2020-04-25 22:33:18 +02:00
|
|
|
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
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2020-04-25 22:33:18 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
@@ -0,0 +0,0 @@ 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);
|
|
|
|
+ }
|
|
|
|
}
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/IEntitySelector.java b/src/main/java/net/minecraft/world/entity/IEntitySelector.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/IEntitySelector.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/IEntitySelector.java
|
2021-03-16 16:50:45 +01:00
|
|
|
@@ -0,0 +0,0 @@ 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;
|
2020-04-25 22:33:18 +02:00
|
|
|
@@ -0,0 +0,0 @@ public final class IEntitySelector {
|
2020-06-26 03:53:21 +02:00
|
|
|
public static final Predicate<Entity> g = (entity) -> {
|
2020-04-25 22:33:18 +02: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 03:53:21 +02:00
|
|
|
// Paper start
|
|
|
|
public static final Predicate<Entity> affectsSpawning = (entity) -> {
|
2021-03-16 08:19:45 +01:00
|
|
|
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/EntityPhantom.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityPhantom.java
|
|
|
|
@@ -0,0 +0,0 @@ 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
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/MobSpawnerPhantom.java
|
2020-06-26 03:53:21 +02:00
|
|
|
@@ -0,0 +0,0 @@ public class MobSpawnerPhantom implements MobSpawner {
|
2020-04-25 22:33:18 +02:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
|
|
|
|
|
|
|
- if (!entityhuman.isSpectator()) {
|
|
|
|
+ if (!entityhuman.isSpectator() && (!worldserver.paperConfig.phantomIgnoreCreative || !entityhuman.isCreative())) { // Paper
|
2020-06-26 03:53:21 +02:00
|
|
|
BlockPosition blockposition = entityhuman.getChunkCoordinates();
|
2020-04-25 22:33:18 +02:00
|
|
|
|
2020-08-25 04:22:08 +02:00
|
|
|
if (!worldserver.getDimensionManager().hasSkyLight() || blockposition.getY() >= worldserver.getSeaLevel() && worldserver.e(blockposition)) {
|