将蜂群无人机给3号位,三号位潜行时能使用自己的武器
This commit is contained in:
parent
42c242dfe8
commit
d889c2ddc1
7 changed files with 245 additions and 126 deletions
|
@ -151,6 +151,7 @@ public class ClickHandler {
|
||||||
&& player.getVehicle() instanceof VehicleEntity vehicle
|
&& player.getVehicle() instanceof VehicleEntity vehicle
|
||||||
&& vehicle instanceof WeaponVehicleEntity weaponVehicle
|
&& vehicle instanceof WeaponVehicleEntity weaponVehicle
|
||||||
&& weaponVehicle.hasWeapon(vehicle.getSeatIndex(player))
|
&& weaponVehicle.hasWeapon(vehicle.getSeatIndex(player))
|
||||||
|
&& weaponVehicle.banHand(player)
|
||||||
) {
|
) {
|
||||||
int index = vehicle.getSeatIndex(player);
|
int index = vehicle.getSeatIndex(player);
|
||||||
PacketDistributor.sendToServer(new SwitchVehicleWeaponMessage(index, -scroll, true));
|
PacketDistributor.sendToServer(new SwitchVehicleWeaponMessage(index, -scroll, true));
|
||||||
|
@ -361,7 +362,7 @@ public class ClickHandler {
|
||||||
public static void handleWeaponZoomPress(Player player, ItemStack stack) {
|
public static void handleWeaponZoomPress(Player player, ItemStack stack) {
|
||||||
PacketDistributor.sendToServer(new ZoomMessage(0));
|
PacketDistributor.sendToServer(new ZoomMessage(0));
|
||||||
|
|
||||||
if (player.getVehicle() instanceof VehicleEntity pVehicle && player.getVehicle() instanceof WeaponVehicleEntity iVehicle && iVehicle.hasWeapon(pVehicle.getSeatIndex(player))) {
|
if (player.getVehicle() instanceof VehicleEntity pVehicle && player.getVehicle() instanceof WeaponVehicleEntity iVehicle && iVehicle.hasWeapon(pVehicle.getSeatIndex(player)) && iVehicle.banHand(player)) {
|
||||||
ClientEventHandler.zoomVehicle = true;
|
ClientEventHandler.zoomVehicle = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.atsuishio.superbwarfare.entity.vehicle.*;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.*;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.*;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.HeliRocketWeapon;
|
import com.atsuishio.superbwarfare.entity.vehicle.weapon.HeliRocketWeapon;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.LaserWeapon;
|
import com.atsuishio.superbwarfare.entity.vehicle.weapon.LaserWeapon;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.weapon.SwarmDroneWeapon;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||||
|
@ -48,7 +49,6 @@ import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||||
import static com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay.*;
|
import static com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay.*;
|
||||||
import static com.atsuishio.superbwarfare.entity.vehicle.Bmp2Entity.LOADED_MISSILE;
|
import static com.atsuishio.superbwarfare.entity.vehicle.Bmp2Entity.LOADED_MISSILE;
|
||||||
import static com.atsuishio.superbwarfare.entity.vehicle.Bmp2Entity.MISSILE_COUNT;
|
import static com.atsuishio.superbwarfare.entity.vehicle.Bmp2Entity.MISSILE_COUNT;
|
||||||
import static com.atsuishio.superbwarfare.entity.vehicle.Yx100Entity.LOADED_DRONE;
|
|
||||||
import static com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity.*;
|
import static com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity.*;
|
||||||
|
|
||||||
@EventBusSubscriber(value = Dist.CLIENT)
|
@EventBusSubscriber(value = Dist.CLIENT)
|
||||||
|
@ -291,8 +291,6 @@ public class VehicleHudOverlay {
|
||||||
} else if (weaponVehicle.getWeaponIndex(0) == 2) {
|
} else if (weaponVehicle.getWeaponIndex(0) == 2) {
|
||||||
double heat = 1 - yx100.getEntityData().get(COAX_HEAT) / 100.0F;
|
double heat = 1 - yx100.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||||
guiGraphics.drawString(mc.font, Component.literal(" 12.7MM HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
guiGraphics.drawString(mc.font, Component.literal(" 12.7MM HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||||
} else {
|
|
||||||
guiGraphics.drawString(mc.font, Component.literal(" SWARM " + yx100.getEntityData().get(LOADED_DRONE) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), w / 2 - 33, h - 65, 0x66FF00, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,8 +347,6 @@ public class VehicleHudOverlay {
|
||||||
} else if (weaponVehicle.getWeaponIndex(0) == 2) {
|
} else if (weaponVehicle.getWeaponIndex(0) == 2) {
|
||||||
double heat2 = yx100.getEntityData().get(COAX_HEAT) / 100.0F;
|
double heat2 = yx100.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("12.7MM HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat2, 1.0F), false);
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("12.7MM HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat2, 1.0F), false);
|
||||||
} else {
|
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("SWARM " + yx100.getEntityData().get(LOADED_DRONE) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), 30, -9, -1, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,7 +539,7 @@ public class VehicleHudOverlay {
|
||||||
);
|
);
|
||||||
|
|
||||||
preciseBlit(guiGraphics, SELECTED, w - 95, startY, 100, 0, 0, 8, 8, 8, 8);
|
preciseBlit(guiGraphics, SELECTED, w - 95, startY, 100, 0, 0, 8, 8, 8, 8);
|
||||||
if (InventoryTool.hasCreativeAmmoBox(player) && !(weapon instanceof LaserWeapon) && !(weapon instanceof HeliRocketWeapon)) {
|
if (InventoryTool.hasCreativeAmmoBox(player) && !(weapon instanceof LaserWeapon) && !(weapon instanceof HeliRocketWeapon) && !(weapon instanceof SwarmDroneWeapon)) {
|
||||||
preciseBlit(guiGraphics, NUMBER, w - 28 + xOffset, h - frameIndex * 18 - 15, 100, 58, 0, 10, 7.5f, 75, 7.5f);
|
preciseBlit(guiGraphics, NUMBER, w - 28 + xOffset, h - frameIndex * 18 - 15, 100, 58, 0, 10, 7.5f, 75, 7.5f);
|
||||||
} else {
|
} else {
|
||||||
renderNumber(guiGraphics, weaponVehicle.getAmmoCount(player), weapon instanceof LaserWeapon,
|
renderNumber(guiGraphics, weaponVehicle.getAmmoCount(player), weapon instanceof LaserWeapon,
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
package com.atsuishio.superbwarfare.client.overlay;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
|
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.Yx100Entity;
|
||||||
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
|
import com.atsuishio.superbwarfare.tools.SeekTool;
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
import net.minecraft.client.CameraType;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
|
import net.neoforged.neoforge.client.event.RenderGuiEvent;
|
||||||
|
import org.joml.Math;
|
||||||
|
|
||||||
|
@EventBusSubscriber(modid = Mod.MODID, value = Dist.CLIENT)
|
||||||
|
public class Yx100SwarmDroneHudOverlay {
|
||||||
|
private static final ResourceLocation FRAME = Mod.loc("textures/screens/frame/frame.png");
|
||||||
|
private static final ResourceLocation FRAME_LOCK = Mod.loc("textures/screens/frame/frame_lock.png");
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void eventHandler(RenderGuiEvent.Pre event) {
|
||||||
|
int w = event.getGuiGraphics().guiWidth();
|
||||||
|
int h = event.getGuiGraphics().guiHeight();
|
||||||
|
Minecraft mc = Minecraft.getInstance();
|
||||||
|
Player player = mc.player;
|
||||||
|
GuiGraphics guiGraphics = event.getGuiGraphics();
|
||||||
|
PoseStack poseStack = guiGraphics.pose();
|
||||||
|
|
||||||
|
if (!shouldRenderCrossHair(player)) return;
|
||||||
|
|
||||||
|
Entity cannon = player.getVehicle();
|
||||||
|
if (cannon == null) return;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (player.getVehicle() instanceof Yx100Entity yx100 && yx100.banHand(player)) {
|
||||||
|
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||||
|
float fovAdjust = (float) 70 / Minecraft.getInstance().options.fov().get();
|
||||||
|
|
||||||
|
float f = (float) Math.min(w, h);
|
||||||
|
float f1 = Math.min((float) w / f, (float) h / f) * fovAdjust;
|
||||||
|
int i = Mth.floor(f * f1);
|
||||||
|
int j = Mth.floor(f * f1);
|
||||||
|
int k = (w - i) / 2;
|
||||||
|
int l = (h - j) / 2;
|
||||||
|
RenderHelper.preciseBlit(guiGraphics, Mod.loc("textures/screens/land/lav_missile_cross.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||||
|
VehicleHudOverlay.renderKillIndicator(guiGraphics, w, h);
|
||||||
|
Entity naerestEntity = SeekTool.seekLivingEntity(player, player.level(), 384, 6);
|
||||||
|
|
||||||
|
float fovAdjust2 = (float) (Minecraft.getInstance().options.fov().get() / 30) - 1;
|
||||||
|
|
||||||
|
double zoom = 1;
|
||||||
|
|
||||||
|
if (ClientEventHandler.zoomVehicle) {
|
||||||
|
zoom = Minecraft.getInstance().options.fov().get() / ClientEventHandler.fov + 0.05 * fovAdjust2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (naerestEntity != null) {
|
||||||
|
Vec3 playerVec = new Vec3(Mth.lerp(event.getPartialTick().getRealtimeDeltaTicks(), player.xo, player.getX()), Mth.lerp(event.getPartialTick().getRealtimeDeltaTicks(), player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(event.getPartialTick().getRealtimeDeltaTicks(), player.zo, player.getZ()));
|
||||||
|
Vec3 pos = new Vec3(Mth.lerp(event.getPartialTick().getRealtimeDeltaTicks(), naerestEntity.xo, naerestEntity.getX()), Mth.lerp(event.getPartialTick().getRealtimeDeltaTicks(), naerestEntity.yo + naerestEntity.getEyeHeight(), naerestEntity.getEyeY()), Mth.lerp(event.getPartialTick().getRealtimeDeltaTicks(), naerestEntity.zo, naerestEntity.getZ()));
|
||||||
|
Vec3 lookAngle = player.getLookAngle().normalize().scale(pos.distanceTo(playerVec) * (1 - 1.0 / zoom));
|
||||||
|
|
||||||
|
var cPos = playerVec.add(lookAngle);
|
||||||
|
Vec3 point = RenderHelper.worldToScreen(pos, cPos);
|
||||||
|
if (point == null) return;
|
||||||
|
|
||||||
|
poseStack.pushPose();
|
||||||
|
float x = (float) point.x;
|
||||||
|
float y = (float) point.y;
|
||||||
|
|
||||||
|
RenderHelper.preciseBlit(guiGraphics, FRAME_LOCK, x - 12, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||||
|
poseStack.popPose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean shouldRenderCrossHair(Player player) {
|
||||||
|
if (player == null) return false;
|
||||||
|
return !player.isSpectator()
|
||||||
|
&& player.getVehicle() instanceof Yx100Entity yx100 && yx100.getNthEntity(2) == player;
|
||||||
|
}
|
||||||
|
}
|
|
@ -120,11 +120,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
.ammo(ModItems.HEAVY_AMMO.get())
|
.ammo(ModItems.HEAVY_AMMO.get())
|
||||||
.sound(ModSounds.INTO_CANNON.get())
|
.sound(ModSounds.INTO_CANNON.get())
|
||||||
.icon(Mod.loc("textures/screens/vehicle_weapon/gun_12_7mm.png")),
|
.icon(Mod.loc("textures/screens/vehicle_weapon/gun_12_7mm.png")),
|
||||||
// 蜂群无人机
|
|
||||||
new SwarmDroneWeapon()
|
|
||||||
.explosionDamage(125)
|
|
||||||
.explosionRadius(6)
|
|
||||||
.sound(ModSounds.INTO_MISSILE.get()),
|
|
||||||
},
|
},
|
||||||
new VehicleWeapon[]{
|
new VehicleWeapon[]{
|
||||||
// 机枪
|
// 机枪
|
||||||
|
@ -135,6 +130,13 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
.bypassArmorRate(0.4f)
|
.bypassArmorRate(0.4f)
|
||||||
.ammo(ModItems.HEAVY_AMMO.get())
|
.ammo(ModItems.HEAVY_AMMO.get())
|
||||||
.icon(Mod.loc("textures/screens/vehicle_weapon/gun_12_7mm.png")),
|
.icon(Mod.loc("textures/screens/vehicle_weapon/gun_12_7mm.png")),
|
||||||
|
},
|
||||||
|
new VehicleWeapon[]{
|
||||||
|
// 蜂群无人机
|
||||||
|
new SwarmDroneWeapon()
|
||||||
|
.explosionDamage(125)
|
||||||
|
.explosionRadius(6)
|
||||||
|
.sound(ModSounds.INTO_MISSILE.get()),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -168,6 +170,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
compound.putInt("LoadedAmmoType", this.entityData.get(LOADED_AMMO_TYPE));
|
compound.putInt("LoadedAmmoType", this.entityData.get(LOADED_AMMO_TYPE));
|
||||||
compound.putInt("WeaponType", getWeaponIndex(0));
|
compound.putInt("WeaponType", getWeaponIndex(0));
|
||||||
compound.putInt("PassengerWeaponType", getWeaponIndex(1));
|
compound.putInt("PassengerWeaponType", getWeaponIndex(1));
|
||||||
|
compound.putInt("ThirdPassengerWeaponType", getWeaponIndex(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -179,6 +182,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
this.entityData.set(LOADED_AMMO_TYPE, compound.getInt("LoadedAmmoType"));
|
this.entityData.set(LOADED_AMMO_TYPE, compound.getInt("LoadedAmmoType"));
|
||||||
setWeaponIndex(0, compound.getInt("WeaponType"));
|
setWeaponIndex(0, compound.getInt("WeaponType"));
|
||||||
setWeaponIndex(1, compound.getInt("PassengerWeaponType"));
|
setWeaponIndex(1, compound.getInt("PassengerWeaponType"));
|
||||||
|
setWeaponIndex(2, compound.getInt("ThirdPassengerWeaponType"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -257,9 +261,10 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
boolean hasCreativeAmmo = false;
|
boolean hasCreativeAmmo = false;
|
||||||
|
for (int i = 0; i < getMaxPassengers(); i++) {
|
||||||
if (this.getFirstPassenger() instanceof Player player) {
|
if (getNthEntity(i) instanceof Player pPlayer && InventoryTool.hasCreativeAmmoBox(pPlayer)) {
|
||||||
hasCreativeAmmo = InventoryTool.hasCreativeAmmoBox(player);
|
hasCreativeAmmo = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reloadCoolDown > 0 && (
|
if (reloadCoolDown > 0 && (
|
||||||
|
@ -273,6 +278,15 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
droneReloadCoolDown--;
|
droneReloadCoolDown--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((hasItem(ModItems.SWARM_DRONE.get()) || hasCreativeAmmo) && droneReloadCoolDown == 0 && this.getEntityData().get(LOADED_DRONE) < 14) {
|
||||||
|
this.entityData.set(LOADED_DRONE, this.getEntityData().get(LOADED_DRONE) + 1);
|
||||||
|
droneReloadCoolDown = 20;
|
||||||
|
if (!hasCreativeAmmo) {
|
||||||
|
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SWARM_DRONE.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
||||||
|
}
|
||||||
|
this.level().playSound(null, this, ModSounds.MISSILE_RELOAD.get(), this.getSoundSource(), 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
this.handleAmmo();
|
this.handleAmmo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,9 +339,10 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasCreativeAmmo = false;
|
boolean hasCreativeAmmo = false;
|
||||||
|
for (int i = 0; i < getMaxPassengers(); i++) {
|
||||||
if (this.getFirstPassenger() instanceof Player player) {
|
if (getNthEntity(i) instanceof Player pPlayer && InventoryTool.hasCreativeAmmoBox(pPlayer)) {
|
||||||
hasCreativeAmmo = InventoryTool.hasCreativeAmmoBox(player);
|
hasCreativeAmmo = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasCreativeAmmo) {
|
if (hasCreativeAmmo) {
|
||||||
|
@ -357,15 +372,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hasItem(ModItems.SWARM_DRONE.get()) || hasCreativeAmmo) && droneReloadCoolDown == 0 && this.getEntityData().get(LOADED_DRONE) < 14) {
|
|
||||||
this.entityData.set(LOADED_DRONE, this.getEntityData().get(LOADED_DRONE) + 1);
|
|
||||||
droneReloadCoolDown = 20;
|
|
||||||
if (!hasCreativeAmmo) {
|
|
||||||
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SWARM_DRONE.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
|
||||||
}
|
|
||||||
this.level().playSound(null, this, ModSounds.MISSILE_RELOAD.get(), this.getSoundSource(), 1, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -514,89 +520,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
serverPlayer.playSound(ModSounds.M_2_VERYFAR.get(), 24, pitch);
|
serverPlayer.playSound(ModSounds.M_2_VERYFAR.get(), 24, pitch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (getWeaponIndex(0) == 3) {
|
|
||||||
Matrix4f transformT = getTurretTransform(1);
|
|
||||||
Vector4f worldPosition = new Vector4f();
|
|
||||||
|
|
||||||
int ammo = this.getEntityData().get(LOADED_DRONE);
|
|
||||||
|
|
||||||
if (ammo == 1) {
|
|
||||||
worldPosition = transformPosition(transformT, -2.315275f, 0.71894375f, -0.25390625f);
|
|
||||||
}
|
|
||||||
if (ammo == 2) {
|
|
||||||
worldPosition = transformPosition(transformT, 2.315275f, 0.71894375f, -0.25390625f);
|
|
||||||
}
|
|
||||||
if (ammo == 3) {
|
|
||||||
worldPosition = transformPosition(transformT, -2.49105625f, 0.71894375f, -0.4296875f);
|
|
||||||
}
|
|
||||||
if (ammo == 4) {
|
|
||||||
worldPosition = transformPosition(transformT, 2.49105625f, 0.71894375f, -0.4296875f);
|
|
||||||
}
|
|
||||||
if (ammo == 5) {
|
|
||||||
worldPosition = transformPosition(transformT, -2.315275f, 0.71894375f, -0.60546875f);
|
|
||||||
}
|
|
||||||
if (ammo == 6) {
|
|
||||||
worldPosition = transformPosition(transformT, 2.315275f, 0.71894375f, -0.60546875f);
|
|
||||||
}
|
|
||||||
if (ammo == 7) {
|
|
||||||
worldPosition = transformPosition(transformT, -2.49105625f, 0.71894375f, -0.78125f);
|
|
||||||
}
|
|
||||||
if (ammo == 8) {
|
|
||||||
worldPosition = transformPosition(transformT, 2.49105625f, 0.71894375f, -0.78125f);
|
|
||||||
}
|
|
||||||
if (ammo == 9) {
|
|
||||||
worldPosition = transformPosition(transformT, -2.315275f, 0.71894375f, -0.95703125f);
|
|
||||||
}
|
|
||||||
if (ammo == 10) {
|
|
||||||
worldPosition = transformPosition(transformT, 2.315275f, 0.71894375f, -0.95703125f);
|
|
||||||
}
|
|
||||||
if (ammo == 11) {
|
|
||||||
worldPosition = transformPosition(transformT, -2.49105625f, 0.71894375f, -1.1328125f);
|
|
||||||
}
|
|
||||||
if (ammo == 12) {
|
|
||||||
worldPosition = transformPosition(transformT, 2.49105625f, 0.71894375f, -1.1328125f);
|
|
||||||
}
|
|
||||||
if (ammo == 13) {
|
|
||||||
worldPosition = transformPosition(transformT, -2.315275f, 0.71894375f, -1.30859375f);
|
|
||||||
}
|
|
||||||
if (ammo == 14) {
|
|
||||||
worldPosition = transformPosition(transformT, 2.315275f, 0.71894375f, -1.30859375f);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec3 lookVec = getBarrelVec(1).normalize();
|
|
||||||
Entity lookingEntity = SeekTool.vehicleSeekEntity(this, level(), 512, 4);
|
|
||||||
|
|
||||||
var swarmDroneEntity = ((SwarmDroneWeapon) getWeapon(0)).create(player);
|
|
||||||
|
|
||||||
|
|
||||||
Vector4f shootPosition1 = transformPosition(transformT, 0, 0, 0);
|
|
||||||
Vector4f shootPosition2 = transformPosition(transformT, 0, 1, 0);
|
|
||||||
Vec3 direct = new Vec3(shootPosition1.x, shootPosition1.y, shootPosition1.z).vectorTo(new Vec3(shootPosition2.x, shootPosition2.y, shootPosition2.z));
|
|
||||||
|
|
||||||
|
|
||||||
swarmDroneEntity.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
|
||||||
swarmDroneEntity.shoot(direct.x, direct.y, direct.z, 1.2f, 10);
|
|
||||||
|
|
||||||
if (lookingEntity != null) {
|
|
||||||
swarmDroneEntity.setGuideType(0);
|
|
||||||
swarmDroneEntity.setTargetUuid(lookingEntity.getStringUUID());
|
|
||||||
swarmDroneEntity.setTargetVec(lookingEntity.getEyePosition());
|
|
||||||
} else {
|
|
||||||
swarmDroneEntity.setGuideType(1);
|
|
||||||
BlockHitResult result = level().clip(new ClipContext(getNewEyePos(1), getNewEyePos(1).add(lookVec.scale(512)),
|
|
||||||
ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this));
|
|
||||||
Vec3 hitPos = result.getLocation();
|
|
||||||
swarmDroneEntity.setTargetVec(hitPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
player.level().addFreshEntity(swarmDroneEntity);
|
|
||||||
|
|
||||||
this.level().playSound(null, BlockPos.containing(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z)), ModSounds.DECOY_FIRE.get(), SoundSource.PLAYERS, 1, random.nextFloat() * 0.05f + 1);
|
|
||||||
|
|
||||||
this.entityData.set(LOADED_DRONE, this.getEntityData().get(LOADED_DRONE) - 1);
|
|
||||||
droneReloadCoolDown = 100;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
|
@ -608,7 +532,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
var projectileEntity = projectile.create(player).setGunItemId(this.getType().getDescriptionId() + ".2");
|
var projectileEntity = projectile.create(player).setGunItemId(this.getType().getDescriptionId() + ".2");
|
||||||
|
|
||||||
projectileEntity.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z);
|
projectileEntity.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z);
|
||||||
projectileEntity.shoot(getGunnerVector(1).x, getGunnerVector(1).y + 0.005f, getGunnerVector(1).z, 20, 0.3f);
|
projectileEntity.shoot(getGunnerVector(1).x, getGunnerVector(1).y + 0.01f, getGunnerVector(1).z, 20, 0.3f);
|
||||||
|
|
||||||
this.level().addFreshEntity(projectileEntity);
|
this.level().addFreshEntity(projectileEntity);
|
||||||
|
|
||||||
|
@ -649,6 +573,90 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
consumeItem(getWeapon(1).ammo, 1);
|
consumeItem(getWeapon(1).ammo, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == 2) {
|
||||||
|
Matrix4f transformT = getTurretTransform(1);
|
||||||
|
Vector4f worldPosition = new Vector4f();
|
||||||
|
|
||||||
|
int ammo = this.getEntityData().get(LOADED_DRONE);
|
||||||
|
|
||||||
|
if (ammo == 1) {
|
||||||
|
worldPosition = transformPosition(transformT, -2.315275f, 0.71894375f, -0.25390625f);
|
||||||
|
}
|
||||||
|
if (ammo == 2) {
|
||||||
|
worldPosition = transformPosition(transformT, 2.315275f, 0.71894375f, -0.25390625f);
|
||||||
|
}
|
||||||
|
if (ammo == 3) {
|
||||||
|
worldPosition = transformPosition(transformT, -2.49105625f, 0.71894375f, -0.4296875f);
|
||||||
|
}
|
||||||
|
if (ammo == 4) {
|
||||||
|
worldPosition = transformPosition(transformT, 2.49105625f, 0.71894375f, -0.4296875f);
|
||||||
|
}
|
||||||
|
if (ammo == 5) {
|
||||||
|
worldPosition = transformPosition(transformT, -2.315275f, 0.71894375f, -0.60546875f);
|
||||||
|
}
|
||||||
|
if (ammo == 6) {
|
||||||
|
worldPosition = transformPosition(transformT, 2.315275f, 0.71894375f, -0.60546875f);
|
||||||
|
}
|
||||||
|
if (ammo == 7) {
|
||||||
|
worldPosition = transformPosition(transformT, -2.49105625f, 0.71894375f, -0.78125f);
|
||||||
|
}
|
||||||
|
if (ammo == 8) {
|
||||||
|
worldPosition = transformPosition(transformT, 2.49105625f, 0.71894375f, -0.78125f);
|
||||||
|
}
|
||||||
|
if (ammo == 9) {
|
||||||
|
worldPosition = transformPosition(transformT, -2.315275f, 0.71894375f, -0.95703125f);
|
||||||
|
}
|
||||||
|
if (ammo == 10) {
|
||||||
|
worldPosition = transformPosition(transformT, 2.315275f, 0.71894375f, -0.95703125f);
|
||||||
|
}
|
||||||
|
if (ammo == 11) {
|
||||||
|
worldPosition = transformPosition(transformT, -2.49105625f, 0.71894375f, -1.1328125f);
|
||||||
|
}
|
||||||
|
if (ammo == 12) {
|
||||||
|
worldPosition = transformPosition(transformT, 2.49105625f, 0.71894375f, -1.1328125f);
|
||||||
|
}
|
||||||
|
if (ammo == 13) {
|
||||||
|
worldPosition = transformPosition(transformT, -2.315275f, 0.71894375f, -1.30859375f);
|
||||||
|
}
|
||||||
|
if (ammo == 14) {
|
||||||
|
worldPosition = transformPosition(transformT, 2.315275f, 0.71894375f, -1.30859375f);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3 lookVec = player.getViewVector(1);
|
||||||
|
Entity lookingEntity = SeekTool.seekLivingEntity(player, level(), 384, 6);
|
||||||
|
|
||||||
|
var swarmDroneEntity = ((SwarmDroneWeapon) getWeapon(2)).create(player);
|
||||||
|
|
||||||
|
|
||||||
|
Vector4f shootPosition1 = transformPosition(transformT, 0, 0, 0);
|
||||||
|
Vector4f shootPosition2 = transformPosition(transformT, 0, 1, 0);
|
||||||
|
Vec3 direct = new Vec3(shootPosition1.x, shootPosition1.y, shootPosition1.z).vectorTo(new Vec3(shootPosition2.x, shootPosition2.y, shootPosition2.z));
|
||||||
|
|
||||||
|
|
||||||
|
swarmDroneEntity.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||||
|
swarmDroneEntity.shoot(direct.x, direct.y, direct.z, 1.2f, 10);
|
||||||
|
|
||||||
|
if (lookingEntity != null) {
|
||||||
|
swarmDroneEntity.setGuideType(0);
|
||||||
|
swarmDroneEntity.setTargetUuid(lookingEntity.getStringUUID());
|
||||||
|
swarmDroneEntity.setTargetVec(lookingEntity.getEyePosition());
|
||||||
|
} else {
|
||||||
|
swarmDroneEntity.setGuideType(1);
|
||||||
|
BlockHitResult result = level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(lookVec.scale(384)),
|
||||||
|
ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this));
|
||||||
|
Vec3 hitPos = result.getLocation();
|
||||||
|
swarmDroneEntity.setTargetVec(hitPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.level().addFreshEntity(swarmDroneEntity);
|
||||||
|
|
||||||
|
this.level().playSound(null, BlockPos.containing(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z)), ModSounds.DECOY_FIRE.get(), SoundSource.PLAYERS, 1, random.nextFloat() * 0.05f + 1);
|
||||||
|
|
||||||
|
this.entityData.set(LOADED_DRONE, this.getEntityData().get(LOADED_DRONE) - 1);
|
||||||
|
droneReloadCoolDown = 100;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1028,14 +1036,17 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
return 15;
|
return 15;
|
||||||
} else if (getWeaponIndex(0) == 2) {
|
} else if (getWeaponIndex(0) == 2) {
|
||||||
return 500;
|
return 500;
|
||||||
} else if (getWeaponIndex(0) == 3) {
|
|
||||||
return 600;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player == getNthEntity(1)) {
|
if (player == getNthEntity(1)) {
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player == getNthEntity(2)) {
|
||||||
|
return 600;
|
||||||
|
}
|
||||||
|
|
||||||
return 15;
|
return 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1048,14 +1059,16 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
return this.entityData.get(LOADED_HE) > 0 && getEnergy() > VehicleConfig.YX_100_SHOOT_COST.get();
|
return this.entityData.get(LOADED_HE) > 0 && getEnergy() > VehicleConfig.YX_100_SHOOT_COST.get();
|
||||||
} else if (getWeaponIndex(0) == 2) {
|
} else if (getWeaponIndex(0) == 2) {
|
||||||
return (this.entityData.get(MG_AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFireCoax;
|
return (this.entityData.get(MG_AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFireCoax;
|
||||||
} else if (getWeaponIndex(0) == 3) {
|
|
||||||
return this.entityData.get(LOADED_DRONE) > 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player == getNthEntity(1)) {
|
if (player == getNthEntity(1)) {
|
||||||
return (this.entityData.get(MG_AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFire;
|
return (this.entityData.get(MG_AMMO) > 0 || InventoryTool.hasCreativeAmmoBox(player)) && !cannotFire;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player == getNthEntity(2)) {
|
||||||
|
return this.entityData.get(LOADED_DRONE) > 0;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1068,20 +1081,25 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
return this.entityData.get(LOADED_HE);
|
return this.entityData.get(LOADED_HE);
|
||||||
} else if (getWeaponIndex(0) == 2) {
|
} else if (getWeaponIndex(0) == 2) {
|
||||||
return this.entityData.get(MG_AMMO);
|
return this.entityData.get(MG_AMMO);
|
||||||
} else if (getWeaponIndex(0) == 3) {
|
|
||||||
return this.entityData.get(LOADED_DRONE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player == getNthEntity(1)) {
|
if (player == getNthEntity(1)) {
|
||||||
return this.entityData.get(MG_AMMO);
|
return this.entityData.get(MG_AMMO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player == getNthEntity(2)) {
|
||||||
|
return this.entityData.get(LOADED_DRONE);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean banHand(Player player) {
|
public boolean banHand(Player player) {
|
||||||
return hidePassenger(player);
|
if (player == getNthEntity(0) || player == getNthEntity(1)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return player == getNthEntity(2) && !player.isShiftKeyDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -242,8 +242,8 @@ public class ClientEventHandler {
|
||||||
|
|
||||||
// 正在游戏内控制载具或无人机
|
// 正在游戏内控制载具或无人机
|
||||||
if (!notInGame() && (player.getVehicle() instanceof MobileVehicleEntity mobileVehicle
|
if (!notInGame() && (player.getVehicle() instanceof MobileVehicleEntity mobileVehicle
|
||||||
&& mobileVehicle.getFirstPassenger() == player
|
&& mobileVehicle.getFirstPassenger() == player)
|
||||||
|| stack.is(ModItems.MONITOR.get())
|
|| (stack.is(ModItems.MONITOR.get())
|
||||||
&& tag.getBoolean("Using")
|
&& tag.getBoolean("Using")
|
||||||
&& tag.getBoolean("Linked"))
|
&& tag.getBoolean("Linked"))
|
||||||
) {
|
) {
|
||||||
|
@ -796,7 +796,7 @@ public class ClientEventHandler {
|
||||||
float pitch = yx100.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - yx100.getEntityData().get(HEAT)));
|
float pitch = yx100.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - yx100.getEntityData().get(HEAT)));
|
||||||
player.playSound(ModSounds.M_2_FIRE_1P.get(), 1f, pitch);
|
player.playSound(ModSounds.M_2_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 {
|
} else if (type == 0) {
|
||||||
if (yx100.getWeaponIndex(0) == 0 || yx100.getWeaponIndex(0) == 1) {
|
if (yx100.getWeaponIndex(0) == 0 || yx100.getWeaponIndex(0) == 1) {
|
||||||
player.playSound(ModSounds.YX_100_FIRE_1P.get(), 1f, 1);
|
player.playSound(ModSounds.YX_100_FIRE_1P.get(), 1f, 1);
|
||||||
} else if (yx100.getWeaponIndex(0) == 2) {
|
} else if (yx100.getWeaponIndex(0) == 2) {
|
||||||
|
@ -1380,8 +1380,9 @@ public class ClientEventHandler {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
final var tag = NBTTool.getTag(stack);
|
final var tag = NBTTool.getTag(stack);
|
||||||
|
|
||||||
if (player.getVehicle() instanceof WeaponVehicleEntity iVehicle && zoomVehicle) {
|
if (player.getVehicle() instanceof WeaponVehicleEntity iVehicle && zoomVehicle && iVehicle.banHand(player)) {
|
||||||
event.setFOV(event.getFOV() / iVehicle.zoomFov());
|
event.setFOV(event.getFOV() / iVehicle.zoomFov());
|
||||||
|
fov = event.getFOV();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,7 @@ public record VehicleMovementMessage(short keys) implements CustomPacketPayload
|
||||||
final var tag = NBTTool.getTag(stack);
|
final var tag = NBTTool.getTag(stack);
|
||||||
|
|
||||||
VehicleEntity vehicle = null;
|
VehicleEntity vehicle = null;
|
||||||
if (entity instanceof MobileVehicleEntity mobileVehicleEntity) {
|
if (entity instanceof MobileVehicleEntity mobileVehicleEntity && mobileVehicleEntity.getFirstPassenger() == player) {
|
||||||
if (mobileVehicleEntity.getFirstPassenger() != player) return;
|
|
||||||
vehicle = mobileVehicleEntity;
|
vehicle = mobileVehicleEntity;
|
||||||
} else if (stack.is(ModItems.MONITOR.get())
|
} else if (stack.is(ModItems.MONITOR.get())
|
||||||
&& tag.getBoolean("Using")
|
&& tag.getBoolean("Using")
|
||||||
|
|
|
@ -44,7 +44,10 @@ public record ZoomMessage(int msgType) implements CustomPacketPayload {
|
||||||
&& vehicle instanceof WeaponVehicleEntity weaponEntity
|
&& vehicle instanceof WeaponVehicleEntity weaponEntity
|
||||||
&& vehicle instanceof VehicleEntity vehicleEntity
|
&& vehicle instanceof VehicleEntity vehicleEntity
|
||||||
&& weaponEntity.hasWeapon(vehicleEntity.getSeatIndex(player))
|
&& weaponEntity.hasWeapon(vehicleEntity.getSeatIndex(player))
|
||||||
) SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_IN.get(), 2, 1);
|
&& weaponEntity.banHand(player)
|
||||||
|
) {
|
||||||
|
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_IN.get(), 2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (message.msgType == 1) {
|
} else if (message.msgType == 1) {
|
||||||
cap.zoom = false;
|
cap.zoom = false;
|
||||||
|
@ -56,8 +59,10 @@ public record ZoomMessage(int msgType) implements CustomPacketPayload {
|
||||||
&& vehicle instanceof WeaponVehicleEntity weaponEntity
|
&& vehicle instanceof WeaponVehicleEntity weaponEntity
|
||||||
&& vehicle instanceof VehicleEntity vehicleEntity
|
&& vehicle instanceof VehicleEntity vehicleEntity
|
||||||
&& weaponEntity.hasWeapon(vehicleEntity.getSeatIndex(player))
|
&& weaponEntity.hasWeapon(vehicleEntity.getSeatIndex(player))
|
||||||
) SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_OUT.get(), 2, 1);
|
&& weaponEntity.banHand(player)
|
||||||
|
) {
|
||||||
|
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_OUT.get(), 2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (player.getMainHandItem().getItem() == ModItems.JAVELIN.get()) {
|
if (player.getMainHandItem().getItem() == ModItems.JAVELIN.get()) {
|
||||||
var handItem = player.getMainHandItem();
|
var handItem = player.getMainHandItem();
|
||||||
|
|
Loading…
Add table
Reference in a new issue