2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-04-25 20:33:18 +00:00
|
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
|
|
Date: Sat, 25 Apr 2020 15:13:41 -0500
|
|
|
|
Subject: [PATCH] Add phantom creative and insomniac controls
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2020-06-27 04:57:36 +00:00
|
|
|
index e4821d4c23689aaf51b60c66fc1e6bc7a0b02fd5..5785f24b0646f8dbf3fba0bbc3b3e5b93e02f162 100644
|
2020-04-25 20:33:18 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2020-06-27 04:57:36 +00:00
|
|
|
@@ -627,4 +627,11 @@ public class PaperWorldConfig {
|
2020-04-25 20:33:18 +00:00
|
|
|
private void lightQueueSize() {
|
|
|
|
lightQueueSize = getInt("light-queue-size", lightQueueSize);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public boolean phantomIgnoreCreative = true;
|
|
|
|
+ public boolean phantomOnlyAttackInsomniacs = true;
|
|
|
|
+ private void phantomSettings() {
|
|
|
|
+ phantomIgnoreCreative = getBoolean("phantoms-do-not-spawn-on-creative-players", phantomIgnoreCreative);
|
|
|
|
+ phantomOnlyAttackInsomniacs = getBoolean("phantoms-only-attack-insomniacs", phantomOnlyAttackInsomniacs);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityPhantom.java b/src/main/java/net/minecraft/server/EntityPhantom.java
|
2020-06-26 01:53:21 +00:00
|
|
|
index 47d82722e15c5b91a86af1a09807ccc37a1b37be..3cb78924daa48c3a0a3e5c9c64ef6e726d79a798 100644
|
2020-04-25 20:33:18 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityPhantom.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityPhantom.java
|
2020-06-26 01:53:21 +00:00
|
|
|
@@ -225,6 +225,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
2020-04-25 20:33:18 +00:00
|
|
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
|
|
|
|
|
|
|
if (EntityPhantom.this.a((EntityLiving) entityhuman, PathfinderTargetCondition.a)) {
|
|
|
|
+ if (!world.paperConfig.phantomOnlyAttackInsomniacs || IEntitySelector.isInsomniac.test(entityhuman)) // Paper
|
|
|
|
EntityPhantom.this.setGoalTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java
|
2020-06-26 01:53:21 +00:00
|
|
|
index 57bc56cffff87d9b1774cec455af8d1651fb882c..a52dd0c021e264a57a62bde27ea9d2a6a97e2335 100644
|
2020-04-25 20:33:18 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/IEntitySelector.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/IEntitySelector.java
|
2020-06-26 01:53:21 +00:00
|
|
|
@@ -26,6 +26,7 @@ public final class IEntitySelector {
|
|
|
|
public static final Predicate<Entity> g = (entity) -> {
|
2020-04-25 20:33:18 +00:00
|
|
|
return !entity.isSpectator();
|
|
|
|
};
|
|
|
|
+ public static Predicate<EntityHuman> isInsomniac = (player) -> MathHelper.clamp(((EntityPlayer) player).getStatisticManager().getStatisticValue(StatisticList.CUSTOM.get(StatisticList.TIME_SINCE_REST)), 1, Integer.MAX_VALUE) >= 72000; // Paper
|
|
|
|
|
2020-06-26 01:53:21 +00:00
|
|
|
// Paper start
|
|
|
|
public static final Predicate<Entity> affectsSpawning = (entity) -> {
|
2020-04-25 20:33:18 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/MobSpawnerPhantom.java b/src/main/java/net/minecraft/server/MobSpawnerPhantom.java
|
2020-06-26 01:53:21 +00:00
|
|
|
index 39c5350373f6a5ad30f41e8886573d6b315924c6..bf4fa17101cb8710d8b8ba8ad43f98b6fe154ae1 100644
|
2020-04-25 20:33:18 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/MobSpawnerPhantom.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MobSpawnerPhantom.java
|
2020-06-26 01:53:21 +00:00
|
|
|
@@ -32,7 +32,7 @@ public class MobSpawnerPhantom implements MobSpawner {
|
2020-04-25 20:33:18 +00:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
|
|
|
|
|
|
|
- if (!entityhuman.isSpectator()) {
|
|
|
|
+ if (!entityhuman.isSpectator() && (!worldserver.paperConfig.phantomIgnoreCreative || !entityhuman.isCreative())) { // Paper
|
2020-06-26 01:53:21 +00:00
|
|
|
BlockPosition blockposition = entityhuman.getChunkCoordinates();
|
2020-04-25 20:33:18 +00:00
|
|
|
|
2020-06-26 01:53:21 +00:00
|
|
|
if (!worldserver.getDimensionManager().hasSkyLight() || blockposition.getY() >= worldserver.getSeaLevel() && worldserver.f(blockposition)) {
|