修复一个导致NPE的问题
This commit is contained in:
parent
fec75999c0
commit
3dcc5fc696
1 changed files with 6 additions and 9 deletions
|
@ -56,6 +56,7 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
|
public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
|
||||||
|
|
||||||
public static final EntityDataAccessor<Boolean> LINKED = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.BOOLEAN);
|
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<String> CONTROLLER = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.STRING);
|
||||||
public static final EntityDataAccessor<Integer> AMMO = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.INT);
|
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));
|
Player controller = EntityFindUtil.findPlayer(this.level(), this.entityData.get(CONTROLLER));
|
||||||
|
|
||||||
|
|
||||||
if (!this.onGround()) {
|
if (!this.onGround()) {
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
handleSimulationDistance(controller);
|
handleSimulationDistance(controller);
|
||||||
|
@ -447,14 +447,13 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
|
||||||
hitEntityCrash(controller, target);
|
hitEntityCrash(controller, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hitEntityCrash(Player controller, Entity target) {
|
public void hitEntityCrash(Player controller, Entity target) {
|
||||||
if (lastTickSpeed > 0.12) {
|
if (lastTickSpeed > 0.12) {
|
||||||
if (this.entityData.get(KAMIKAZE) && 20 * lastTickSpeed > this.getHealth()) {
|
if (this.entityData.get(KAMIKAZE) && 20 * lastTickSpeed > this.getHealth()) {
|
||||||
target.hurt(ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, controller), ExplosionConfig.DRONE_KAMIKAZE_HIT_DAMAGE.get());
|
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);
|
Monitor.disLink(controller.getMainHandItem(), controller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -484,7 +483,6 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
|
||||||
String id = this.entityData.get(CONTROLLER);
|
String id = this.entityData.get(CONTROLLER);
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
try {
|
try {
|
||||||
|
@ -530,7 +528,6 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void kamikazeExplosion() {
|
private void kamikazeExplosion() {
|
||||||
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
|
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
|
||||||
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
||||||
|
|
Loading…
Add table
Reference in a new issue