优化炮体选择,调整音效,空的格子显示为空

This commit is contained in:
Atsuishio 2025-07-14 17:46:27 +08:00 committed by Light_Quanta
parent 9d7353dd85
commit 0b2823abe9
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
4 changed files with 38 additions and 14 deletions

View file

@ -5,6 +5,7 @@ import com.atsuishio.superbwarfare.component.ModDataComponents;
import com.atsuishio.superbwarfare.entity.vehicle.Type63Entity; import com.atsuishio.superbwarfare.entity.vehicle.Type63Entity;
import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.item.FiringParameters; import com.atsuishio.superbwarfare.item.FiringParameters;
import com.atsuishio.superbwarfare.item.common.ammo.MediumRocketItem;
import com.atsuishio.superbwarfare.tools.*; import com.atsuishio.superbwarfare.tools.*;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
@ -67,7 +68,6 @@ public class Type63InfoOverlay implements LayeredDraw.Layer {
for (int i = 0; i < type63Entity.barrel.length; i++) { for (int i = 0; i < type63Entity.barrel.length; i++) {
if (OBB.getLookingObb(player, player.entityInteractionRange()) == type63Entity.barrel[i]) { if (OBB.getLookingObb(player, player.entityInteractionRange()) == type63Entity.barrel[i]) {
int type = items.get(i); int type = items.get(i);
if (type == -1) return;
ItemStack stack = switch (type) { ItemStack stack = switch (type) {
case 0 -> new ItemStack(ModItems.MEDIUM_ROCKET_AP.get()); 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()); case 2 -> new ItemStack(ModItems.MEDIUM_ROCKET_CM.get());
default -> ItemStack.EMPTY; default -> ItemStack.EMPTY;
}; };
if (stack.isEmpty()) return;
Vec3 pos = new Vec3(type63Entity.barrel[i].center()); Vec3 pos = new Vec3(type63Entity.barrel[i].center());
Vec3 point = VectorUtil.worldToScreen(pos, cameraPos); Vec3 point = VectorUtil.worldToScreen(pos, cameraPos);
@ -87,6 +86,11 @@ public class Type63InfoOverlay implements LayeredDraw.Layer {
poseStack.translate(x, y, 0); poseStack.translate(x, y, 0);
var component = Component.literal("[").append(stack.getHoverName()).append("]"); 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); int width = Minecraft.getInstance().font.width(component);
guiGraphics.drawString(Minecraft.getInstance().font, component, -width / 2, -4, -1, false); guiGraphics.drawString(Minecraft.getInstance().font, component, -width / 2, -4, -1, false);

View file

@ -56,6 +56,7 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt
public static final EntityDataAccessor<Float> PITCH = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor<Float> PITCH = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> YAW = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor<Float> YAW = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> BODY_YAW = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> SHOOT_PITCH = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor<Float> SHOOT_PITCH = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> SHOOT_YAW = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor<Float> SHOOT_YAW = SynchedEntityData.defineId(Type63Entity.class, EntityDataSerializers.FLOAT);
@ -116,6 +117,7 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt
builder.define(PITCH, 0F) builder.define(PITCH, 0F)
.define(YAW, 0F) .define(YAW, 0F)
.define(BODY_YAW, 0F)
.define(SHOOT_PITCH, 0F) .define(SHOOT_PITCH, 0F)
.define(SHOOT_YAW, 0F) .define(SHOOT_YAW, 0F)
.define(LOADED_AMMO, list); .define(LOADED_AMMO, list);
@ -146,20 +148,33 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();
if (stack.isEmpty()) { if (stack.isEmpty()) {
if (OBB.getLookingObb(player, player.entityInteractionRange()) == hoe1) { if (player.isShiftKeyDown()) {
if (player.level() instanceof ServerLevel) { if (OBB.getLookingObb(player, player.entityInteractionRange()) == hoe1) {
setYRot(getYRot() + (float) interactionTick); if (player.level() instanceof ServerLevel serverLevel) {
interactEvent(new Vec3(hoe1.center())); 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 serverLevel) {
if (OBB.getLookingObb(player, player.entityInteractionRange()) == hoe2) { entityData.set(BODY_YAW, entityData.get(BODY_YAW) - 0.2f * (float) interactionTick);
if (player.level() instanceof ServerLevel) { interactionTick++;
setYRot(getYRot() - (float) interactionTick); if (cooldown == 0) {
interactEvent(new Vec3(hoe2.center())); 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) { if (OBB.getLookingObb(player, player.entityInteractionRange()) == yawController) {
interactEvent(new Vec3(yawController.center())); interactEvent(new Vec3(yawController.center()));
entityData.set(YAW, Mth.clamp(entityData.get(YAW) + (player.isShiftKeyDown() ? -0.02f : 0.02f) * (float) interactionTick, -15, 15)); 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) { public void interactEvent(Vec3 vec3) {
if (level() instanceof ServerLevel serverLevel) { if (level() instanceof ServerLevel serverLevel) {
interactionTick++; interactionTick++;
interactionTick += 0.5; interactionTick++;
if (cooldown == 0) { if (cooldown == 0) {
cooldown = 6; 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); 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(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(); this.refreshDimensions();
} }

View file

@ -600,6 +600,7 @@
"tips.superbwarfare.mortar.warn": "%1$s cannot aim at this position", "tips.superbwarfare.mortar.warn": "%1$s cannot aim at this position",
"tips.superbwarfare.target.yaw": "Target Yaw: ", "tips.superbwarfare.target.yaw": "Target Yaw: ",
"tips.superbwarfare.target.pitch": "Target Pitch: ", "tips.superbwarfare.target.pitch": "Target Pitch: ",
"tips.superbwarfare.barrel_empty": "EMPTY",
"container.superbwarfare.reforging_table": "Gun Reforge Table", "container.superbwarfare.reforging_table": "Gun Reforge Table",

View file

@ -600,6 +600,7 @@
"tips.superbwarfare.mortar.warn": "%1$s无法瞄准该位置", "tips.superbwarfare.mortar.warn": "%1$s无法瞄准该位置",
"tips.superbwarfare.target.yaw": "目标偏航角: ", "tips.superbwarfare.target.yaw": "目标偏航角: ",
"tips.superbwarfare.target.pitch": "目标俯仰角: ", "tips.superbwarfare.target.pitch": "目标俯仰角: ",
"tips.superbwarfare.barrel_empty": "空",
"container.superbwarfare.reforging_table": "枪械重铸台", "container.superbwarfare.reforging_table": "枪械重铸台",
"container.superbwarfare.charging_station": "充电站", "container.superbwarfare.charging_station": "充电站",