添加炮击指示器缩放功能
This commit is contained in:
parent
d6fcd7a101
commit
cb43fade3e
3 changed files with 25 additions and 1 deletions
|
@ -219,6 +219,12 @@ public class ClickHandler {
|
|||
PacketDistributor.sendToServer(new AdjustMortarAngleMessage(scroll));
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
//TODO 为啥还能滚轮换物品?
|
||||
if (player.isUsingItem() && player.getUseItem().is(ModItems.ARTILLERY_INDICATOR.get())) {
|
||||
artilleryIndicatorCustomZoom = Mth.clamp(artilleryIndicatorCustomZoom + 0.4 * scroll, 0, 9);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -113,6 +113,9 @@ public class ClientEventHandler {
|
|||
public static double[] randomShell = {0, 0, 0};
|
||||
|
||||
public static double customZoom = 0;
|
||||
|
||||
public static double artilleryIndicatorZoom = 1;
|
||||
public static double artilleryIndicatorCustomZoom = 0;
|
||||
public static MillisTimer clientTimer = new MillisTimer();
|
||||
public static MillisTimer clientTimerVehicle = new MillisTimer();
|
||||
|
||||
|
@ -1460,6 +1463,22 @@ public class ClientEventHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
double factor;
|
||||
|
||||
if (stack.is(ModItems.ARTILLERY_INDICATOR.get())) {
|
||||
if (player.isUsingItem() && player.getUseItem().is(ModItems.ARTILLERY_INDICATOR.get())) {
|
||||
factor = 2 + artilleryIndicatorCustomZoom;
|
||||
} else {
|
||||
factor = 1;
|
||||
}
|
||||
} else {
|
||||
factor = 1;
|
||||
}
|
||||
|
||||
artilleryIndicatorZoom = Mth.lerp(0.6 * times, artilleryIndicatorZoom, factor);
|
||||
|
||||
event.setFOV(event.getFOV() / artilleryIndicatorZoom);
|
||||
|
||||
if (stack.getItem() instanceof GunItem) {
|
||||
if (!event.usedConfiguredFov()) {
|
||||
return;
|
||||
|
|
|
@ -34,7 +34,6 @@ public class ArtilleryIndicator extends Item {
|
|||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public @NotNull InteractionResultHolder<ItemStack> use(Level worldIn, Player playerIn, InteractionHand handIn) {
|
||||
ItemStack stack = playerIn.getItemInHand(handIn);
|
||||
playerIn.playSound(SoundEvents.SPYGLASS_USE, 1.0F, 1.0F);
|
||||
return ItemUtils.startUsingInstantly(worldIn, playerIn, handIn);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue