添加YX-100二号位的射击功能

This commit is contained in:
Atsuihsio 2025-03-05 20:46:31 +08:00
parent 1ec3d8c2be
commit d6cbba6f54
17 changed files with 413 additions and 190 deletions

View file

@ -119,7 +119,7 @@ public class ClickHandler {
if (stack.is(ModTags.Items.GUN) if (stack.is(ModTags.Items.GUN)
|| stack.is(ModItems.MONITOR.get()) || stack.is(ModItems.MONITOR.get())
|| stack.is(ModItems.LUNGE_MINE.get()) || stack.is(ModItems.LUNGE_MINE.get())
|| (player.getVehicle() instanceof ArmedVehicleEntity iVehicle && iVehicle.isDriver(player)) || (player.getVehicle() instanceof ArmedVehicleEntity)
|| (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get()))) { || (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get()))) {
if (button == ModKeyMappings.FIRE.getKey().getValue()) { if (button == ModKeyMappings.FIRE.getKey().getValue()) {
handleWeaponFirePress(player, stack); handleWeaponFirePress(player, stack);
@ -310,8 +310,8 @@ public class ClickHandler {
} }
if (player.getVehicle() instanceof ArmedVehicleEntity iVehicle && iVehicle.banHand(player)) { if (player.getVehicle() instanceof WeaponVehicleEntity iVehicle && iVehicle.banHand(player)) {
if (iVehicle.isDriver(player)) { if (player.getVehicle() instanceof VehicleEntity pVehicle && iVehicle.hasWeapon(pVehicle.getSeatIndex(player))) {
ClientEventHandler.holdFireVehicle = true; ClientEventHandler.holdFireVehicle = true;
} }
return; return;

View file

@ -65,6 +65,13 @@ public class Yx100Renderer extends GeoEntityRenderer<Yx100Entity> {
bone.setRotX(-Mth.lerp(partialTick, animatable.turretXRotO, animatable.getTurretXRot()) * Mth.DEG_TO_RAD); bone.setRotX(-Mth.lerp(partialTick, animatable.turretXRotO, animatable.getTurretXRot()) * Mth.DEG_TO_RAD);
} }
if (name.equals("jiqiang")) {
bone.setRotY(Mth.lerp(partialTick, animatable.gunYRotO, animatable.getGunYRot()) * Mth.DEG_TO_RAD - (animatable.getNthEntity(1) == null ? 0 : Mth.lerp(partialTick, animatable.turretYRotO, animatable.getTurretYRot()) * Mth.DEG_TO_RAD));
}
if (name.equals("qiangguan")) {
bone.setRotX(-Mth.lerp(partialTick, animatable.gunXRotO, animatable.getGunXRot()) * Mth.DEG_TO_RAD);
}
if (name.equals("flare")) { if (name.equals("flare")) {
bone.setRotZ((float) (0.5 * (Math.random() - 0.5))); bone.setRotZ((float) (0.5 * (Math.random() - 0.5)));
} }

View file

@ -155,7 +155,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
propellerRotO = this.getPropellerRot(); propellerRotO = this.getPropellerRot();
super.baseTick(); super.baseTick();
setZRot(getRoll() * 0.99f); setZRot(getRoll() * (backInputDown ? 0.9f : 0.99f));
if (heat > 0) { if (heat > 0) {
heat--; heat--;
@ -352,14 +352,14 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
setDeltaMovement(getDeltaMovement().add(0.0f, Math.min(Math.sin((90 - this.getXRot()) * Mth.DEG_TO_RAD), Math.sin((90 + this.getRoll()) * Mth.DEG_TO_RAD)) * this.entityData.get(POWER), 0.0f)); setDeltaMovement(getDeltaMovement().add(0.0f, Math.min(Math.sin((90 - this.getXRot()) * Mth.DEG_TO_RAD), Math.sin((90 + this.getRoll()) * Mth.DEG_TO_RAD)) * this.entityData.get(POWER), 0.0f));
Vector3f direction = getRightDirection().mul(-Math.sin(this.getRoll() * Mth.DEG_TO_RAD) * this.entityData.get(PROPELLER_ROT)); Vector3f direction = getRightDirection().mul(-Math.sin(this.getRoll() * Mth.DEG_TO_RAD) * this.entityData.get(PROPELLER_ROT));
setDeltaMovement(getDeltaMovement().add(new Vec3(direction.x, direction.y, direction.z).scale(backInputDown ? 0.1 : 2.5))); setDeltaMovement(getDeltaMovement().add(new Vec3(direction.x, direction.y, direction.z).scale(3)));
// if (passenger instanceof Player player) { // if (passenger instanceof Player player) {
// player.displayClientMessage(Component.literal(this.getRoll() + ""), true); // player.displayClientMessage(Component.literal(this.getRoll() + ""), true);
// } // }
Vector3f directionZ = getForwardDirection().mul(-Math.cos((this.getXRot() + 90) * Mth.DEG_TO_RAD) * this.entityData.get(PROPELLER_ROT)); Vector3f directionZ = getForwardDirection().mul(-Math.cos((this.getXRot() + 90) * Mth.DEG_TO_RAD) * this.entityData.get(PROPELLER_ROT));
setDeltaMovement(getDeltaMovement().add(new Vec3(directionZ.x, directionZ.y, directionZ.z).scale(backInputDown ? 0.1 : 2))); setDeltaMovement(getDeltaMovement().add(new Vec3(directionZ.x, directionZ.y, directionZ.z).scale(3)));
if (this.entityData.get(POWER) > 0.04f) { if (this.entityData.get(POWER) > 0.04f) {
engineStartOver = true; engineStartOver = true;
@ -527,7 +527,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
} }
@Override @Override
public void vehicleShoot(Player player) { public void vehicleShoot(Player player, int type) {
boolean hasCreativeAmmo = player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())); boolean hasCreativeAmmo = player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()));
Matrix4f transform = getVehicleTransform(); Matrix4f transform = getVehicleTransform();
@ -700,7 +700,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
} }
@Override @Override
public int mainGunRpm() { public int mainGunRpm(Player player) {
return 360; return 360;
} }

View file

@ -126,7 +126,7 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
if (stack.is(ModItems.CROWBAR.get()) && !player.isCrouching()) { if (stack.is(ModItems.CROWBAR.get()) && !player.isCrouching()) {
if (this.entityData.get(COOL_DOWN) == 0) { if (this.entityData.get(COOL_DOWN) == 0) {
vehicleShoot(player); vehicleShoot(player, 0);
entityData.set(SHOOTER_UUID, player.getStringUUID()); entityData.set(SHOOTER_UUID, player.getStringUUID());
} }
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
@ -442,7 +442,7 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
} }
@Override @Override
public void vehicleShoot(Player player) { public void vehicleShoot(Player player, int type) {
if (this.entityData.get(COOL_DOWN) > 0) { if (this.entityData.get(COOL_DOWN) > 0) {
return; return;
} }
@ -588,7 +588,7 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
} }
@Override @Override
public int mainGunRpm() { public int mainGunRpm(Player player) {
return 0; return 0;
} }

View file

@ -308,7 +308,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
} }
@Override @Override
public void vehicleShoot(Player player) { public void vehicleShoot(Player player, int type) {
Matrix4f transform = getBarrelTransform(); Matrix4f transform = getBarrelTransform();
if (getWeaponType(0) == 0) { if (getWeaponType(0) == 0) {
if (this.cannotFire) return; if (this.cannotFire) return;
@ -716,7 +716,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
} }
@Override @Override
public int mainGunRpm() { public int mainGunRpm(Player player) {
if (getWeaponType(0) == 0) { if (getWeaponType(0) == 0) {
return 250; return 250;
} else if (getWeaponType(0) == 1) { } else if (getWeaponType(0) == 1) {

View file

@ -277,7 +277,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
} }
@Override @Override
public void vehicleShoot(Player player) { public void vehicleShoot(Player player, int type) {
boolean hasCreativeAmmo = player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())); boolean hasCreativeAmmo = player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()));
Matrix4f transform = getBarrelTransform(); Matrix4f transform = getBarrelTransform();
@ -662,7 +662,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
} }
@Override @Override
public int mainGunRpm() { public int mainGunRpm(Player player) {
if (getWeaponType(0) == 0) { if (getWeaponType(0) == 0) {
return 300; return 300;
} else if (getWeaponType(0) == 1) { } else if (getWeaponType(0) == 1) {

View file

@ -108,7 +108,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) {
vehicleShoot(player); vehicleShoot(player, 0);
} }
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
@ -253,7 +253,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
} }
@Override @Override
public void vehicleShoot(Player player) { public void vehicleShoot(Player player, int type) {
if (this.entityData.get(COOL_DOWN) > 0) { if (this.entityData.get(COOL_DOWN) > 0) {
return; return;
} }
@ -397,7 +397,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity
} }
@Override @Override
public int mainGunRpm() { public int mainGunRpm(Player player) {
return 0; return 0;
} }

View file

@ -113,7 +113,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) {
vehicleShoot(player); vehicleShoot(player, 0);
} }
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
@ -265,7 +265,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
} }
@Override @Override
public void vehicleShoot(Player player) { public void vehicleShoot(Player player, int type) {
if (this.entityData.get(COOL_DOWN) > 0) { if (this.entityData.get(COOL_DOWN) > 0) {
return; return;
} }
@ -491,7 +491,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt
} }
@Override @Override
public int mainGunRpm() { public int mainGunRpm(Player player) {
return 0; return 0;
} }

View file

@ -225,7 +225,7 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
* 机枪塔开火 * 机枪塔开火
*/ */
@Override @Override
public void vehicleShoot(Player player) { public void vehicleShoot(Player player, int type) {
if (this.cannotFire) return; if (this.cannotFire) return;
ProjectileEntity projectile = new ProjectileEntity(player.level()) ProjectileEntity projectile = new ProjectileEntity(player.level())
@ -497,7 +497,7 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
} }
@Override @Override
public int mainGunRpm() { public int mainGunRpm(Player player) {
return 500; return 500;
} }

View file

@ -4,16 +4,14 @@ import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig;
import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity; import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity;
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier;
import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.init.*;
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
import com.atsuishio.superbwarfare.tools.CustomExplosion; import com.atsuishio.superbwarfare.tools.*;
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
import com.atsuishio.superbwarfare.tools.ParticleTool;
import com.atsuishio.superbwarfare.tools.SoundTool;
import com.mojang.math.Axis; import com.mojang.math.Axis;
import net.minecraft.client.CameraType; import net.minecraft.client.CameraType;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -39,6 +37,7 @@ import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MoverType; import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@ -70,11 +69,15 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
public static final EntityDataAccessor<Integer> FIRE_ANIM = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor<Integer> FIRE_ANIM = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Float> DELTA_ROT = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor<Float> DELTA_ROT = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Integer> AMMO = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor<Integer> AMMO = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> MG_AMMO = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> LOADED_AMMO = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor<Integer> LOADED_AMMO = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> WEAPON_TYPE = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor<Integer> WEAPON_TYPE = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> PASSENGER_WEAPON_TYPE = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Float> TRACK_L = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor<Float> TRACK_L = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> TRACK_R = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor<Float> TRACK_R = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> YAW = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor<Float> YAW = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Integer> FIRE_TIME = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> MACHINE_GUN_HEAT = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
public static final float MAX_HEALTH = 500; public static final float MAX_HEALTH = 500;
public static final int MAX_ENERGY = 5000000; public static final int MAX_ENERGY = 5000000;
@ -84,6 +87,11 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
public float turretXRot; public float turretXRot;
public float turretYRotO; public float turretYRotO;
public float turretXRotO; public float turretXRotO;
public float gunYRot;
public float gunXRot;
public float gunYRotO;
public float gunXRotO;
public float leftWheelRot; public float leftWheelRot;
public float rightWheelRot; public float rightWheelRot;
public float leftWheelRotO; public float leftWheelRotO;
@ -93,6 +101,8 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
public double recoilShakeO; public double recoilShakeO;
public int reloadCoolDown; public int reloadCoolDown;
public boolean cannotFire;
public Yx100Entity(PlayMessages.SpawnEntity packet, Level world) { public Yx100Entity(PlayMessages.SpawnEntity packet, Level world) {
this(ModEntities.YX_100.get(), world); this(ModEntities.YX_100.get(), world);
} }
@ -106,13 +116,17 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
protected void defineSynchedData() { protected void defineSynchedData() {
super.defineSynchedData(); super.defineSynchedData();
this.entityData.define(AMMO, 0); this.entityData.define(AMMO, 0);
this.entityData.define(MG_AMMO, 0);
this.entityData.define(LOADED_AMMO, 0); this.entityData.define(LOADED_AMMO, 0);
this.entityData.define(FIRE_ANIM, 0); this.entityData.define(FIRE_ANIM, 0);
this.entityData.define(DELTA_ROT, 0f); this.entityData.define(DELTA_ROT, 0f);
this.entityData.define(WEAPON_TYPE, 0); this.entityData.define(WEAPON_TYPE, 0);
this.entityData.define(PASSENGER_WEAPON_TYPE, 0);
this.entityData.define(TRACK_L, 0f); this.entityData.define(TRACK_L, 0f);
this.entityData.define(TRACK_R, 0f); this.entityData.define(TRACK_R, 0f);
this.entityData.define(YAW, 0f); this.entityData.define(YAW, 0f);
this.entityData.define(FIRE_TIME, 0);
this.entityData.define(MACHINE_GUN_HEAT, 0);
} }
@Override @Override
@ -120,6 +134,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
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", getWeaponType(0));
compound.putInt("PassengerWeaponType", getWeaponType(1));
} }
@Override @Override
@ -127,6 +142,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
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")); setWeaponType(0, compound.getInt("WeaponType"));
setWeaponType(1, compound.getInt("PassengerWeaponType"));
} }
@Override @Override
@ -169,6 +185,8 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
public void baseTick() { public void baseTick() {
turretYRotO = this.getTurretYRot(); turretYRotO = this.getTurretYRot();
turretXRotO = this.getTurretXRot(); turretXRotO = this.getTurretXRot();
gunYRotO = this.getGunYRot();
gunXRotO = this.getGunXRot();
leftWheelRotO = this.getLeftWheelRot(); leftWheelRotO = this.getLeftWheelRot();
rightWheelRotO = this.getRightWheelRot(); rightWheelRotO = this.getRightWheelRot();
recoilShakeO = this.getRecoilShake(); recoilShakeO = this.getRecoilShake();
@ -177,10 +195,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
super.baseTick(); super.baseTick();
// if (this.getFirstPassenger() instanceof Player player) {
// player.displayClientMessage(Component.literal(FormatTool.format1D(this.getRecoilShake(), " °")),false);
// }
if (this.entityData.get(TRACK_R) < 0) { if (this.entityData.get(TRACK_R) < 0) {
this.entityData.set(TRACK_R, 100f); this.entityData.set(TRACK_R, 100f);
} }
@ -201,6 +215,14 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
this.entityData.set(FIRE_ANIM, this.entityData.get(FIRE_ANIM) - 1); this.entityData.set(FIRE_ANIM, this.entityData.get(FIRE_ANIM) - 1);
} }
if (this.entityData.get(FIRE_TIME) > 0) {
this.entityData.set(FIRE_TIME, this.entityData.get(FIRE_TIME) - 1);
}
if (this.entityData.get(MACHINE_GUN_HEAT) > 0) {
this.entityData.set(MACHINE_GUN_HEAT, this.entityData.get(MACHINE_GUN_HEAT) - 1);
}
if (reloadCoolDown == 70 && this.getFirstPassenger() instanceof Player player) { if (reloadCoolDown == 70 && this.getFirstPassenger() instanceof Player player) {
SoundTool.playLocalSound(player, ModSounds.YX_100_RELOAD.get()); SoundTool.playLocalSound(player, ModSounds.YX_100_RELOAD.get());
} }
@ -212,6 +234,20 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
this.handleAmmo(); this.handleAmmo();
} }
if (this.entityData.get(MACHINE_GUN_HEAT) < 40) {
cannotFire = false;
}
Entity gunner = this.getNthEntity(1);
if (gunner instanceof Player player) {
if (this.entityData.get(MACHINE_GUN_HEAT) > 100) {
cannotFire = true;
if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_OVERHEAT.get(), 1f, 1f);
}
}
}
if (this.onGround()) { if (this.onGround()) {
float f0 = 0.54f + 0.25f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90; float f0 = 0.54f + 0.25f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90;
this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).normalize().scale(0.05 * this.getDeltaMovement().horizontalDistance()))); this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).normalize().scale(0.05 * this.getDeltaMovement().horizontalDistance())));
@ -244,6 +280,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
collideHardBlock(); collideHardBlock();
} }
turretAngle();
gunnerAngle(); gunnerAngle();
lowHealthWarning(); lowHealthWarning();
this.refreshDimensions(); this.refreshDimensions();
@ -258,14 +295,18 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
} }
private void handleAmmo() { private void handleAmmo() {
if (!(this.getFirstPassenger() instanceof Player player)) return; boolean hasCreativeAmmo = false;
boolean hasCreativeAmmo = player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())); if (this.getFirstPassenger() instanceof Player player) {
hasCreativeAmmo = player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()));
}
if (hasCreativeAmmo) { if (hasCreativeAmmo) {
this.entityData.set(AMMO, 9999); this.entityData.set(AMMO, 9999);
this.entityData.set(MG_AMMO, 9999);
} else { } else {
this.entityData.set(AMMO, countItem(getCurrentAmmoItem())); this.entityData.set(AMMO, countItem(getCurrentAmmoItem()));
this.entityData.set(MG_AMMO, countItem(ModItems.HEAVY_AMMO.get()));
} }
if (this.getEntityData().get(LOADED_AMMO) == 0 if (this.getEntityData().get(LOADED_AMMO) == 0
@ -288,9 +329,8 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
} }
@Override @Override
public void vehicleShoot(Player player) { public void vehicleShoot(Player player, int type) {
if (reloadCoolDown > 0) return; if (reloadCoolDown == 0 && type == 0) {
Matrix4f transform = getBarrelTransform(); Matrix4f transform = getBarrelTransform();
float hitDamage, explosionRadius, explosionDamage, fireProbability; float hitDamage, explosionRadius, explosionDamage, fireProbability;
int fireTime, durability; int fireTime, durability;
@ -393,6 +433,64 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
} }
} }
if (type == 1) {
if (this.cannotFire) return;
Matrix4f transform = getGunTransform();
Vector4f worldPosition = transformPosition(transform, 0, 0, 0);
ProjectileEntity projectile = new ProjectileEntity(player.level())
.shooter(player)
.damage(VehicleConfig.SPEEDBOAT_GUN_DAMAGE.get())
.headShot(2f)
.zoom(false);
projectile.bypassArmorRate(1f);
projectile.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z);
projectile.shoot(getGunVector(1).x, getGunVector(1).y + 0.005f, getGunVector(1).z, 20, 0.02f);
this.level().addFreshEntity(projectile);
float pitch = this.entityData.get(MACHINE_GUN_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - this.entityData.get(MACHINE_GUN_HEAT)));
if (!player.level().isClientSide) {
if (player instanceof ServerPlayer serverPlayer) {
serverPlayer.playSound(ModSounds.M_2_FIRE_3P.get(), 4, pitch);
serverPlayer.playSound(ModSounds.M_2_FAR.get(), 12, pitch);
serverPlayer.playSound(ModSounds.M_2_VERYFAR.get(), 24, pitch);
}
}
this.entityData.set(FIRE_TIME, 2);
this.entityData.set(MACHINE_GUN_HEAT, this.entityData.get(MACHINE_GUN_HEAT) + 3);
Level level = player.level();
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
if (target instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(6, 5, 5, this.getX(), this.getEyeY(), this.getZ()));
}
}
boolean hasCreativeAmmo = player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()));
if (!hasCreativeAmmo) {
ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> {
if (stack.is(ModItems.AMMO_BOX.get())) {
return AmmoType.HEAVY.get(stack) > 0;
}
return false;
}).findFirst().orElse(ItemStack.EMPTY);
if (!ammoBox.isEmpty()) {
AmmoType.HEAVY.add(ammoBox, -1);
} else {
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1));
}
}
}
}
public Vec3 getBarrelVector(float pPartialTicks) { public Vec3 getBarrelVector(float pPartialTicks) {
return this.calculateViewVector(this.getBarrelXRot(pPartialTicks), this.getBarrelYRot(pPartialTicks)); return this.calculateViewVector(this.getBarrelXRot(pPartialTicks), this.getBarrelYRot(pPartialTicks));
} }
@ -405,6 +503,18 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
return -Mth.lerp(pPartialTick, turretYRotO - this.yRotO, getTurretYRot() - this.getYRot()); return -Mth.lerp(pPartialTick, turretYRotO - this.yRotO, getTurretYRot() - this.getYRot());
} }
public Vec3 getGunVector(float pPartialTicks) {
return this.calculateViewVector(this.getGunXRot(pPartialTicks), this.getGunYRot(pPartialTicks));
}
public float getGunXRot(float pPartialTicks) {
return Mth.lerp(pPartialTicks, gunXRotO - this.xRotO, getGunXRot() - this.getXRot());
}
public float getGunYRot(float pPartialTick) {
return -Mth.lerp(pPartialTick, gunYRotO - this.yRotO, getGunYRot() - this.getYRot());
}
@Override @Override
public void travel() { public void travel() {
Entity passenger0 = this.getFirstPassenger(); Entity passenger0 = this.getFirstPassenger();
@ -466,23 +576,39 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
} }
} }
private void gunnerAngle() { private void turretAngle() {
Entity driver = this.getFirstPassenger(); Entity driver = this.getFirstPassenger();
if (!(driver instanceof Player)) return; if (!(driver instanceof Player)) return;
float gunAngle = -Mth.wrapDegrees(driver.getYHeadRot() - this.getYRot()); float turretAngle = -Mth.wrapDegrees(driver.getYHeadRot() - this.getYRot());
float diffY; float diffY;
float diffX; float diffX;
diffY = Mth.wrapDegrees(gunAngle - getTurretYRot() + 0.05f); diffY = Mth.wrapDegrees(turretAngle - getTurretYRot() + 0.05f);
diffX = Mth.wrapDegrees(driver.getXRot() - this.getTurretXRot()); diffX = Mth.wrapDegrees(driver.getXRot() - this.getTurretXRot());
float min = -5 - (float) (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT); float min = -5 + (float) (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT);
float max = 5 - (float) (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT); float max = 5 + (float) (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT);
this.setTurretXRot(Mth.clamp(this.getTurretXRot() + Mth.clamp(0.95f * diffX, min, max), -30f, 4f)); this.setTurretXRot(Mth.clamp(this.getTurretXRot() + Mth.clamp(0.95f * diffX, -5, 5), -30f, 4f));
this.setTurretYRot(this.getTurretYRot() + Mth.clamp(0.9f * diffY, -4.5f, 4.5f)); this.setTurretYRot(this.getTurretYRot() + Mth.clamp(0.9f * diffY, min, max));
}
private void gunnerAngle() {
Entity gunner = this.getNthEntity(1);
if (!(gunner instanceof Player)) return;
float gunAngle = -Mth.wrapDegrees(gunner.getYHeadRot() - this.getYRot());
float diffY;
float diffX;
diffY = Mth.wrapDegrees(gunAngle - getGunYRot());
diffX = Mth.wrapDegrees(gunner.getXRot() - this.getGunXRot());
this.setGunXRot(Mth.clamp(this.getGunXRot() + Mth.clamp(0.95f * diffX, -10, 10), -50f, 10f));
this.setGunYRot(this.getGunYRot() + Mth.clamp(0.9f * diffY, -18, 18));
} }
@Override @Override
@ -505,6 +631,22 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
return turretXRot; return turretXRot;
} }
public float gunYRotO() {
return gunYRotO;
}
public float gunYRot() {
return gunYRot;
}
public float gunXRotO() {
return gunXRotO;
}
public float gunXRot() {
return gunXRot;
}
@Override @Override
public Vec3 getBarrelVec(float ticks) { public Vec3 getBarrelVec(float ticks) {
return getBarrelVector(ticks); return getBarrelVector(ticks);
@ -526,6 +668,22 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
this.turretXRot = pTurretXRot; this.turretXRot = pTurretXRot;
} }
public float getGunYRot() {
return this.gunYRot;
}
public void setGunYRot(float pGunYRot) {
this.gunYRot = pGunYRot;
}
public float getGunXRot() {
return this.gunXRot;
}
public void setGunXRot(float pGunXRot) {
this.gunXRot = pGunXRot;
}
public float getLeftWheelRot() { public float getLeftWheelRot() {
return this.leftWheelRot; return this.leftWheelRot;
} }
@ -564,21 +722,29 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
Matrix4f transform = getTurretTransform(); Matrix4f transform = getTurretTransform();
float x = 0.8669625f; // float x = 0.8669625f;
float y = 0.2f; // float y = 0.2f;
float z = 0.6076875f; // float z = 0.6076875f;
y += (float) passenger.getMyRidingOffset(); // y += (float) passenger.getMyRidingOffset();
//
//
// Vector4f worldPosition = transformPosition(transform, x, y, z);
//
// if (passenger instanceof Yx100GunEntity) {
// worldPosition = transformPosition(transform, -x, y + 2, z);
// }
int i = this.getSeatIndex(passenger); int i = this.getOrderedPassengers().indexOf(passenger);
Vector4f worldPosition = transformPosition(transform, x, y, z);
if (passenger instanceof Yx100GunEntity) {
worldPosition = transformPosition(transform, -x, y + 2, z);
}
if (i == 0) {
Vector4f worldPosition = transformPosition(transform, 0.8669625f, 0.2f, 0.6076875f);
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z); passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z); callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
} else if (i == 1) {
Vector4f worldPosition = transformPosition(transform, -0.87890625f, 0.5f, -0.6640625f);
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
}
} }
public int getMaxPassengers() { public int getMaxPassengers() {
@ -600,6 +766,21 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
return transform; return transform;
} }
public Matrix4f getGunTransform() {
Matrix4f transformT = getTurretTransform();
float x = -0.87890625f;
float y = 2f;
float z = -0.6640625f;
Vector4f worldPosition = transformPosition(transformT, x, y, z);
Matrix4f transform = new Matrix4f();
transform.translate(worldPosition.x, worldPosition.y, worldPosition.z);
transform.rotate(Axis.YP.rotationDegrees(getTurretYRot() - getYRot()));
transform.rotate(Axis.XP.rotationDegrees(getTurretXRot()));
transform.rotate(Axis.ZP.rotationDegrees(getRoll()));
return transform;
}
public Matrix4f getTurretTransform() { public Matrix4f getTurretTransform() {
Matrix4f transformT = getVehicleTransform(); Matrix4f transformT = getVehicleTransform();
float x = 0f; float x = 0f;
@ -651,12 +832,12 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
} }
protected void clampRotation(Entity entity) { protected void clampRotation(Entity entity) {
if (entity.level().isClientSide && entity == getFirstPassenger()) {
float f = Mth.wrapDegrees(entity.getXRot()); float f = Mth.wrapDegrees(entity.getXRot());
float f1 = Mth.clamp(f, -30F, 4F); float f1 = Mth.clamp(f, -30F, 4F);
entity.xRotO += f1 - f; entity.xRotO += f1 - f;
entity.setXRot(entity.getXRot() + f1 - f); entity.setXRot(entity.getXRot() + f1 - f);
if (entity.level().isClientSide && entity == getFirstPassenger()) {
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
if (mc.options.getCameraType() == CameraType.FIRST_PERSON) { if (mc.options.getCameraType() == CameraType.FIRST_PERSON) {
entity.setYBodyRot(this.getYRot()); entity.setYBodyRot(this.getYRot());
@ -666,6 +847,11 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
entity.setYRot(entity.getYRot() + f3 - f2); entity.setYRot(entity.getYRot() + f3 - f2);
entity.setYBodyRot(this.getYRot()); entity.setYBodyRot(this.getYRot());
} }
} else if (entity == getNthEntity(1)) {
float f = Mth.wrapDegrees(entity.getXRot());
float f1 = Mth.clamp(f, -50F, 10F);
entity.xRotO += f1 - f;
entity.setXRot(entity.getXRot() + f1 - f);
} }
} }
@ -702,15 +888,30 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
} }
@Override @Override
public int mainGunRpm() { public int mainGunRpm(Player player) {
if (player == getNthEntity(0)) {
return 15;
}
if (player == getNthEntity(1)) {
return 600;
}
return 15; return 15;
} }
@Override @Override
public boolean canShoot(Player player) { public boolean canShoot(Player player) {
if (player == getNthEntity(0)) {
return this.entityData.get(LOADED_AMMO) > 0; return this.entityData.get(LOADED_AMMO) > 0;
} }
if (player == getNthEntity(1)) {
return (this.entityData.get(MG_AMMO) > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) && !cannotFire;
}
return false;
}
@Override @Override
public int getAmmoCount(Player player) { public int getAmmoCount(Player player) {
return this.entityData.get(LOADED_AMMO); return this.entityData.get(LOADED_AMMO);
@ -763,12 +964,18 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
@Override @Override
public int getWeaponType(int index) { public int getWeaponType(int index) {
return index == 0 ? entityData.get(WEAPON_TYPE) : -1; if (index == 0) {
return entityData.get(WEAPON_TYPE);
} else if (index == 1) {
return entityData.get(PASSENGER_WEAPON_TYPE);
}
return -1;
} }
@Override @Override
public void setWeaponType(int index, int type) { public void setWeaponType(int index, int type) {
if (index == 0) entityData.set(WEAPON_TYPE, type); if (index == 0) entityData.set(WEAPON_TYPE, type);
if (index == 1) entityData.set(PASSENGER_WEAPON_TYPE, type);
} }
@Override @Override

View file

@ -111,7 +111,7 @@ public class Yx100GunEntity extends VehicleEntity implements GeoEntity, CannonEn
} }
@Override @Override
public void vehicleShoot(Player player) { public void vehicleShoot(Player player, int type) {
} }
@ -160,7 +160,7 @@ public class Yx100GunEntity extends VehicleEntity implements GeoEntity, CannonEn
} }
@Override @Override
public int mainGunRpm() { public int mainGunRpm(Player player) {
return 600; return 600;
} }

View file

@ -10,7 +10,7 @@ public interface ArmedVehicleEntity {
* *
* @param player 玩家 * @param player 玩家
*/ */
void vehicleShoot(Player player); void vehicleShoot(Player player, int type);
/** /**
* 判断指定玩家是否是载具驾驶员 * 判断指定玩家是否是载具驾驶员
@ -30,7 +30,7 @@ public interface ArmedVehicleEntity {
* *
* @return 射速 * @return 射速
*/ */
int mainGunRpm(); int mainGunRpm(Player player);
/** /**
* 当前情况载具是否可以开火 * 当前情况载具是否可以开火

View file

@ -64,6 +64,7 @@ import java.util.function.Supplier;
import static com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity.COAX_HEAT; import static com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity.COAX_HEAT;
import static com.atsuishio.superbwarfare.entity.vehicle.SpeedboatEntity.HEAT; import static com.atsuishio.superbwarfare.entity.vehicle.SpeedboatEntity.HEAT;
import static com.atsuishio.superbwarfare.entity.vehicle.Yx100Entity.MACHINE_GUN_HEAT;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class ClientEventHandler { public class ClientEventHandler {
@ -701,8 +702,8 @@ public class ClientEventHandler {
holdFireVehicle = false; holdFireVehicle = false;
} }
if (player.getVehicle() instanceof ArmedVehicleEntity iVehicle && iVehicle.isDriver(player) && iVehicle.canShoot(player)) { if (player.getVehicle() instanceof VehicleEntity pVehicle && player.getVehicle() instanceof WeaponVehicleEntity iVehicle && iVehicle.hasWeapon(pVehicle.getSeatIndex(player)) && iVehicle.canShoot(player)) {
int rpm = iVehicle.mainGunRpm(); int rpm = iVehicle.mainGunRpm(player);
if (rpm == 0) { if (rpm == 0) {
rpm = 240; rpm = 240;
} }
@ -718,8 +719,8 @@ public class ClientEventHandler {
} }
if (clientTimerVehicle.getProgress() >= cooldown) { if (clientTimerVehicle.getProgress() >= cooldown) {
ModUtils.PACKET_HANDLER.sendToServer(new VehicleFireMessage(0)); ModUtils.PACKET_HANDLER.sendToServer(new VehicleFireMessage(pVehicle.getSeatIndex(player)));
playVehicleClientSounds(player, iVehicle); playVehicleClientSounds(player, iVehicle, pVehicle.getSeatIndex(player));
clientTimerVehicle.setProgress((clientTimerVehicle.getProgress() - cooldown)); clientTimerVehicle.setProgress((clientTimerVehicle.getProgress() - cooldown));
} }
} else if (clientTimerVehicle.getProgress() >= cooldown) { } else if (clientTimerVehicle.getProgress() >= cooldown) {
@ -730,14 +731,13 @@ public class ClientEventHandler {
} }
} }
public static void playVehicleClientSounds(Player player, ArmedVehicleEntity iVehicle) { public static void playVehicleClientSounds(Player player, WeaponVehicleEntity iVehicle, int type) {
if (iVehicle instanceof SpeedboatEntity speedboat) { if (iVehicle instanceof SpeedboatEntity speedboat) {
float pitch = speedboat.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - speedboat.getEntityData().get(HEAT))); float pitch = speedboat.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - speedboat.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);
} }
if (iVehicle instanceof WeaponVehicleEntity) {
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.getWeaponType(0) == 0) {
@ -770,7 +770,12 @@ public class ClientEventHandler {
player.playSound(ModSounds.BMP_MISSILE_FIRE_1P.get(), 1f, 1); player.playSound(ModSounds.BMP_MISSILE_FIRE_1P.get(), 1f, 1);
} }
} }
if (iVehicle instanceof Yx100Entity) { if (iVehicle instanceof Yx100Entity yx100) {
if (type == 1) {
float pitch = yx100.getEntityData().get(MACHINE_GUN_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - yx100.getEntityData().get(MACHINE_GUN_HEAT)));
player.playSound(ModSounds.M_2_FIRE_1P.get(), 1f, pitch);
player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1);
} else {
player.playSound(ModSounds.YX_100_FIRE_1P.get(), 1f, 1); player.playSound(ModSounds.YX_100_FIRE_1P.get(), 1f, 1);
} }
} }

View file

@ -94,9 +94,9 @@ public abstract class CameraMixin {
setRotation(-Mth.lerp(partialTicks, yx100.turretYRotO - yx100.yRotO, yx100.getTurretYRot() - yx100.getYRot()), Mth.lerp(partialTicks, yx100.turretXRotO - yx100.xRotO, yx100.getTurretXRot() - yx100.getXRot())); setRotation(-Mth.lerp(partialTicks, yx100.turretYRotO - yx100.yRotO, yx100.getTurretYRot() - yx100.getYRot()), Mth.lerp(partialTicks, yx100.turretXRotO - yx100.xRotO, yx100.getTurretXRot() - yx100.getXRot()));
setPosition(Mth.lerp(partialTicks, player.xo, player.getX()), Mth.lerp(partialTicks, player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(partialTicks, player.zo, player.getZ())); setPosition(Mth.lerp(partialTicks, player.xo, player.getX()), Mth.lerp(partialTicks, player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(partialTicks, player.zo, player.getZ()));
info.cancel(); info.cancel();
} else { } else if (yx100.getNthEntity(1) == player) {
setRotation(Mth.lerp(partialTicks, player.yHeadRotO, player.getYHeadRot()), Mth.lerp(partialTicks, player.xRotO, player.getXRot())); setRotation(-Mth.lerp(partialTicks, yx100.gunYRotO - yx100.yRotO, yx100.getGunYRot() - yx100.getYRot()), Mth.lerp(partialTicks, yx100.gunXRotO - yx100.xRotO, yx100.getGunXRot() - yx100.getXRot()));
setPosition(Mth.lerp(partialTicks, player.xo, player.getX()) - 6 * player.getViewVector(partialTicks).x, Mth.lerp(partialTicks, player.yo + player.getEyeHeight() + 1, player.getEyeY() + 1) - 6 * player.getViewVector(partialTicks).y, Mth.lerp(partialTicks, player.zo, player.getZ()) - 6 * player.getViewVector(partialTicks).z); setPosition(Mth.lerp(partialTicks, player.xo, player.getX()), Mth.lerp(partialTicks, player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(partialTicks, player.zo, player.getZ()));
info.cancel(); info.cancel();
} }
return; return;

View file

@ -61,8 +61,12 @@ public class MouseHandlerMixin {
return ClientEventHandler.zoomVehicle ? 0.22 : 0.27; return ClientEventHandler.zoomVehicle ? 0.22 : 0.27;
} }
if (player.getVehicle() instanceof Yx100Entity) { if (player.getVehicle() instanceof Yx100Entity yx100) {
if (player == yx100.getFirstPassenger()) {
return ClientEventHandler.zoomVehicle ? 0.17 : 0.22; return ClientEventHandler.zoomVehicle ? 0.17 : 0.22;
} else if (player ==yx100.getNthEntity(1)){
return ClientEventHandler.zoomVehicle ? 0.27 : 0.35;
}
} }
if (player.getVehicle() instanceof Ah6Entity ah6Entity && !ah6Entity.onGround() && ah6Entity.getFirstPassenger() == player) { if (player.getVehicle() instanceof Ah6Entity ah6Entity && !ah6Entity.onGround() && ah6Entity.getFirstPassenger() == player) {

View file

@ -29,7 +29,7 @@ public class VehicleFireMessage {
var player = context.getSender(); var player = context.getSender();
if (player.getVehicle() instanceof ArmedVehicleEntity iVehicle) { if (player.getVehicle() instanceof ArmedVehicleEntity iVehicle) {
iVehicle.vehicleShoot(player); iVehicle.vehicleShoot(player, message.type);
} }
} }
}); });

View file

@ -7379,9 +7379,9 @@
] ]
}, },
{ {
"name": "QQQJ2", "name": "qiangguan",
"parent": "jiqiang", "parent": "jiqiang",
"pivot": [-14.075, 61.82839, -26.40625], "pivot": [-14.03469, 61.31016, 9.60856],
"cubes": [ "cubes": [
{ {
"origin": [-16.36015, 58.61995, -2.03125], "origin": [-16.36015, 58.61995, -2.03125],