修复载具上开火把自己弹出的问题
This commit is contained in:
parent
974ee5cce1
commit
4247ca342a
10 changed files with 23 additions and 3 deletions
|
@ -33,7 +33,7 @@ public class EnergyVehicleEntity extends VehicleEntity implements IChargeEntity
|
||||||
@Override
|
@Override
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
super.addAdditionalSaveData(compound);
|
super.addAdditionalSaveData(compound);
|
||||||
compound.putFloat("Energy", this.entityData.get(ENERGY));
|
compound.putInt("Energy", this.entityData.get(ENERGY));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void extraEnergy(int extraAmount) {
|
public void extraEnergy(int extraAmount) {
|
||||||
|
|
|
@ -71,7 +71,9 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
double f = Math.min(entitySize / thisSize, 2);
|
double f = Math.min(entitySize / thisSize, 2);
|
||||||
double f1 = Math.min(thisSize / entitySize, 4);
|
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 (velocity.horizontalDistance() > 0.4) {
|
||||||
if (!this.level().isClientSide) {
|
if (!this.level().isClientSide) {
|
||||||
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
|
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
|
||||||
|
@ -117,10 +119,12 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
||||||
@Override
|
@Override
|
||||||
protected void readAdditionalSaveData(CompoundTag compound) {
|
protected void readAdditionalSaveData(CompoundTag compound) {
|
||||||
super.readAdditionalSaveData(compound);
|
super.readAdditionalSaveData(compound);
|
||||||
|
this.entityData.set(POWER, compound.getFloat("Power"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
super.addAdditionalSaveData(compound);
|
super.addAdditionalSaveData(compound);
|
||||||
|
compound.putFloat("Power", this.entityData.get(POWER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.InteractionHand;
|
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.item.Items;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.joml.Math;
|
import org.joml.Math;
|
||||||
|
|
||||||
public class VehicleEntity extends Entity {
|
public class VehicleEntity extends Entity {
|
||||||
|
@ -193,6 +195,11 @@ public class VehicleEntity extends Entity {
|
||||||
return !this.isRemoved();
|
return !this.isRemoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean skipAttackInteraction(@NotNull Entity attacker) {
|
||||||
|
return hasPassenger(attacker) || super.skipAttackInteraction(attacker);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void baseTick() {
|
public void baseTick() {
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
|
@ -212,7 +219,7 @@ public class VehicleEntity extends Entity {
|
||||||
|
|
||||||
handleClientSync();
|
handleClientSync();
|
||||||
|
|
||||||
if (this.getHealth() <= 0) {
|
if (this.level() instanceof ServerLevel && this.getHealth() <= 0) {
|
||||||
this.ejectPassengers();
|
this.ejectPassengers();
|
||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,9 @@ public class GunGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
||||||
protected void onHitEntity(EntityHitResult result) {
|
protected void onHitEntity(EntityHitResult result) {
|
||||||
float damageMultiplier = 1 + this.monsterMultiplier;
|
float damageMultiplier = 1 + this.monsterMultiplier;
|
||||||
Entity entity = result.getEntity();
|
Entity entity = result.getEntity();
|
||||||
|
|
||||||
|
if (entity == this.getOwner() || entity == this.getVehicle()) return;
|
||||||
|
|
||||||
if (this.getOwner() instanceof LivingEntity living) {
|
if (this.getOwner() instanceof LivingEntity living) {
|
||||||
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
||||||
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
||||||
|
|
|
@ -91,6 +91,7 @@ public class HandGrenadeEntity extends ThrowableItemProjectile implements GeoEnt
|
||||||
case ENTITY:
|
case ENTITY:
|
||||||
EntityHitResult entityResult = (EntityHitResult) result;
|
EntityHitResult entityResult = (EntityHitResult) result;
|
||||||
Entity entity = entityResult.getEntity();
|
Entity entity = entityResult.getEntity();
|
||||||
|
if (entity == this.getOwner() || entity == this.getVehicle()) return;
|
||||||
double speed_e = this.getDeltaMovement().length();
|
double speed_e = this.getDeltaMovement().length();
|
||||||
if (speed_e > 0.1) {
|
if (speed_e > 0.1) {
|
||||||
if (this.getOwner() instanceof LivingEntity living) {
|
if (this.getOwner() instanceof LivingEntity living) {
|
||||||
|
|
|
@ -121,6 +121,7 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo
|
||||||
protected void onHitEntity(EntityHitResult result) {
|
protected void onHitEntity(EntityHitResult result) {
|
||||||
float damageMultiplier = 1 + this.monsterMultiplier;
|
float damageMultiplier = 1 + this.monsterMultiplier;
|
||||||
Entity entity = result.getEntity();
|
Entity entity = result.getEntity();
|
||||||
|
if (entity == this.getOwner() || entity == this.getVehicle()) return;
|
||||||
if (this.getOwner() instanceof LivingEntity living) {
|
if (this.getOwner() instanceof LivingEntity living) {
|
||||||
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
||||||
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
||||||
|
|
|
@ -93,6 +93,7 @@ public class RgoGrenadeEntity extends ThrowableItemProjectile implements GeoEnti
|
||||||
case ENTITY:
|
case ENTITY:
|
||||||
EntityHitResult entityResult = (EntityHitResult) result;
|
EntityHitResult entityResult = (EntityHitResult) result;
|
||||||
Entity entity = entityResult.getEntity();
|
Entity entity = entityResult.getEntity();
|
||||||
|
if (entity == this.getOwner() || entity == this.getVehicle()) return;
|
||||||
if (this.getOwner() instanceof LivingEntity living) {
|
if (this.getOwner() instanceof LivingEntity living) {
|
||||||
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
||||||
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
||||||
|
|
|
@ -97,6 +97,7 @@ public class RpgRocketEntity extends ThrowableItemProjectile implements GeoEntit
|
||||||
protected void onHitEntity(EntityHitResult result) {
|
protected void onHitEntity(EntityHitResult result) {
|
||||||
float damageMultiplier = 1 + this.monsterMultiplier;
|
float damageMultiplier = 1 + this.monsterMultiplier;
|
||||||
Entity entity = result.getEntity();
|
Entity entity = result.getEntity();
|
||||||
|
if (entity == this.getOwner() || entity == this.getVehicle()) return;
|
||||||
if (this.getOwner() instanceof LivingEntity living) {
|
if (this.getOwner() instanceof LivingEntity living) {
|
||||||
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
||||||
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
||||||
|
|
|
@ -79,6 +79,7 @@ public class TaserBulletProjectileEntity extends AbstractArrow implements GeoEnt
|
||||||
@Override
|
@Override
|
||||||
protected void onHitEntity(EntityHitResult result) {
|
protected void onHitEntity(EntityHitResult result) {
|
||||||
Entity entity = result.getEntity();
|
Entity entity = result.getEntity();
|
||||||
|
if (entity == this.getVehicle()) return;
|
||||||
if (this.getOwner() instanceof LivingEntity living) {
|
if (this.getOwner() instanceof LivingEntity living) {
|
||||||
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
||||||
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class SeekTool {
|
||||||
&& e != entity
|
&& e != entity
|
||||||
&& e.isAlive()
|
&& e.isAlive()
|
||||||
&& e.getVehicle() == null
|
&& 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)
|
&& !(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(),
|
return level.clip(new ClipContext(entity.getEyePosition(), e.getEyePosition(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue