diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/EnergyVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/EnergyVehicleEntity.java index eb589405c..a97ade4f0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/EnergyVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/EnergyVehicleEntity.java @@ -33,7 +33,7 @@ public class EnergyVehicleEntity extends VehicleEntity implements IChargeEntity @Override public void addAdditionalSaveData(CompoundTag compound) { super.addAdditionalSaveData(compound); - compound.putFloat("Energy", this.entityData.get(ENERGY)); + compound.putInt("Energy", this.entityData.get(ENERGY)); } public void extraEnergy(int extraAmount) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/MobileVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/MobileVehicleEntity.java index 39796c90f..e432b6e0d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/MobileVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/MobileVehicleEntity.java @@ -71,7 +71,9 @@ public class MobileVehicleEntity extends EnergyVehicleEntity { double f = Math.min(entitySize / thisSize, 2); double f1 = Math.min(thisSize / entitySize, 4); - if (entity.isAlive() && !(entity instanceof ItemEntity || entity instanceof Projectile || entity instanceof ProjectileEntity)) { + if (entity.isAlive() + && !(entity instanceof ItemEntity || entity instanceof Projectile || entity instanceof ProjectileEntity) + && !(entity instanceof Player player && (player.isSpectator() || player.isCreative()))) { if (velocity.horizontalDistance() > 0.4) { if (!this.level().isClientSide) { this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1); @@ -117,10 +119,12 @@ public class MobileVehicleEntity extends EnergyVehicleEntity { @Override protected void readAdditionalSaveData(CompoundTag compound) { super.readAdditionalSaveData(compound); + this.entityData.set(POWER, compound.getFloat("Power")); } @Override public void addAdditionalSaveData(CompoundTag compound) { super.addAdditionalSaveData(compound); + compound.putFloat("Power", this.entityData.get(POWER)); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/VehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/VehicleEntity.java index 299a262aa..38d5101a9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/VehicleEntity.java @@ -6,6 +6,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; @@ -21,6 +22,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; import org.joml.Math; public class VehicleEntity extends Entity { @@ -193,6 +195,11 @@ public class VehicleEntity extends Entity { return !this.isRemoved(); } + @Override + public boolean skipAttackInteraction(@NotNull Entity attacker) { + return hasPassenger(attacker) || super.skipAttackInteraction(attacker); + } + @Override public void baseTick() { super.baseTick(); @@ -212,7 +219,7 @@ public class VehicleEntity extends Entity { handleClientSync(); - if (this.getHealth() <= 0) { + if (this.level() instanceof ServerLevel && this.getHealth() <= 0) { this.ejectPassengers(); destroy(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/GunGrenadeEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/GunGrenadeEntity.java index 12401e861..6b17b23d4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/GunGrenadeEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/GunGrenadeEntity.java @@ -80,6 +80,9 @@ public class GunGrenadeEntity extends ThrowableItemProjectile implements GeoEnti protected void onHitEntity(EntityHitResult result) { float damageMultiplier = 1 + this.monsterMultiplier; Entity entity = result.getEntity(); + + if (entity == this.getOwner() || entity == this.getVehicle()) return; + if (this.getOwner() instanceof LivingEntity living) { if (!living.level().isClientSide() && living instanceof ServerPlayer player) { living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/HandGrenadeEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/HandGrenadeEntity.java index 91c1f2a5b..5c8731a82 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/HandGrenadeEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/HandGrenadeEntity.java @@ -91,6 +91,7 @@ public class HandGrenadeEntity extends ThrowableItemProjectile implements GeoEnt case ENTITY: EntityHitResult entityResult = (EntityHitResult) result; Entity entity = entityResult.getEntity(); + if (entity == this.getOwner() || entity == this.getVehicle()) return; double speed_e = this.getDeltaMovement().length(); if (speed_e > 0.1) { if (this.getOwner() instanceof LivingEntity living) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java index c915b1097..b05b86c74 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java @@ -121,6 +121,7 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo protected void onHitEntity(EntityHitResult result) { float damageMultiplier = 1 + this.monsterMultiplier; Entity entity = result.getEntity(); + if (entity == this.getOwner() || entity == this.getVehicle()) return; if (this.getOwner() instanceof LivingEntity living) { if (!living.level().isClientSide() && living instanceof ServerPlayer player) { living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RgoGrenadeEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RgoGrenadeEntity.java index bc248e042..e3eff10a6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RgoGrenadeEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RgoGrenadeEntity.java @@ -93,6 +93,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti case ENTITY: EntityHitResult entityResult = (EntityHitResult) result; Entity entity = entityResult.getEntity(); + if (entity == this.getOwner() || entity == this.getVehicle()) return; if (this.getOwner() instanceof LivingEntity living) { if (!living.level().isClientSide() && living instanceof ServerPlayer player) { living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java index 0eba4da44..35afc2c86 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java @@ -97,6 +97,7 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit protected void onHitEntity(EntityHitResult result) { float damageMultiplier = 1 + this.monsterMultiplier; Entity entity = result.getEntity(); + if (entity == this.getOwner() || entity == this.getVehicle()) return; if (this.getOwner() instanceof LivingEntity living) { if (!living.level().isClientSide() && living instanceof ServerPlayer player) { living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/TaserBulletProjectileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/TaserBulletProjectileEntity.java index 3e6bd7590..3c2392fdd 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/TaserBulletProjectileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/TaserBulletProjectileEntity.java @@ -79,6 +79,7 @@ public class TaserBulletProjectileEntity extends AbstractArrow implements GeoEnt @Override protected void onHitEntity(EntityHitResult result) { Entity entity = result.getEntity(); + if (entity == this.getVehicle()) return; if (this.getOwner() instanceof LivingEntity living) { if (!living.level().isClientSide() && living instanceof ServerPlayer player) { living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1); diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java index 7aec65a03..cd118f6d6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java @@ -31,6 +31,7 @@ public class SeekTool { && e != entity && e.isAlive() && e.getVehicle() == null + && !(e instanceof Player player && (player.isSpectator())) && !(e instanceof ItemEntity || e instanceof ExperienceOrb || e instanceof HangingEntity || e instanceof ProjectileEntity || e instanceof Projectile || e instanceof ArmorStand) ) { return level.clip(new ClipContext(entity.getEyePosition(), e.getEyePosition(),