修复一个导致NPE的问题

This commit is contained in:
17146 2025-01-21 19:04:52 +08:00
parent fec75999c0
commit 3dcc5fc696

View file

@ -56,6 +56,7 @@ import software.bernie.geckolib.util.GeckoLibUtil;
import java.util.*;
public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
public static final EntityDataAccessor<Boolean> LINKED = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<String> CONTROLLER = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.STRING);
public static final EntityDataAccessor<Integer> AMMO = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.INT);
@ -179,7 +180,6 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
Player controller = EntityFindUtil.findPlayer(this.level(), this.entityData.get(CONTROLLER));
if (!this.onGround()) {
if (controller != null) {
handleSimulationDistance(controller);
@ -447,14 +447,13 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
hitEntityCrash(controller, target);
}
}
}
public void hitEntityCrash(Player controller, Entity target) {
if (lastTickSpeed > 0.12) {
if (this.entityData.get(KAMIKAZE) && 20 * lastTickSpeed > this.getHealth()) {
target.hurt(ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, controller), ExplosionConfig.DRONE_KAMIKAZE_HIT_DAMAGE.get());
if (controller.getMainHandItem().is(ModItems.MONITOR.get())) {
if (controller != null && controller.getMainHandItem().is(ModItems.MONITOR.get())) {
Monitor.disLink(controller.getMainHandItem(), controller);
}
}
@ -484,7 +483,6 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
@Override
public void destroy() {
String id = this.entityData.get(CONTROLLER);
UUID uuid;
try {
@ -530,7 +528,6 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
this.discard();
}
private void kamikazeExplosion() {
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
CustomExplosion explosion = new CustomExplosion(this.level(), this,