mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 17:37:42 +01:00
58 lines
3.4 KiB
Diff
58 lines
3.4 KiB
Diff
From a44f4c1e877acf7424367aec36a4c18d84d01bdc Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Fri, 29 Nov 2019 20:33:41 -0600
|
|
Subject: [PATCH] Phantoms only attack insomniacs
|
|
|
|
---
|
|
src/main/java/net/minecraft/server/EntityPhantom.java | 1 +
|
|
src/main/java/net/minecraft/server/IEntitySelector.java | 1 +
|
|
src/main/java/net/pl3x/purpur/PurpurWorldConfig.java | 2 ++
|
|
3 files changed, 4 insertions(+)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityPhantom.java b/src/main/java/net/minecraft/server/EntityPhantom.java
|
|
index c3a5e24617..6d2984c8d5 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPhantom.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPhantom.java
|
|
@@ -272,6 +272,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
|
|
|
if (EntityPhantom.this.a((EntityLiving) entityhuman, PathfinderTargetCondition.a)) {
|
|
+ if (!world.purpurConfig.phantomOnlyAttackInsomniacs || IEntitySelector.isInsomniac.test(entityhuman)) // Purpur
|
|
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
|
|
index a2d1ef3602..e1fdee2794 100644
|
|
--- a/src/main/java/net/minecraft/server/IEntitySelector.java
|
|
+++ b/src/main/java/net/minecraft/server/IEntitySelector.java
|
|
@@ -23,6 +23,7 @@ public final class IEntitySelector {
|
|
public static final Predicate<Entity> f = (entity) -> {
|
|
return !entity.isSpectator();
|
|
};
|
|
+ public static Predicate<EntityHuman> isInsomniac = (player) -> MathHelper.clamp(((EntityPlayer) player).getStatisticManager().getStatisticValue(StatisticList.CUSTOM.b(StatisticList.TIME_SINCE_REST)), 1, Integer.MAX_VALUE) >= 72000; // Purpur
|
|
|
|
public static Predicate<Entity> a(double d0, double d1, double d2, double d3) {
|
|
double d4 = d3 * d3;
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 9cd1a32ed8..9ae372d7d0 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -397,12 +397,14 @@ public class PurpurWorldConfig {
|
|
public boolean phantomRequireShiftToMount = true;
|
|
public double phantomMaxY = 256D;
|
|
public boolean phantomIgnoreCreative = false;
|
|
+ public boolean phantomOnlyAttackInsomniacs = false;
|
|
private void phantomSettings() {
|
|
phantomRidable = getBoolean("mobs.phantom.ridable", phantomRidable);
|
|
phantomRidableInWater = getBoolean("mobs.phantom.ridable-in-water", phantomRidableInWater);
|
|
phantomRequireShiftToMount = getBoolean("mobs.phantom.require-shift-to-mount", phantomRequireShiftToMount);
|
|
phantomMaxY = getDouble("mobs.phantom.ridable-max-y", phantomMaxY);
|
|
phantomIgnoreCreative = getBoolean("mobs.phantom.do-not-spawn-on-creative-players", phantomIgnoreCreative);
|
|
+ phantomOnlyAttackInsomniacs = getBoolean("mobs.phantom.only-attack-insomniacs", phantomOnlyAttackInsomniacs);
|
|
}
|
|
|
|
public boolean pigRidable = false;
|
|
--
|
|
2.24.0
|
|
|