修改载具武器方法名称
This commit is contained in:
parent
a0d156a4eb
commit
00f40884a6
12 changed files with 102 additions and 73 deletions
|
@ -118,7 +118,7 @@ public class HelicopterHudOverlay {
|
||||||
w / 2 - 140, h / 2, 0x66FF00, false);
|
w / 2 - 140, h / 2, 0x66FF00, false);
|
||||||
|
|
||||||
if (mobileVehicle instanceof Ah6Entity ah6Entity) {
|
if (mobileVehicle instanceof Ah6Entity ah6Entity) {
|
||||||
if (weaponVehicle.getWeaponType(0) == 0) {
|
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||||
double heat = 1 - ah6Entity.heat / 100.0F;
|
double heat = 1 - ah6Entity.heat / 100.0F;
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : iHelicopterEntity.getAmmoCount(player))), w / 2 - 160, h / 2 - 60, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : iHelicopterEntity.getAmmoCount(player))), w / 2 - 160, h / 2 - 60, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -186,7 +186,7 @@ public class HelicopterHudOverlay {
|
||||||
poseStack.scale(0.75f, 0.75f, 1);
|
poseStack.scale(0.75f, 0.75f, 1);
|
||||||
|
|
||||||
if (mobileVehicle instanceof Ah6Entity ah6Entity) {
|
if (mobileVehicle instanceof Ah6Entity ah6Entity) {
|
||||||
if (weaponVehicle.getWeaponType(0) == 0) {
|
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||||
double heat = ah6Entity.heat / 100.0F;
|
double heat = ah6Entity.heat / 100.0F;
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : iHelicopterEntity.getAmmoCount(player))), 25, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : iHelicopterEntity.getAmmoCount(player))), 25, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class VehicleHudOverlay {
|
||||||
//
|
//
|
||||||
// if (InventoryTool.hasCreativeAmmoBox(player)
|
// if (InventoryTool.hasCreativeAmmoBox(player)
|
||||||
// && !(iVehicle instanceof CannonEntity
|
// && !(iVehicle instanceof CannonEntity
|
||||||
// || (iVehicle instanceof Ah6Entity ah6Entity && ah6Entity.getWeaponType(0) == 1))
|
// || (iVehicle instanceof Ah6Entity ah6Entity && ah6Entity.getWeaponIndex(0) == 1))
|
||||||
// ) {
|
// ) {
|
||||||
// event.getGuiGraphics().drawString(
|
// event.getGuiGraphics().drawString(
|
||||||
// Minecraft.getInstance().font,
|
// Minecraft.getInstance().font,
|
||||||
|
@ -169,7 +169,7 @@ public class VehicleHudOverlay {
|
||||||
return Component.translatable("des.superbwarfare.tips.ammo_type.cal50").getString();
|
return Component.translatable("des.superbwarfare.tips.ammo_type.cal50").getString();
|
||||||
}
|
}
|
||||||
if (iVehicle instanceof Ah6Entity ah6Entity) {
|
if (iVehicle instanceof Ah6Entity ah6Entity) {
|
||||||
if (ah6Entity.getWeaponType(0) == 0) {
|
if (ah6Entity.getWeaponIndex(0) == 0) {
|
||||||
return Component.translatable("des.superbwarfare.tips.ammo_type.20mm_cannon").getString();
|
return Component.translatable("des.superbwarfare.tips.ammo_type.20mm_cannon").getString();
|
||||||
} else {
|
} else {
|
||||||
return Component.translatable("des.superbwarfare.tips.ammo_type.rocket").getString();
|
return Component.translatable("des.superbwarfare.tips.ammo_type.rocket").getString();
|
||||||
|
@ -229,18 +229,18 @@ public class VehicleHudOverlay {
|
||||||
|
|
||||||
// 不同武器种类的准星
|
// 不同武器种类的准星
|
||||||
if (weaponVehicle instanceof Yx100Entity) {
|
if (weaponVehicle instanceof Yx100Entity) {
|
||||||
if (weaponVehicle.getWeaponType(0) == 0) {
|
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/tank_cannon_cross_ap.png"), k, l, 0, 0.0F, i, j, i, j);
|
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/tank_cannon_cross_ap.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||||
} else if (weaponVehicle.getWeaponType(0) == 1) {
|
} else if (weaponVehicle.getWeaponIndex(0) == 1) {
|
||||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/tank_cannon_cross_he.png"), k, l, 0, 0.0F, i, j, i, j);
|
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/tank_cannon_cross_he.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (weaponVehicle.getWeaponType(0) == 0) {
|
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/lav_cannon_cross.png"), k, l, 0, 0.0F, i, j, i, j);
|
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/lav_cannon_cross.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||||
} else if (weaponVehicle.getWeaponType(0) == 1) {
|
} else if (weaponVehicle.getWeaponIndex(0) == 1) {
|
||||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/lav_gun_cross.png"), k, l, 0, 0.0F, i, j, i, j);
|
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/lav_gun_cross.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||||
} else if (weaponVehicle.getWeaponType(0) == 2) {
|
} else if (weaponVehicle.getWeaponIndex(0) == 2) {
|
||||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/lav_missile_cross.png"), k, l, 0, 0.0F, i, j, i, j);
|
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/lav_missile_cross.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,6 @@ public class VehicleHudOverlay {
|
||||||
w / 2 + 160, h / 2 - 48, 0x66FF00, false);
|
w / 2 + 160, h / 2 - 48, 0x66FF00, false);
|
||||||
|
|
||||||
// 低电量警告
|
// 低电量警告
|
||||||
|
|
||||||
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
||||||
guiGraphics.drawString(mc.font, Component.literal("NO POWER!"),
|
guiGraphics.drawString(mc.font, Component.literal("NO POWER!"),
|
||||||
w / 2 - 144, h / 2 + 14, -65536, false);
|
w / 2 - 144, h / 2 + 14, -65536, false);
|
||||||
|
@ -299,9 +298,9 @@ public class VehicleHudOverlay {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 武器名称
|
// 武器名称
|
||||||
//LAV-150
|
// LAV-150
|
||||||
if (player.getVehicle() instanceof Lav150Entity lav) {
|
if (player.getVehicle() instanceof Lav150Entity lav) {
|
||||||
if (weaponVehicle.getWeaponType(0) == 0) {
|
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||||
double heat = 1 - lav.getEntityData().get(HEAT) / 100.0F;
|
double heat = 1 - lav.getEntityData().get(HEAT) / 100.0F;
|
||||||
guiGraphics.drawString(mc.font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : lav.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
guiGraphics.drawString(mc.font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : lav.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -310,12 +309,12 @@ public class VehicleHudOverlay {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//BMP-2
|
// BMP-2
|
||||||
if (player.getVehicle() instanceof Bmp2Entity bmp2) {
|
if (player.getVehicle() instanceof Bmp2Entity bmp2) {
|
||||||
if (weaponVehicle.getWeaponType(0) == 0) {
|
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||||
double heat = 1 - bmp2.getEntityData().get(HEAT) / 100.0F;
|
double heat = 1 - bmp2.getEntityData().get(HEAT) / 100.0F;
|
||||||
guiGraphics.drawString(mc.font, Component.literal(" 30MM 2A42 " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp2.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
guiGraphics.drawString(mc.font, Component.literal(" 30MM 2A42 " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp2.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||||
} else if (weaponVehicle.getWeaponType(0) == 1) {
|
} else if (weaponVehicle.getWeaponIndex(0) == 1) {
|
||||||
double heat = 1 - bmp2.getEntityData().get(COAX_HEAT) / 100.0F;
|
double heat = 1 - bmp2.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||||
guiGraphics.drawString(mc.font, Component.literal(" 7.62MM ПКТ " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp2.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
guiGraphics.drawString(mc.font, Component.literal(" 7.62MM ПКТ " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp2.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -324,9 +323,9 @@ public class VehicleHudOverlay {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//YX-100
|
// YX-100
|
||||||
if (player.getVehicle() instanceof Yx100Entity yx100) {
|
if (player.getVehicle() instanceof Yx100Entity yx100) {
|
||||||
if (weaponVehicle.getWeaponType(0) == 0) {
|
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||||
guiGraphics.drawString(mc.font, Component.literal("AP SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), w / 2 - 33, h - 65, 0x66FF00, false);
|
guiGraphics.drawString(mc.font, Component.literal("AP SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), w / 2 - 33, h - 65, 0x66FF00, false);
|
||||||
} else {
|
} else {
|
||||||
guiGraphics.drawString(mc.font, Component.literal("HE SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), w / 2 - 33, h - 65, 0x66FF00, false);
|
guiGraphics.drawString(mc.font, Component.literal("HE SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), w / 2 - 33, h - 65, 0x66FF00, false);
|
||||||
|
@ -357,7 +356,7 @@ public class VehicleHudOverlay {
|
||||||
|
|
||||||
// LAV-150
|
// LAV-150
|
||||||
if (weaponVehicle instanceof Lav150Entity lav1501) {
|
if (weaponVehicle instanceof Lav150Entity lav1501) {
|
||||||
if (weaponVehicle.getWeaponType(0) == 0) {
|
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||||
double heat = lav1501.getEntityData().get(HEAT) / 100.0F;
|
double heat = lav1501.getEntityData().get(HEAT) / 100.0F;
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : lav1501.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : lav1501.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -367,10 +366,10 @@ public class VehicleHudOverlay {
|
||||||
}
|
}
|
||||||
// BMP-2
|
// BMP-2
|
||||||
if (weaponVehicle instanceof Bmp2Entity bmp201) {
|
if (weaponVehicle instanceof Bmp2Entity bmp201) {
|
||||||
if (weaponVehicle.getWeaponType(0) == 0) {
|
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||||
double heat = bmp201.getEntityData().get(HEAT) / 100.0F;
|
double heat = bmp201.getEntityData().get(HEAT) / 100.0F;
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("30MM 2A42 " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp201.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("30MM 2A42 " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp201.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||||
} else if (weaponVehicle.getWeaponType(0) == 1) {
|
} else if (weaponVehicle.getWeaponIndex(0) == 1) {
|
||||||
double heat2 = bmp201.getEntityData().get(COAX_HEAT) / 100.0F;
|
double heat2 = bmp201.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("7.62MM ПКТ " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp201.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat2, 1.0F), false);
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("7.62MM ПКТ " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp201.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat2, 1.0F), false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -379,7 +378,7 @@ public class VehicleHudOverlay {
|
||||||
}
|
}
|
||||||
// YX-100
|
// YX-100
|
||||||
if (weaponVehicle instanceof Yx100Entity yx100) {
|
if (weaponVehicle instanceof Yx100Entity yx100) {
|
||||||
if (weaponVehicle.getWeaponType(0) == 0) {
|
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("AP SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), 30, -9, -1, false);
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("AP SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), 30, -9, -1, false);
|
||||||
} else {
|
} else {
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HE SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), 30, -9, -1, false);
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HE SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), 30, -9, -1, false);
|
||||||
|
@ -510,6 +509,35 @@ public class VehicleHudOverlay {
|
||||||
var weapons = weaponVehicle.getAvailableWeapons(index);
|
var weapons = weaponVehicle.getAvailableWeapons(index);
|
||||||
if (weapons.isEmpty()) return;
|
if (weapons.isEmpty()) return;
|
||||||
|
|
||||||
|
int weaponType = weaponVehicle.getWeaponIndex(index);
|
||||||
|
if (weaponType == -1) return;
|
||||||
|
|
||||||
|
var pose = guiGraphics.pose();
|
||||||
|
|
||||||
|
pose.pushPose();
|
||||||
|
|
||||||
|
RenderSystem.disableDepthTest();
|
||||||
|
RenderSystem.depthMask(false);
|
||||||
|
RenderSystem.enableBlend();
|
||||||
|
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||||
|
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||||
|
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||||
|
|
||||||
// TODO 实现载具武器HUD
|
// TODO 实现载具武器HUD
|
||||||
|
int frameIndex = 0;
|
||||||
|
|
||||||
|
for (int i = weapons.size() - 1; i >= 0 && i < 9; i--) {
|
||||||
|
ResourceLocation frame = ModUtils.loc("textures/screens/vehicle_weapon/frame_" + (i + 1) + ".png");
|
||||||
|
|
||||||
|
pose.pushPose();
|
||||||
|
|
||||||
|
preciseBlit(guiGraphics, frame, w - 85, h - frameIndex * 18 - 20, 100, 0, 0, 75, 16, 75, 16);
|
||||||
|
|
||||||
|
pose.popPose();
|
||||||
|
|
||||||
|
frameIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
pose.popPose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
this.level().playSound(null, this, ModSounds.MISSILE_RELOAD.get(), this.getSoundSource(), 1, 1);
|
this.level().playSound(null, this, ModSounds.MISSILE_RELOAD.get(), this.getSoundSource(), 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getWeaponType(0) == 0) {
|
if (this.getWeaponIndex(0) == 0) {
|
||||||
this.entityData.set(AMMO, ammoCount);
|
this.entityData.set(AMMO, ammoCount);
|
||||||
} else {
|
} else {
|
||||||
this.entityData.set(AMMO, this.getEntityData().get(LOADED_ROCKET));
|
this.entityData.set(AMMO, this.getEntityData().get(LOADED_ROCKET));
|
||||||
|
@ -570,7 +570,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
Vector4f worldPositionRight;
|
Vector4f worldPositionRight;
|
||||||
Vector4f worldPositionLeft;
|
Vector4f worldPositionLeft;
|
||||||
|
|
||||||
if (getWeaponType(0) == 0) {
|
if (getWeaponIndex(0) == 0) {
|
||||||
if (this.cannotFire) return;
|
if (this.cannotFire) return;
|
||||||
|
|
||||||
x = 1.15f;
|
x = 1.15f;
|
||||||
|
@ -635,7 +635,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(6, 5, 7, this.getX(), this.getEyeY(), this.getZ()));
|
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(6, 5, 7, this.getX(), this.getEyeY(), this.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (getWeaponType(0) == 1 && this.getEntityData().get(LOADED_ROCKET) > 0) {
|
} else if (getWeaponIndex(0) == 1 && this.getEntityData().get(LOADED_ROCKET) > 0) {
|
||||||
x = 1.7f;
|
x = 1.7f;
|
||||||
y = 0.62f - 1.45f;
|
y = 0.62f - 1.45f;
|
||||||
z = 0.8f;
|
z = 0.8f;
|
||||||
|
@ -718,9 +718,9 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canShoot(Player player) {
|
public boolean canShoot(Player player) {
|
||||||
if (getWeaponType(0) == 0) {
|
if (getWeaponIndex(0) == 0) {
|
||||||
return (this.entityData.get(AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFire;
|
return (this.entityData.get(AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFire;
|
||||||
} else if (getWeaponType(0) == 1) {
|
} else if (getWeaponIndex(0) == 1) {
|
||||||
return this.entityData.get(AMMO) > 0;
|
return this.entityData.get(AMMO) > 0;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -312,9 +312,9 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
||||||
this.level().playSound(null, this, ModSounds.BMP_MISSILE_RELOAD.get(), this.getSoundSource(), 1, 1);
|
this.level().playSound(null, this, ModSounds.BMP_MISSILE_RELOAD.get(), this.getSoundSource(), 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getWeaponType(0) == 0) {
|
if (getWeaponIndex(0) == 0) {
|
||||||
this.entityData.set(AMMO, countItem(ModItems.SMALL_SHELL.get()));
|
this.entityData.set(AMMO, countItem(ModItems.SMALL_SHELL.get()));
|
||||||
} else if (getWeaponType(0) == 1) {
|
} else if (getWeaponIndex(0) == 1) {
|
||||||
this.entityData.set(AMMO, ammoCount);
|
this.entityData.set(AMMO, ammoCount);
|
||||||
} else {
|
} else {
|
||||||
this.entityData.set(AMMO, countItem(ModItems.WIRE_GUIDE_MISSILE.get()));
|
this.entityData.set(AMMO, countItem(ModItems.WIRE_GUIDE_MISSILE.get()));
|
||||||
|
@ -332,7 +332,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
||||||
@Override
|
@Override
|
||||||
public void vehicleShoot(Player player, int type) {
|
public void vehicleShoot(Player player, int type) {
|
||||||
Matrix4f transform = getBarrelTransform();
|
Matrix4f transform = getBarrelTransform();
|
||||||
if (getWeaponType(0) == 0) {
|
if (getWeaponIndex(0) == 0) {
|
||||||
if (this.cannotFire) return;
|
if (this.cannotFire) return;
|
||||||
float x = -0.1125f;
|
float x = -0.1125f;
|
||||||
float y = 0.174025f;
|
float y = 0.174025f;
|
||||||
|
@ -370,7 +370,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
||||||
this.entityData.set(HEAT, this.entityData.get(HEAT) + 7);
|
this.entityData.set(HEAT, this.entityData.get(HEAT) + 7);
|
||||||
this.entityData.set(FIRE_ANIM, 3);
|
this.entityData.set(FIRE_ANIM, 3);
|
||||||
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
||||||
} else if (getWeaponType(0) == 1) {
|
} else if (getWeaponIndex(0) == 1) {
|
||||||
if (this.cannotFireCoax) return;
|
if (this.cannotFireCoax) return;
|
||||||
float x = 0.1125f;
|
float x = 0.1125f;
|
||||||
float y = 0.174025f;
|
float y = 0.174025f;
|
||||||
|
@ -414,7 +414,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
||||||
serverPlayer.playSound(ModSounds.M_60_VERYFAR.get(), 12, 1);
|
serverPlayer.playSound(ModSounds.M_60_VERYFAR.get(), 12, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (getWeaponType(0) == 2 && this.getEntityData().get(LOADED_MISSILE) > 0) {
|
} else if (getWeaponIndex(0) == 2 && this.getEntityData().get(LOADED_MISSILE) > 0) {
|
||||||
Matrix4f transformT = getBarrelTransform();
|
Matrix4f transformT = getBarrelTransform();
|
||||||
Vector4f worldPosition = transformPosition(transformT, 0, 1, 0);
|
Vector4f worldPosition = transformPosition(transformT, 0, 1, 0);
|
||||||
|
|
||||||
|
@ -683,11 +683,11 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayState firePredicate(AnimationState<Bmp2Entity> event) {
|
private PlayState firePredicate(AnimationState<Bmp2Entity> event) {
|
||||||
if (this.entityData.get(FIRE_ANIM) > 1 && getWeaponType(0) == 0) {
|
if (this.entityData.get(FIRE_ANIM) > 1 && getWeaponIndex(0) == 0) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.lav.fire"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.lav.fire"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.entityData.get(FIRE_ANIM) > 0 && getWeaponType(0) == 1) {
|
if (this.entityData.get(FIRE_ANIM) > 0 && getWeaponIndex(0) == 1) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.lav.fire2"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.lav.fire2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,9 +716,9 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int mainGunRpm(Player player) {
|
public int mainGunRpm(Player player) {
|
||||||
if (getWeaponType(0) == 0) {
|
if (getWeaponIndex(0) == 0) {
|
||||||
return 250;
|
return 250;
|
||||||
} else if (getWeaponType(0) == 1) {
|
} else if (getWeaponIndex(0) == 1) {
|
||||||
return 750;
|
return 750;
|
||||||
}
|
}
|
||||||
return 250;
|
return 250;
|
||||||
|
@ -726,11 +726,11 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canShoot(Player player) {
|
public boolean canShoot(Player player) {
|
||||||
if (getWeaponType(0) == 0) {
|
if (getWeaponIndex(0) == 0) {
|
||||||
return (this.entityData.get(AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFire;
|
return (this.entityData.get(AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFire;
|
||||||
} else if (getWeaponType(0) == 1) {
|
} else if (getWeaponIndex(0) == 1) {
|
||||||
return (this.entityData.get(AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFireCoax;
|
return (this.entityData.get(AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFireCoax;
|
||||||
} else if (getWeaponType(0) == 2) {
|
} else if (getWeaponIndex(0) == 2) {
|
||||||
return (this.entityData.get(LOADED_MISSILE) > 0);
|
return (this.entityData.get(LOADED_MISSILE) > 0);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -275,9 +275,9 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
return false;
|
return false;
|
||||||
}).mapToInt(AmmoType.RIFLE::get).sum() + countItem(ModItems.RIFLE_AMMO.get());
|
}).mapToInt(AmmoType.RIFLE::get).sum() + countItem(ModItems.RIFLE_AMMO.get());
|
||||||
|
|
||||||
if (getWeaponType(0) == 0) {
|
if (getWeaponIndex(0) == 0) {
|
||||||
this.entityData.set(AMMO, countItem(ModItems.SMALL_SHELL.get()));
|
this.entityData.set(AMMO, countItem(ModItems.SMALL_SHELL.get()));
|
||||||
} else if (getWeaponType(0) == 1) {
|
} else if (getWeaponIndex(0) == 1) {
|
||||||
this.entityData.set(AMMO, ammoCount);
|
this.entityData.set(AMMO, ammoCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
boolean hasCreativeAmmo = InventoryTool.hasCreativeAmmoBox(player);
|
boolean hasCreativeAmmo = InventoryTool.hasCreativeAmmoBox(player);
|
||||||
|
|
||||||
Matrix4f transform = getBarrelTransform();
|
Matrix4f transform = getBarrelTransform();
|
||||||
if (getWeaponType(0) == 0) {
|
if (getWeaponIndex(0) == 0) {
|
||||||
if (this.cannotFire) return;
|
if (this.cannotFire) return;
|
||||||
float x = -0.0234375f;
|
float x = -0.0234375f;
|
||||||
float y = 0f;
|
float y = 0f;
|
||||||
|
@ -334,7 +334,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
this.entityData.set(FIRE_ANIM, 3);
|
this.entityData.set(FIRE_ANIM, 3);
|
||||||
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
||||||
|
|
||||||
} else if (getWeaponType(0) == 1) {
|
} else if (getWeaponIndex(0) == 1) {
|
||||||
if (this.cannotFireCoax) return;
|
if (this.cannotFireCoax) return;
|
||||||
float x = 0.3f;
|
float x = 0.3f;
|
||||||
float y = 0.08f;
|
float y = 0.08f;
|
||||||
|
@ -624,11 +624,11 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayState firePredicate(AnimationState<Lav150Entity> event) {
|
private PlayState firePredicate(AnimationState<Lav150Entity> event) {
|
||||||
if (this.entityData.get(FIRE_ANIM) > 1 && getWeaponType(0) == 0) {
|
if (this.entityData.get(FIRE_ANIM) > 1 && getWeaponIndex(0) == 0) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.lav.fire"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.lav.fire"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.entityData.get(FIRE_ANIM) > 0 && getWeaponType(0) == 1) {
|
if (this.entityData.get(FIRE_ANIM) > 0 && getWeaponIndex(0) == 1) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.lav.fire2"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.lav.fire2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,9 +657,9 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int mainGunRpm(Player player) {
|
public int mainGunRpm(Player player) {
|
||||||
if (getWeaponType(0) == 0) {
|
if (getWeaponIndex(0) == 0) {
|
||||||
return 300;
|
return 300;
|
||||||
} else if (getWeaponType(0) == 1) {
|
} else if (getWeaponIndex(0) == 1) {
|
||||||
return 600;
|
return 600;
|
||||||
}
|
}
|
||||||
return 300;
|
return 300;
|
||||||
|
@ -667,9 +667,9 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canShoot(Player player) {
|
public boolean canShoot(Player player) {
|
||||||
if (getWeaponType(0) == 0) {
|
if (getWeaponIndex(0) == 0) {
|
||||||
return (this.entityData.get(AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFire;
|
return (this.entityData.get(AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFire;
|
||||||
} else if (getWeaponType(0) == 1) {
|
} else if (getWeaponIndex(0) == 1) {
|
||||||
return (this.entityData.get(AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFireCoax;
|
return (this.entityData.get(AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFireCoax;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
|
||||||
if (stack.getItem() instanceof CannonShellItem) {
|
if (stack.getItem() instanceof CannonShellItem) {
|
||||||
if (this.entityData.get(COOL_DOWN) == 0) {
|
if (this.entityData.get(COOL_DOWN) == 0) {
|
||||||
var weaponType = stack.is(ModItems.AP_5_INCHES.get()) ? 0 : 1;
|
var weaponType = stack.is(ModItems.AP_5_INCHES.get()) ? 0 : 1;
|
||||||
setWeaponType(0, weaponType);
|
setWeaponIndex(0, weaponType);
|
||||||
vehicleShoot(player, 0);
|
vehicleShoot(player, 0);
|
||||||
}
|
}
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
@ -266,7 +266,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
|
||||||
var isCreative = player.isCreative() || InventoryTool.hasCreativeAmmoBox(player);
|
var isCreative = player.isCreative() || InventoryTool.hasCreativeAmmoBox(player);
|
||||||
|
|
||||||
if (!isCreative) {
|
if (!isCreative) {
|
||||||
var ammo = getWeaponType(0) == 0 ? ModItems.AP_5_INCHES.get() : ModItems.HE_5_INCHES.get();
|
var ammo = getWeaponIndex(0) == 0 ? ModItems.AP_5_INCHES.get() : ModItems.HE_5_INCHES.get();
|
||||||
var ammoCount = InventoryTool.countItem(player.getInventory().items, ammo);
|
var ammoCount = InventoryTool.countItem(player.getInventory().items, ammo);
|
||||||
|
|
||||||
if (ammoCount <= 0) return;
|
if (ammoCount <= 0) return;
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
||||||
if (stack.getItem() instanceof CannonShellItem) {
|
if (stack.getItem() instanceof CannonShellItem) {
|
||||||
if (this.entityData.get(COOL_DOWN) == 0) {
|
if (this.entityData.get(COOL_DOWN) == 0) {
|
||||||
var weaponType = stack.is(ModItems.AP_5_INCHES.get()) ? 0 : 1;
|
var weaponType = stack.is(ModItems.AP_5_INCHES.get()) ? 0 : 1;
|
||||||
setWeaponType(0, weaponType);
|
setWeaponIndex(0, weaponType);
|
||||||
vehicleShoot(player, 0);
|
vehicleShoot(player, 0);
|
||||||
}
|
}
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
@ -282,7 +282,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
||||||
if (isCreative) {
|
if (isCreative) {
|
||||||
consumed = 2;
|
consumed = 2;
|
||||||
} else {
|
} else {
|
||||||
var ammo = getWeaponType(0) == 0 ? ModItems.AP_5_INCHES.get() : ModItems.HE_5_INCHES.get();
|
var ammo = getWeaponIndex(0) == 0 ? ModItems.AP_5_INCHES.get() : ModItems.HE_5_INCHES.get();
|
||||||
var ammoCount = InventoryTool.countItem(player.getInventory().items, ammo);
|
var ammoCount = InventoryTool.countItem(player.getInventory().items, ammo);
|
||||||
|
|
||||||
// 尝试消耗两发弹药
|
// 尝试消耗两发弹药
|
||||||
|
@ -298,7 +298,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
|
||||||
int durability;
|
int durability;
|
||||||
boolean salvoShoot = consumed == 2;
|
boolean salvoShoot = consumed == 2;
|
||||||
|
|
||||||
if (getWeaponType(0) == 1) {
|
if (getWeaponIndex(0) == 1) {
|
||||||
// HE
|
// HE
|
||||||
hitDamage = VehicleConfig.MLE1934_HE_DAMAGE.get();
|
hitDamage = VehicleConfig.MLE1934_HE_DAMAGE.get();
|
||||||
explosionRadius = VehicleConfig.MLE1934_HE_EXPLOSION_RADIUS.get();
|
explosionRadius = VehicleConfig.MLE1934_HE_EXPLOSION_RADIUS.get();
|
||||||
|
|
|
@ -166,16 +166,16 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
super.addAdditionalSaveData(compound);
|
super.addAdditionalSaveData(compound);
|
||||||
compound.putInt("LoadedAmmo", this.entityData.get(LOADED_AMMO));
|
compound.putInt("LoadedAmmo", this.entityData.get(LOADED_AMMO));
|
||||||
compound.putInt("WeaponType", getWeaponType(0));
|
compound.putInt("WeaponType", getWeaponIndex(0));
|
||||||
compound.putInt("PassengerWeaponType", getWeaponType(1));
|
compound.putInt("PassengerWeaponType", getWeaponIndex(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readAdditionalSaveData(CompoundTag compound) {
|
public void readAdditionalSaveData(CompoundTag compound) {
|
||||||
super.readAdditionalSaveData(compound);
|
super.readAdditionalSaveData(compound);
|
||||||
this.entityData.set(LOADED_AMMO, compound.getInt("LoadedAmmo"));
|
this.entityData.set(LOADED_AMMO, compound.getInt("LoadedAmmo"));
|
||||||
setWeaponType(0, compound.getInt("WeaponType"));
|
setWeaponIndex(0, compound.getInt("WeaponType"));
|
||||||
setWeaponType(1, compound.getInt("PassengerWeaponType"));
|
setWeaponIndex(1, compound.getInt("PassengerWeaponType"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -38,11 +38,11 @@ public interface WeaponVehicleEntity extends ArmedVehicleEntity {
|
||||||
if (weapons.isEmpty()) return;
|
if (weapons.isEmpty()) return;
|
||||||
var count = weapons.size();
|
var count = weapons.size();
|
||||||
|
|
||||||
var typeIndex = isScroll ? (value + getWeaponType(index) + count) % count : value;
|
var typeIndex = isScroll ? (value + getWeaponIndex(index) + count) % count : value;
|
||||||
var weapon = weapons.get(typeIndex);
|
var weapon = weapons.get(typeIndex);
|
||||||
|
|
||||||
// 修改该槽位选择的武器
|
// 修改该槽位选择的武器
|
||||||
setWeaponType(index, typeIndex);
|
setWeaponIndex(index, typeIndex);
|
||||||
|
|
||||||
// 播放武器切换音效
|
// 播放武器切换音效
|
||||||
var sound = weapon.sound;
|
var sound = weapon.sound;
|
||||||
|
@ -92,19 +92,19 @@ public interface WeaponVehicleEntity extends ArmedVehicleEntity {
|
||||||
var weapons = getAvailableWeapons(index);
|
var weapons = getAvailableWeapons(index);
|
||||||
if (weapons.isEmpty()) return null;
|
if (weapons.isEmpty()) return null;
|
||||||
|
|
||||||
var type = getWeaponType(index);
|
var type = getWeaponIndex(index);
|
||||||
if (type < 0 || type >= weapons.size()) return null;
|
if (type < 0 || type >= weapons.size()) return null;
|
||||||
|
|
||||||
return weapons.get(type);
|
return weapons.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取该槽位当前的武器类型,返回-1则表示该位置没有可用武器
|
* 获取该槽位当前的武器编号,返回-1则表示该位置没有可用武器
|
||||||
*
|
*
|
||||||
* @param index 武器槽位
|
* @param index 武器槽位
|
||||||
* @return 武器类型
|
* @return 武器类型
|
||||||
*/
|
*/
|
||||||
default int getWeaponType(int index) {
|
default int getWeaponIndex(int index) {
|
||||||
if (!(this instanceof VehicleEntity vehicle)) return -1;
|
if (!(this instanceof VehicleEntity vehicle)) return -1;
|
||||||
|
|
||||||
var selectedWeapons = vehicle.getEntityData().get(VehicleEntity.SELECTED_WEAPON);
|
var selectedWeapons = vehicle.getEntityData().get(VehicleEntity.SELECTED_WEAPON);
|
||||||
|
@ -114,12 +114,12 @@ public interface WeaponVehicleEntity extends ArmedVehicleEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置该槽位当前的武器类型
|
* 设置该槽位当前的武器编号
|
||||||
*
|
*
|
||||||
* @param index 武器槽位
|
* @param index 武器槽位
|
||||||
* @param type 武器类型
|
* @param type 武器类型
|
||||||
*/
|
*/
|
||||||
default void setWeaponType(int index, int type) {
|
default void setWeaponIndex(int index, int type) {
|
||||||
if (!(this instanceof VehicleEntity vehicle)) return;
|
if (!(this instanceof VehicleEntity vehicle)) return;
|
||||||
|
|
||||||
var selectedWeapons = vehicle.getEntityData().get(VehicleEntity.SELECTED_WEAPON).toIntArray();
|
var selectedWeapons = vehicle.getEntityData().get(VehicleEntity.SELECTED_WEAPON).toIntArray();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.atsuishio.superbwarfare.entity.vehicle.weapon;
|
package com.atsuishio.superbwarfare.entity.vehicle.weapon;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
|
@ -8,7 +9,7 @@ import net.minecraft.world.item.Item;
|
||||||
public abstract class VehicleWeapon {
|
public abstract class VehicleWeapon {
|
||||||
|
|
||||||
// 武器的图标
|
// 武器的图标
|
||||||
public ResourceLocation icon;
|
public ResourceLocation icon = ModUtils.loc("textures/screens/vehicle_weapon/empty.png");
|
||||||
// 武器的名称
|
// 武器的名称
|
||||||
public Component name;
|
public Component name;
|
||||||
// 武器使用的弹药类型
|
// 武器使用的弹药类型
|
||||||
|
|
|
@ -740,33 +740,33 @@ public class ClientEventHandler {
|
||||||
|
|
||||||
if (iVehicle instanceof Ah6Entity ah6Entity) {
|
if (iVehicle instanceof Ah6Entity ah6Entity) {
|
||||||
float pitch = ah6Entity.heat <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - ah6Entity.heat));
|
float pitch = ah6Entity.heat <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - ah6Entity.heat));
|
||||||
if (ah6Entity.getWeaponType(0) == 0) {
|
if (ah6Entity.getWeaponIndex(0) == 0) {
|
||||||
ah6Entity.heat += 5;
|
ah6Entity.heat += 5;
|
||||||
player.playSound(ModSounds.HELICOPTER_CANNON_FIRE_1P.get(), 1f, pitch);
|
player.playSound(ModSounds.HELICOPTER_CANNON_FIRE_1P.get(), 1f, pitch);
|
||||||
} else if (ah6Entity.getWeaponType(0) == 1) {
|
} else if (ah6Entity.getWeaponIndex(0) == 1) {
|
||||||
player.playSound(ModSounds.HELICOPTER_ROCKET_FIRE_1P.get(), 1f, 1);
|
player.playSound(ModSounds.HELICOPTER_ROCKET_FIRE_1P.get(), 1f, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (iVehicle instanceof Lav150Entity lav150) {
|
if (iVehicle instanceof Lav150Entity lav150) {
|
||||||
if (lav150.getWeaponType(0) == 0) {
|
if (lav150.getWeaponIndex(0) == 0) {
|
||||||
float pitch = lav150.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - lav150.getEntityData().get(HEAT)));
|
float pitch = lav150.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - lav150.getEntityData().get(HEAT)));
|
||||||
player.playSound(ModSounds.LAV_CANNON_FIRE_1P.get(), 1f, pitch);
|
player.playSound(ModSounds.LAV_CANNON_FIRE_1P.get(), 1f, pitch);
|
||||||
player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1);
|
player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1);
|
||||||
} else if (lav150.getWeaponType(0) == 1) {
|
} else if (lav150.getWeaponIndex(0) == 1) {
|
||||||
float pitch = lav150.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - lav150.getEntityData().get(COAX_HEAT)));
|
float pitch = lav150.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - lav150.getEntityData().get(COAX_HEAT)));
|
||||||
player.playSound(ModSounds.COAX_FIRE_1P.get(), 1f, pitch);
|
player.playSound(ModSounds.COAX_FIRE_1P.get(), 1f, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (iVehicle instanceof Bmp2Entity bmp2) {
|
if (iVehicle instanceof Bmp2Entity bmp2) {
|
||||||
if (bmp2.getWeaponType(0) == 0) {
|
if (bmp2.getWeaponIndex(0) == 0) {
|
||||||
float pitch = bmp2.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - bmp2.getEntityData().get(HEAT)));
|
float pitch = bmp2.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - bmp2.getEntityData().get(HEAT)));
|
||||||
player.playSound(ModSounds.BMP_CANNON_FIRE_1P.get(), 1f, pitch);
|
player.playSound(ModSounds.BMP_CANNON_FIRE_1P.get(), 1f, pitch);
|
||||||
player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1);
|
player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1);
|
||||||
} else if (bmp2.getWeaponType(0) == 1) {
|
} else if (bmp2.getWeaponIndex(0) == 1) {
|
||||||
float pitch = bmp2.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - bmp2.getEntityData().get(COAX_HEAT)));
|
float pitch = bmp2.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - bmp2.getEntityData().get(COAX_HEAT)));
|
||||||
player.playSound(ModSounds.COAX_FIRE_1P.get(), 1f, pitch);
|
player.playSound(ModSounds.COAX_FIRE_1P.get(), 1f, pitch);
|
||||||
} else if (bmp2.getWeaponType(0) == 2) {
|
} else if (bmp2.getWeaponIndex(0) == 2) {
|
||||||
player.playSound(ModSounds.BMP_MISSILE_FIRE_1P.get(), 1f, 1);
|
player.playSound(ModSounds.BMP_MISSILE_FIRE_1P.get(), 1f, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class MinecraftMixin {
|
||||||
// 数字键 武器切换
|
// 数字键 武器切换
|
||||||
if (!Screen.hasShiftDown()
|
if (!Screen.hasShiftDown()
|
||||||
&& weaponVehicle.hasWeapon(seatIndex)
|
&& weaponVehicle.hasWeapon(seatIndex)
|
||||||
&& weaponVehicle.getWeaponType(seatIndex) != index) {
|
&& weaponVehicle.getWeaponIndex(seatIndex) != index) {
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new SwitchVehicleWeaponMessage(seatIndex, index, false));
|
ModUtils.PACKET_HANDLER.sendToServer(new SwitchVehicleWeaponMessage(seatIndex, index, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue