diff --git a/src/main/java/com/atsuishio/superbwarfare/client/overlay/Type63InfoOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/overlay/Type63InfoOverlay.java index 8de7b1b8a..171d18184 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/overlay/Type63InfoOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/overlay/Type63InfoOverlay.java @@ -5,6 +5,7 @@ import com.atsuishio.superbwarfare.component.ModDataComponents; import com.atsuishio.superbwarfare.entity.vehicle.Type63Entity; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.item.FiringParameters; +import com.atsuishio.superbwarfare.item.common.ammo.MediumRocketItem; import com.atsuishio.superbwarfare.tools.*; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; @@ -67,7 +68,6 @@ public class Type63InfoOverlay implements LayeredDraw.Layer { for (int i = 0; i < type63Entity.barrel.length; i++) { if (OBB.getLookingObb(player, player.entityInteractionRange()) == type63Entity.barrel[i]) { int type = items.get(i); - if (type == -1) return; ItemStack stack = switch (type) { case 0 -> new ItemStack(ModItems.MEDIUM_ROCKET_AP.get()); @@ -75,7 +75,6 @@ public class Type63InfoOverlay implements LayeredDraw.Layer { case 2 -> new ItemStack(ModItems.MEDIUM_ROCKET_CM.get()); default -> ItemStack.EMPTY; }; - if (stack.isEmpty()) return; Vec3 pos = new Vec3(type63Entity.barrel[i].center()); Vec3 point = VectorUtil.worldToScreen(pos, cameraPos); @@ -87,6 +86,11 @@ public class Type63InfoOverlay implements LayeredDraw.Layer { poseStack.translate(x, y, 0); var component = Component.literal("[").append(stack.getHoverName()).append("]"); + + if (!(stack.getItem() instanceof MediumRocketItem)) { + component = Component.literal("[").append(Component.translatable("tips.superbwarfare.barrel_empty")).append("]"); + } + int width = Minecraft.getInstance().font.width(component); guiGraphics.drawString(Minecraft.getInstance().font, component, -width / 2, -4, -1, false); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Type63Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Type63Entity.java index 4a982b691..fbd25c9a9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Type63Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Type63Entity.java @@ -56,6 +56,7 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt public static final EntityDataAccessor PITCH = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor YAW = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT); + public static final EntityDataAccessor BODY_YAW = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor SHOOT_PITCH = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor SHOOT_YAW = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT); @@ -116,6 +117,7 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt builder.define(PITCH, 0F) .define(YAW, 0F) + .define(BODY_YAW, 0F) .define(SHOOT_PITCH, 0F) .define(SHOOT_YAW, 0F) .define(LOADED_AMMO, list); @@ -146,20 +148,33 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt ItemStack stack = player.getMainHandItem(); if (stack.isEmpty()) { - if (OBB.getLookingObb(player, player.entityInteractionRange()) == hoe1) { - if (player.level() instanceof ServerLevel) { - setYRot(getYRot() + (float) interactionTick); - interactEvent(new Vec3(hoe1.center())); + if (player.isShiftKeyDown()) { + if (OBB.getLookingObb(player, player.entityInteractionRange()) == hoe1) { + if (player.level() instanceof ServerLevel serverLevel) { + entityData.set(BODY_YAW, entityData.get(BODY_YAW) + 0.2f * (float) interactionTick); + interactionTick++; + if (cooldown == 0) { + cooldown = 6; + Vec3 vec3 = new Vec3(hoe1.center()); + serverLevel.playSound(null, vec3.x, vec3.y, vec3.z, ModSounds.WHEEL_STEP.get(), SoundSource.PLAYERS, 0.5f, random.nextFloat() * 0.05f + 0.975f); + } + } + player.swing(InteractionHand.MAIN_HAND); } - player.swing(InteractionHand.MAIN_HAND); - } - if (OBB.getLookingObb(player, player.entityInteractionRange()) == hoe2) { - if (player.level() instanceof ServerLevel) { - setYRot(getYRot() - (float) interactionTick); - interactEvent(new Vec3(hoe2.center())); + if (OBB.getLookingObb(player, player.entityInteractionRange()) == hoe2) { + if (player.level() instanceof ServerLevel serverLevel) { + entityData.set(BODY_YAW, entityData.get(BODY_YAW) - 0.2f * (float) interactionTick); + interactionTick++; + if (cooldown == 0) { + cooldown = 6; + Vec3 vec3 = new Vec3(hoe1.center()); + serverLevel.playSound(null, vec3.x, vec3.y, vec3.z, ModSounds.WHEEL_STEP.get(), SoundSource.PLAYERS, 0.5f, random.nextFloat() * 0.05f + 0.975f); + } + } + player.swing(InteractionHand.MAIN_HAND); } - player.swing(InteractionHand.MAIN_HAND); } + if (OBB.getLookingObb(player, player.entityInteractionRange()) == yawController) { interactEvent(new Vec3(yawController.center())); entityData.set(YAW, Mth.clamp(entityData.get(YAW) + (player.isShiftKeyDown() ? -0.02f : 0.02f) * (float) interactionTick, -15, 15)); @@ -259,7 +274,7 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt public void interactEvent(Vec3 vec3) { if (level() instanceof ServerLevel serverLevel) { interactionTick++; - interactionTick += 0.5; + interactionTick++; if (cooldown == 0) { cooldown = 6; serverLevel.playSound(null, vec3.x, vec3.y, vec3.z, ModSounds.HAND_WHEEL_ROT.get(), SoundSource.PLAYERS, 1f, random.nextFloat() * 0.05f + 0.975f); @@ -350,6 +365,9 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt entityData.set(SHOOT_YAW, (float) -VehicleEntity.getYRotFromVector(getShootVector(1))); } + entityData.set(BODY_YAW, entityData.get(BODY_YAW) * 0.8f); + setYRot(getYRot() + entityData.get(BODY_YAW)); + this.refreshDimensions(); } diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index 5289751ed..7278a3017 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -600,6 +600,7 @@ "tips.superbwarfare.mortar.warn": "%1$s cannot aim at this position", "tips.superbwarfare.target.yaw": "Target Yaw: ", "tips.superbwarfare.target.pitch": "Target Pitch: ", + "tips.superbwarfare.barrel_empty": "EMPTY", "container.superbwarfare.reforging_table": "Gun Reforge Table", diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index a660574c8..29868bccb 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -600,6 +600,7 @@ "tips.superbwarfare.mortar.warn": "%1$s无法瞄准该位置", "tips.superbwarfare.target.yaw": "目标偏航角: ", "tips.superbwarfare.target.pitch": "目标俯仰角: ", + "tips.superbwarfare.barrel_empty": "空", "container.superbwarfare.reforging_table": "枪械重铸台", "container.superbwarfare.charging_station": "充电站",