修复滚轮问题,优化代码

This commit is contained in:
17146 2025-07-08 22:39:24 +08:00 committed by Light_Quanta
parent f2fc7943e1
commit 380dbf79b7
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
2 changed files with 8 additions and 12 deletions

View file

@ -213,16 +213,14 @@ public class ClickHandler {
event.setCanceled(true);
}
Entity looking = TraceTool.findLookingEntity(player, 6);
if (looking == null) return;
if (looking instanceof MortarEntity && player.isShiftKeyDown()) {
PacketDistributor.sendToServer(new AdjustMortarAngleMessage(scroll));
if (player.isUsingItem() && player.getUseItem().is(ModItems.ARTILLERY_INDICATOR.get())) {
artilleryIndicatorCustomZoom = Mth.clamp(artilleryIndicatorCustomZoom + 0.4 * scroll, 0, 9);
event.setCanceled(true);
}
//TODO 为啥还能滚轮换物品
if (player.isUsingItem() && player.getUseItem().is(ModItems.ARTILLERY_INDICATOR.get())) {
artilleryIndicatorCustomZoom = Mth.clamp(artilleryIndicatorCustomZoom + 0.4 * scroll, 0, 9);
Entity looking = TraceTool.findLookingEntity(player, 6);
if (looking instanceof MortarEntity && player.isShiftKeyDown()) {
PacketDistributor.sendToServer(new AdjustMortarAngleMessage(scroll));
event.setCanceled(true);
}
}

View file

@ -60,6 +60,9 @@ public class MortarEntity extends VehicleEntity implements GeoEntity, Container,
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
private LivingEntity shooter = null;
public ItemStack stack = ItemStack.EMPTY;
public MortarEntity(EntityType<MortarEntity> type, Level level) {
super(type, level);
}
@ -140,9 +143,6 @@ public class MortarEntity extends VehicleEntity implements GeoEntity, Container,
return this.entityData.get(OWNER_UUID).orElse(null);
}
private LivingEntity shooter = null;
public void fire(@Nullable LivingEntity shooter) {
if (!(this.stack.getItem() instanceof MortarShell)) return;
@ -356,8 +356,6 @@ public class MortarEntity extends VehicleEntity implements GeoEntity, Container,
return this.cache;
}
public ItemStack stack = ItemStack.EMPTY;
@Override
public int getContainerSize() {
return 1;