From f04709de7853b525d578aeab63cd0297c8377c27 Mon Sep 17 00:00:00 2001 From: granny Date: Tue, 7 Jan 2025 17:59:38 -0800 Subject: [PATCH] port Phantoms burn in light patch --- .../server/0073-Phantoms-burn-in-light.patch | 76 ------------------- .../0012-Phantoms-burn-in-light.patch | 52 +++++++++++++ .../purpurmc/purpur/PurpurWorldConfig.java | 6 ++ 3 files changed, 58 insertions(+), 76 deletions(-) delete mode 100644 patches/server/0073-Phantoms-burn-in-light.patch create mode 100644 purpur-server/minecraft-patches/features/0012-Phantoms-burn-in-light.patch diff --git a/patches/server/0073-Phantoms-burn-in-light.patch b/patches/server/0073-Phantoms-burn-in-light.patch deleted file mode 100644 index eaf657da5..000000000 --- a/patches/server/0073-Phantoms-burn-in-light.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: draycia -Date: Sun, 12 Apr 2020 20:41:59 -0700 -Subject: [PATCH] Phantoms burn in light - - -diff --git a/net/minecraft/world/entity/monster/Phantom.java b/net/minecraft/world/entity/monster/Phantom.java -index 093c2601ff561c47775f9f99cb5990e6c1b05d8c..7f62544ed66850c9545d8db9897236abd52cbd56 100644 ---- a/net/minecraft/world/entity/monster/Phantom.java -+++ b/net/minecraft/world/entity/monster/Phantom.java -@@ -50,6 +50,7 @@ public class Phantom extends FlyingMob implements Enemy { - public BlockPos anchorPoint; - Phantom.AttackPhase attackPhase; - Vec3 crystalPosition; // Purpur - Phantoms attracted to crystals and crystals shoot phantoms -+ private static final net.minecraft.world.item.crafting.Ingredient TORCH = net.minecraft.world.item.crafting.Ingredient.of(net.minecraft.world.item.Items.TORCH, net.minecraft.world.item.Items.SOUL_TORCH); // Purpur - Phantoms burn in light - - public Phantom(EntityType type, Level world) { - super(type, world); -@@ -243,7 +244,11 @@ public class Phantom extends FlyingMob implements Enemy { - - @Override - public void aiStep() { -- if (this.isAlive() && this.shouldBurnInDay && this.isSunBurnTick()) { // Paper - shouldBurnInDay API -+ // Purpur start - Phantoms burn in light -+ boolean burnFromDaylight = this.shouldBurnInDay && this.isSunBurnTick() && this.level().purpurConfig.phantomBurnInDaylight; -+ boolean burnFromLightSource = this.level().purpurConfig.phantomBurnInLight > 0 && this.level().getMaxLocalRawBrightness(blockPosition()) >= this.level().purpurConfig.phantomBurnInLight; -+ if (this.isAlive() && (burnFromDaylight || burnFromLightSource)) { // Paper - shouldBurnInDay API -+ // Purpur end - Phantoms burn in light - if (getRider() == null || !this.isControllable()) // Purpur - Ridables - this.igniteForSeconds(8.0F); - } -@@ -642,6 +647,12 @@ public class Phantom extends FlyingMob implements Enemy { - return false; - } else if (!entityliving.isAlive()) { - return false; -+ // Purpur start - Phantoms burn in light -+ } else if (level().purpurConfig.phantomBurnInLight > 0 && level().getLightEmission(new BlockPos(Phantom.this)) >= level().purpurConfig.phantomBurnInLight) { -+ return false; -+ } else if (level().purpurConfig.phantomIgnorePlayersWithTorch && (TORCH.test(entityliving.getItemInHand(net.minecraft.world.InteractionHand.MAIN_HAND)) || TORCH.test(entityliving.getItemInHand(net.minecraft.world.InteractionHand.OFF_HAND)))) { -+ return false; -+ // Purpur end - Phantoms burn in light - } else { - if (entityliving instanceof Player) { - Player entityhuman = (Player) entityliving; -@@ -788,6 +799,7 @@ public class Phantom extends FlyingMob implements Enemy { - ServerLevel worldserver = getServerLevel(Phantom.this.level()); - List list = worldserver.getNearbyPlayers(this.attackTargeting, Phantom.this, Phantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D)); - -+ if (level().purpurConfig.phantomIgnorePlayersWithTorch) list.removeIf(human -> TORCH.test(human.getItemInHand(net.minecraft.world.InteractionHand.MAIN_HAND)) || TORCH.test(human.getItemInHand(net.minecraft.world.InteractionHand.OFF_HAND)));// Purpur - Phantoms burn in light - if (!list.isEmpty()) { - list.sort(Comparator.comparing((Entity e) -> { return e.getY(); }).reversed()); // CraftBukkit - decompile error - Iterator iterator = list.iterator(); -diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index 0d4eaa2933d2b6501eeb64a0d95b2d4d67fb5523..4fc86678e3c6459d88a0f7114dd858c6850290df 100644 ---- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -@@ -1221,6 +1221,9 @@ public class PurpurWorldConfig { - public double phantomSpawnLocalDifficultyChance = 3.0D; - public int phantomSpawnMinPerAttempt = 1; - public int phantomSpawnMaxPerAttempt = -1; -+ public int phantomBurnInLight = 0; -+ public boolean phantomIgnorePlayersWithTorch = false; -+ public boolean phantomBurnInDaylight = true; - private void phantomSettings() { - phantomRidable = getBoolean("mobs.phantom.ridable", phantomRidable); - phantomRidableInWater = getBoolean("mobs.phantom.ridable-in-water", phantomRidableInWater); -@@ -1251,6 +1254,9 @@ public class PurpurWorldConfig { - phantomSpawnLocalDifficultyChance = getDouble("mobs.phantom.spawn.local-difficulty-chance", phantomSpawnLocalDifficultyChance); - phantomSpawnMinPerAttempt = getInt("mobs.phantom.spawn.per-attempt.min", phantomSpawnMinPerAttempt); - phantomSpawnMaxPerAttempt = getInt("mobs.phantom.spawn.per-attempt.max", phantomSpawnMaxPerAttempt); -+ phantomBurnInLight = getInt("mobs.phantom.burn-in-light", phantomBurnInLight); -+ phantomBurnInDaylight = getBoolean("mobs.phantom.burn-in-daylight", phantomBurnInDaylight); -+ phantomIgnorePlayersWithTorch = getBoolean("mobs.phantom.ignore-players-with-torch", phantomIgnorePlayersWithTorch); - } - - public boolean pigRidable = false; diff --git a/purpur-server/minecraft-patches/features/0012-Phantoms-burn-in-light.patch b/purpur-server/minecraft-patches/features/0012-Phantoms-burn-in-light.patch new file mode 100644 index 000000000..ea29b8107 --- /dev/null +++ b/purpur-server/minecraft-patches/features/0012-Phantoms-burn-in-light.patch @@ -0,0 +1,52 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: draycia +Date: Sun, 12 Apr 2020 20:41:59 -0700 +Subject: [PATCH] Phantoms burn in light + + +diff --git a/net/minecraft/world/entity/monster/Phantom.java b/net/minecraft/world/entity/monster/Phantom.java +index 438f09ef7b116352de1c75a04b42b6096bed8d87..e18301d69c60dbe8072dcf061beafd57e893da11 100644 +--- a/net/minecraft/world/entity/monster/Phantom.java ++++ b/net/minecraft/world/entity/monster/Phantom.java +@@ -53,6 +53,7 @@ public class Phantom extends FlyingMob implements Enemy { + public java.util.UUID spawningEntity; + public boolean shouldBurnInDay = true; + // Paper end ++ private static final net.minecraft.world.item.crafting.Ingredient TORCH = net.minecraft.world.item.crafting.Ingredient.of(net.minecraft.world.item.Items.TORCH, net.minecraft.world.item.Items.SOUL_TORCH); // Purpur - Phantoms burn in light + + public Phantom(EntityType entityType, Level level) { + super(entityType, level); +@@ -253,7 +254,11 @@ public class Phantom extends FlyingMob implements Enemy { + + @Override + public void aiStep() { +- if (this.isAlive() && this.shouldBurnInDay && this.isSunBurnTick()) { // Paper - shouldBurnInDay API ++ // Purpur start - Phantoms burn in light ++ boolean burnFromDaylight = this.shouldBurnInDay && this.isSunBurnTick() && this.level().purpurConfig.phantomBurnInDaylight; ++ boolean burnFromLightSource = this.level().purpurConfig.phantomBurnInLight > 0 && this.level().getMaxLocalRawBrightness(blockPosition()) >= this.level().purpurConfig.phantomBurnInLight; ++ if (this.isAlive() && (burnFromDaylight || burnFromLightSource)) { // Paper - shouldBurnInDay API ++ // Purpur end - Phantoms burn in light + if (getRider() == null || !this.isControllable()) // Purpur - Ridables + this.igniteForSeconds(8.0F); + } +@@ -370,6 +375,7 @@ public class Phantom extends FlyingMob implements Enemy { + List nearbyPlayers = serverLevel.getNearbyPlayers( + this.attackTargeting, Phantom.this, Phantom.this.getBoundingBox().inflate(16.0, 64.0, 16.0) + ); ++ if (level().purpurConfig.phantomIgnorePlayersWithTorch) nearbyPlayers.removeIf(human -> TORCH.test(human.getItemInHand(net.minecraft.world.InteractionHand.MAIN_HAND)) || TORCH.test(human.getItemInHand(net.minecraft.world.InteractionHand.OFF_HAND))); // Purpur - Phantoms burn in light + if (!nearbyPlayers.isEmpty()) { + nearbyPlayers.sort(Comparator.comparing(Entity::getY).reversed()); + +@@ -735,6 +741,12 @@ public class Phantom extends FlyingMob implements Enemy { + return false; + } else if (!target.isAlive()) { + return false; ++ // Purpur start - Phantoms burn in light ++ } else if (level().purpurConfig.phantomBurnInLight > 0 && level().getLightEmission(new BlockPos(Phantom.this)) >= level().purpurConfig.phantomBurnInLight) { ++ return false; ++ } else if (level().purpurConfig.phantomIgnorePlayersWithTorch && (TORCH.test(target.getItemInHand(net.minecraft.world.InteractionHand.MAIN_HAND)) || TORCH.test(target.getItemInHand(net.minecraft.world.InteractionHand.OFF_HAND)))) { ++ return false; ++ // Purpur end - Phantoms burn in light + } else if (target instanceof Player player && (target.isSpectator() || player.isCreative())) { + return false; + } else if (!this.canUse()) { diff --git a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index db70f7e20..f125ee1d3 100644 --- a/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -1210,6 +1210,9 @@ public class PurpurWorldConfig { public double phantomSpawnLocalDifficultyChance = 3.0D; public int phantomSpawnMinPerAttempt = 1; public int phantomSpawnMaxPerAttempt = -1; + public int phantomBurnInLight = 0; + public boolean phantomIgnorePlayersWithTorch = false; + public boolean phantomBurnInDaylight = true; private void phantomSettings() { phantomRidable = getBoolean("mobs.phantom.ridable", phantomRidable); phantomRidableInWater = getBoolean("mobs.phantom.ridable-in-water", phantomRidableInWater); @@ -1240,6 +1243,9 @@ public class PurpurWorldConfig { phantomSpawnLocalDifficultyChance = getDouble("mobs.phantom.spawn.local-difficulty-chance", phantomSpawnLocalDifficultyChance); phantomSpawnMinPerAttempt = getInt("mobs.phantom.spawn.per-attempt.min", phantomSpawnMinPerAttempt); phantomSpawnMaxPerAttempt = getInt("mobs.phantom.spawn.per-attempt.max", phantomSpawnMaxPerAttempt); + phantomBurnInLight = getInt("mobs.phantom.burn-in-light", phantomBurnInLight); + phantomBurnInDaylight = getBoolean("mobs.phantom.burn-in-daylight", phantomBurnInDaylight); + phantomIgnorePlayersWithTorch = getBoolean("mobs.phantom.ignore-players-with-torch", phantomIgnorePlayersWithTorch); } public boolean pigRidable = false;