From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MeFisto94 Date: Tue, 11 May 2021 00:48:33 +0200 Subject: [PATCH] Add a "should burn in sunlight" API for Phantoms and Skeletons diff --git a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java +++ b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java @@ -0,0 +0,0 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo return MobType.UNDEAD; } + // Paper start + private boolean shouldBurnInDay = true; + public boolean shouldBurnInDay() { return shouldBurnInDay; } + public void setShouldBurnInDay(boolean shouldBurnInDay) { this.shouldBurnInDay = shouldBurnInDay; } + // Paper end + @Override public void aiStep() { - boolean flag = this.isSunBurnTick(); + boolean flag = shouldBurnInDay && this.isSunBurnTick(); // Paper - Configurable Burning if (flag) { ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); @@ -0,0 +0,0 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo public void readAdditionalSaveData(CompoundTag nbt) { super.readAdditionalSaveData(nbt); this.reassessWeaponGoal(); + // Paper start + if (nbt.contains("Paper.ShouldBurnInDay")) { + this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay"); + } + // Paper end + } + + // Paper start + @Override + public void addAdditionalSaveData(CompoundTag nbt) { + super.addAdditionalSaveData(nbt); + nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay); } + // Paper end @Override public void setItemSlot(EquipmentSlot slot, ItemStack stack) { diff --git a/src/main/java/net/minecraft/world/entity/monster/Phantom.java b/src/main/java/net/minecraft/world/entity/monster/Phantom.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Phantom.java +++ b/src/main/java/net/minecraft/world/entity/monster/Phantom.java @@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy { @Override public void aiStep() { - if (this.isAlive() && this.isSunBurnTick()) { + if (this.isAlive() && shouldBurnInDay && this.isSunBurnTick()) { // Paper - Configurable Burning this.setSecondsOnFire(8); } @@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy { if (nbt.hasUUID("Paper.SpawningEntity")) { this.spawningEntity = nbt.getUUID("Paper.SpawningEntity"); } + if (nbt.contains("Paper.ShouldBurnInDay")) { + this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay"); + } // Paper end } @@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy { if (this.spawningEntity != null) { nbt.putUUID("Paper.SpawningEntity", this.spawningEntity); } + nbt.putBoolean("Paper.ShouldBurnInDay", shouldBurnInDay); // Paper end } @@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy { return spawningEntity; } public void setSpawningEntity(java.util.UUID entity) { this.spawningEntity = entity; } + + private boolean shouldBurnInDay = true; + public boolean shouldBurnInDay() { return shouldBurnInDay; } + public void setShouldBurnInDay(boolean shouldBurnInDay) { this.shouldBurnInDay = shouldBurnInDay; } // Paper end private static enum AttackPhase { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java @@ -0,0 +0,0 @@ public abstract class CraftAbstractSkeleton extends CraftMonster implements Abst return (net.minecraft.world.entity.monster.AbstractSkeleton) super.getHandle(); } // Paper end + // Paper start + @Override + public boolean shouldBurnInDay() { + return getHandle().shouldBurnInDay(); + } + + @Override + public void setShouldBurnInDay(boolean shouldBurnInDay) { + getHandle().setShouldBurnInDay(shouldBurnInDay); + } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java @@ -0,0 +0,0 @@ public class CraftPhantom extends CraftFlying implements Phantom { public java.util.UUID getSpawningEntity() { return getHandle().getSpawningEntity(); } + + @Override + public boolean shouldBurnInDay() { + return getHandle().shouldBurnInDay(); + } + + @Override + public void setShouldBurnInDay(boolean shouldBurnInDay) { + getHandle().setShouldBurnInDay(shouldBurnInDay); + } // Paper end }