mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-06-21 17:57:50 +02:00
55 lines
3.5 KiB
Diff
55 lines
3.5 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/monster/Phantom.java b/net/minecraft/world/entity/monster/Phantom.java
|
|
index d3c9948ee52c0f209481e273bc94b551519a7d71..f2665ff68020cddf921675f4eaa4c0e99c9d9563 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(final EntityType<? extends Phantom> type, final Level level) {
|
|
super(type, level);
|
|
@@ -238,7 +239,11 @@ public class Phantom extends Mob implements Enemy {
|
|
// Paper start
|
|
@Override
|
|
public boolean isSunBurnTick() {
|
|
- return this.shouldBurnInDay && super.isSunBurnTick();
|
|
+ // Purpur start - API for any mob to burn daylight
|
|
+ boolean burnFromDaylight = this.shouldBurnInDay && super.isSunBurnTick() && this.level().purpurConfig.phantomBurnInDaylight;
|
|
+ boolean burnFromLightSource = this.level().purpurConfig.phantomBurnInLight > 0 && this.level().getMaxLocalRawBrightness(blockPosition()) >= this.level().purpurConfig.phantomBurnInLight;
|
|
+ return burnFromDaylight || burnFromLightSource;
|
|
+ // Purpur end - API for any mob to burn daylight
|
|
}
|
|
// Paper end
|
|
|
|
@@ -355,7 +360,8 @@ public class Phantom extends Mob implements Enemy {
|
|
this.nextScanTick = reducedTickDelay(60);
|
|
ServerLevel level = getServerLevel(Phantom.this.level());
|
|
List<Player> players = level.getNearbyPlayers(this.attackTargeting, Phantom.this, Phantom.this.getBoundingBox().inflate(16.0, 64.0, 16.0));
|
|
- if (!players.isEmpty()) {
|
|
+ if (level().purpurConfig.phantomIgnorePlayersWithTorch) players.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 (!players.isEmpty()) {
|
|
players.sort(Comparator.<Player, Double>comparing(Entity::getY).reversed());
|
|
|
|
for (Player player : players) {
|
|
@@ -724,6 +730,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 {
|