Skip to content

Commit f39e848

Browse files
committed
port Phantoms burn in light patch
1 parent 1577f71 commit f39e848

3 files changed

Lines changed: 58 additions & 76 deletions

File tree

patches/server/0073-Phantoms-burn-in-light.patch

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: draycia <lonelyyordle@gmail.com>
3+
Date: Sun, 12 Apr 2020 20:41:59 -0700
4+
Subject: [PATCH] Phantoms burn in light
5+
6+
7+
diff --git a/net/minecraft/world/entity/monster/Phantom.java b/net/minecraft/world/entity/monster/Phantom.java
8+
index 438f09ef7b116352de1c75a04b42b6096bed8d87..e18301d69c60dbe8072dcf061beafd57e893da11 100644
9+
--- a/net/minecraft/world/entity/monster/Phantom.java
10+
+++ b/net/minecraft/world/entity/monster/Phantom.java
11+
@@ -53,6 +53,7 @@ public class Phantom extends FlyingMob implements Enemy {
12+
public java.util.UUID spawningEntity;
13+
public boolean shouldBurnInDay = true;
14+
// Paper end
15+
+ 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
16+
17+
public Phantom(EntityType<? extends Phantom> entityType, Level level) {
18+
super(entityType, level);
19+
@@ -253,7 +254,11 @@ public class Phantom extends FlyingMob implements Enemy {
20+
21+
@Override
22+
public void aiStep() {
23+
- if (this.isAlive() && this.shouldBurnInDay && this.isSunBurnTick()) { // Paper - shouldBurnInDay API
24+
+ // Purpur start - Phantoms burn in light
25+
+ boolean burnFromDaylight = this.shouldBurnInDay && this.isSunBurnTick() && this.level().purpurConfig.phantomBurnInDaylight;
26+
+ boolean burnFromLightSource = this.level().purpurConfig.phantomBurnInLight > 0 && this.level().getMaxLocalRawBrightness(blockPosition()) >= this.level().purpurConfig.phantomBurnInLight;
27+
+ if (this.isAlive() && (burnFromDaylight || burnFromLightSource)) { // Paper - shouldBurnInDay API
28+
+ // Purpur end - Phantoms burn in light
29+
if (getRider() == null || !this.isControllable()) // Purpur - Ridables
30+
this.igniteForSeconds(8.0F);
31+
}
32+
@@ -370,6 +375,7 @@ public class Phantom extends FlyingMob implements Enemy {
33+
List<Player> nearbyPlayers = serverLevel.getNearbyPlayers(
34+
this.attackTargeting, Phantom.this, Phantom.this.getBoundingBox().inflate(16.0, 64.0, 16.0)
35+
);
36+
+ 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
37+
if (!nearbyPlayers.isEmpty()) {
38+
nearbyPlayers.sort(Comparator.<Player, Double>comparing(Entity::getY).reversed());
39+
40+
@@ -735,6 +741,12 @@ public class Phantom extends FlyingMob implements Enemy {
41+
return false;
42+
} else if (!target.isAlive()) {
43+
return false;
44+
+ // Purpur start - Phantoms burn in light
45+
+ } else if (level().purpurConfig.phantomBurnInLight > 0 && level().getLightEmission(new BlockPos(Phantom.this)) >= level().purpurConfig.phantomBurnInLight) {
46+
+ return false;
47+
+ } 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)))) {
48+
+ return false;
49+
+ // Purpur end - Phantoms burn in light
50+
} else if (target instanceof Player player && (target.isSpectator() || player.isCreative())) {
51+
return false;
52+
} else if (!this.canUse()) {

purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,9 @@ private void parrotSettings() {
12101210
public double phantomSpawnLocalDifficultyChance = 3.0D;
12111211
public int phantomSpawnMinPerAttempt = 1;
12121212
public int phantomSpawnMaxPerAttempt = -1;
1213+
public int phantomBurnInLight = 0;
1214+
public boolean phantomIgnorePlayersWithTorch = false;
1215+
public boolean phantomBurnInDaylight = true;
12131216
private void phantomSettings() {
12141217
phantomRidable = getBoolean("mobs.phantom.ridable", phantomRidable);
12151218
phantomRidableInWater = getBoolean("mobs.phantom.ridable-in-water", phantomRidableInWater);
@@ -1240,6 +1243,9 @@ private void phantomSettings() {
12401243
phantomSpawnLocalDifficultyChance = getDouble("mobs.phantom.spawn.local-difficulty-chance", phantomSpawnLocalDifficultyChance);
12411244
phantomSpawnMinPerAttempt = getInt("mobs.phantom.spawn.per-attempt.min", phantomSpawnMinPerAttempt);
12421245
phantomSpawnMaxPerAttempt = getInt("mobs.phantom.spawn.per-attempt.max", phantomSpawnMaxPerAttempt);
1246+
phantomBurnInLight = getInt("mobs.phantom.burn-in-light", phantomBurnInLight);
1247+
phantomBurnInDaylight = getBoolean("mobs.phantom.burn-in-daylight", phantomBurnInDaylight);
1248+
phantomIgnorePlayersWithTorch = getBoolean("mobs.phantom.ignore-players-with-torch", phantomIgnorePlayersWithTorch);
12431249
}
12441250

12451251
public boolean pigRidable = false;

0 commit comments

Comments
 (0)