Skip to content

Commit

Permalink
fix: prevent crash from NullPointerError if player dies in oil or sul…
Browse files Browse the repository at this point in the history
…furic acid
  • Loading branch information
Roelymole committed Jan 9, 2025
1 parent 26380d7 commit 7adef29
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/dev/galacticraft/mod/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,18 @@ public abstract class EntityMixin implements EntityAccessor {

@Inject(method = "updateInWaterStateAndDoWaterCurrentPushing", at = @At("TAIL"))
private void checkWaterStateGC(CallbackInfo ci) {
Player player = level.getPlayerByUUID(uuid);
boolean isCreative = (player != null) && player.isCreative();
if (this.updateFluidHeightAndDoFluidPushing(GCTags.OIL, 0.0028d) || this.updateFluidHeightAndDoFluidPushing(GCTags.FUEL, 0.0028d)) {
if (this.isOnFire()) {
level.explode(level.getEntity(id), position.x, position.y, position.z, 0f, Level.ExplosionInteraction.NONE);
if ((this.isAlwaysTicking() && !level.getPlayerByUUID(uuid).isCreative()) || !this.isInvulnerable()) {
if ((this.isAlwaysTicking() && !isCreative) || !this.isInvulnerable()) {
this.hurt(new DamageSource(this.level.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(GCDamageTypes.OIL_BOOM)), 20.0f);
}
}
} else if (this.updateFluidHeightAndDoFluidPushing(GCTags.SULFURIC_ACID, 0.0028d)) {
// The entity enter an acid fluid, this entity need to take damage
if ((this.isAlwaysTicking() && !level.getPlayerByUUID(uuid).isCreative()) || !this.isInvulnerable()) {
if ((this.isAlwaysTicking() && !isCreative) || !this.isInvulnerable()) {
this.hurt(new DamageSource(this.level.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE)
.getHolderOrThrow(GCDamageTypes.SULFURIC_ACID)), 2.0f);
}
Expand Down

0 comments on commit 7adef29

Please sign in to comment.