Files
Purpur/purpur-server/minecraft-patches/features/0011-Phantoms-burn-in-light.patch
2025-12-04 18:55:42 -08:00

56 lines
3.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: draycia <lonelyyordle@gmail.com>
Date: Sun, 12 Apr 2020 20:41:59 -0700
Subject: [PATCH] Phantoms burn in light
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
index d8faed1fc3ead010f0abd8ffdf3428881472a25c..a3569262099dce237c3feb5e29d24bf47f4c1e38 100644
--- a/net/minecraft/world/entity/Mob.java
+++ b/net/minecraft/world/entity/Mob.java
@@ -581,7 +581,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
}
private void burnUndead() {
- if (this.isAlive() && this.isSunBurnTick()) {
+ // Purpur start - Phantoms burn in light
+ boolean burnFromLightSource = this.level().purpurConfig.phantomBurnInLight > 0 && this instanceof net.minecraft.world.entity.monster.Phantom && this.level().getMaxLocalRawBrightness(blockPosition()) >= this.level().purpurConfig.phantomBurnInLight;
+ if (this.isAlive() && (this.isSunBurnTick() || burnFromLightSource)) {
+ // Purpur end - Phantoms burn in light
EquipmentSlot equipmentSlot = this.sunProtectionSlot();
ItemStack itemBySlot = this.getItemBySlot(equipmentSlot);
if (!itemBySlot.isEmpty()) {
diff --git a/net/minecraft/world/entity/monster/Phantom.java b/net/minecraft/world/entity/monster/Phantom.java
index 7077beafe2251fcc4e37578091bfaa02714268b9..e55470432cebddec43a7d63230eb4391a3d42f8e 100644
--- a/net/minecraft/world/entity/monster/Phantom.java
+++ b/net/minecraft/world/entity/monster/Phantom.java
@@ -54,6 +54,7 @@ public class Phantom extends Mob implements Enemy {
public java.util.@Nullable 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<? extends Phantom> type, Level level) {
super(type, level);
@@ -366,6 +367,7 @@ public class Phantom extends Mob implements Enemy {
List<Player> 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.<Player, Double>comparing(Entity::getY).reversed());
@@ -736,6 +738,12 @@ public class Phantom extends Mob 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()) {