mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-03 06:40:19 +08:00
70 lines
4.5 KiB
Diff
70 lines
4.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
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
|
|
index cd248eb6be663e8be33f2c3c6b06b77b6d5753a4..46ac6d91422423f1e03b86d3efa3241f2599000d 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -625,4 +625,11 @@ public class PaperWorldConfig {
|
|
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/world/entity/IEntitySelector.java b/src/main/java/net/minecraft/world/entity/IEntitySelector.java
|
|
index 1a6f8aec32af85717f5d56e0b00a02cda88ce028..c8d7ea8cfa4945af4a6675172b931a4cc3ca2801 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/IEntitySelector.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/IEntitySelector.java
|
|
@@ -3,6 +3,9 @@ package net.minecraft.world.entity;
|
|
import com.google.common.base.Predicates;
|
|
import java.util.function.Predicate;
|
|
import javax.annotation.Nullable;
|
|
+import net.minecraft.server.level.EntityPlayer;
|
|
+import net.minecraft.stats.StatisticList;
|
|
+import net.minecraft.util.MathHelper;
|
|
import net.minecraft.world.EnumDifficulty;
|
|
import net.minecraft.world.IInventory;
|
|
import net.minecraft.world.entity.player.EntityHuman;
|
|
@@ -31,6 +34,7 @@ public final class IEntitySelector {
|
|
public static final Predicate<Entity> g = (entity) -> {
|
|
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
|
|
|
|
// Paper start
|
|
public static final Predicate<Entity> affectsSpawning = (entity) -> {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/EntityPhantom.java b/src/main/java/net/minecraft/world/entity/monster/EntityPhantom.java
|
|
index 6c498d4345df35a411d155799ac56e47c9c48114..42cf3fa42b73739182d26fbb524ee5b304c799b2 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/EntityPhantom.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityPhantom.java
|
|
@@ -262,6 +262,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
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/world/level/levelgen/MobSpawnerPhantom.java b/src/main/java/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java
|
|
index 96a5a6569387a25b15a06aaab3bd9d033547e875..e4f5e570636862481aac92ec9b74d6cf5723eb6e 100644
|
|
--- a/src/main/java/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java
|
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java
|
|
@@ -53,7 +53,7 @@ public class MobSpawnerPhantom implements MobSpawner {
|
|
while (iterator.hasNext()) {
|
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
|
|
|
- if (!entityhuman.isSpectator()) {
|
|
+ if (!entityhuman.isSpectator() && (!worldserver.paperConfig.phantomIgnoreCreative || !entityhuman.isCreative())) { // Paper
|
|
BlockPosition blockposition = entityhuman.getChunkCoordinates();
|
|
|
|
if (!worldserver.getDimensionManager().hasSkyLight() || blockposition.getY() >= worldserver.getSeaLevel() && worldserver.e(blockposition)) {
|