From 7e37e540536578593937c193a7635496dfcffa49 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Fri, 18 Nov 2016 18:55:14 -0600 Subject: [PATCH] Simplify the affects spawning API implementation Get the hell away from EntitySelectors, not that that one right anyway Fixes GH-482 --- Spigot-Server-Patches/0003-MC-Dev-fixes.patch | 62 +---------------- .../0017-Player-affects-spawning-API.patch | 66 ++++++++++++------- scripts/importmcdev.sh | 1 - 3 files changed, 44 insertions(+), 85 deletions(-) diff --git a/Spigot-Server-Patches/0003-MC-Dev-fixes.patch b/Spigot-Server-Patches/0003-MC-Dev-fixes.patch index f02323521f..74c5e9cac8 100644 --- a/Spigot-Server-Patches/0003-MC-Dev-fixes.patch +++ b/Spigot-Server-Patches/0003-MC-Dev-fixes.patch @@ -1,4 +1,4 @@ -From 3feb3accfd0afbeb9d2896bf9f1561dab0959fb7 Mon Sep 17 00:00:00 2001 +From ac03240e79862b55067a1317bea4ab1a14ab9a95 Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 30 Mar 2016 19:36:20 -0400 Subject: [PATCH] MC Dev fixes @@ -83,66 +83,6 @@ index fe74068..b669884 100644 return this.a((ICommand) object); } -diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java -index dc0ffd8..ec75cf3 100644 ---- a/src/main/java/net/minecraft/server/IEntitySelector.java -+++ b/src/main/java/net/minecraft/server/IEntitySelector.java -@@ -61,7 +61,7 @@ public final class IEntitySelector { - } - - public boolean apply(@Nullable Object object) { -- return this.a((Entity) object); -+ return this.a((T) object); // Paper - Fix decompile error - } - }; - } -@@ -71,7 +71,7 @@ public final class IEntitySelector { - final ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteambase == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteambase.getCollisionRule(); - - return scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : Predicates.and(IEntitySelector.e, new Predicate() { -- public boolean a(@Nullable Entity entity) { -+ public boolean a(@Nullable Entity entity1) { // Paper - fix decompile error - if (!entity.isCollidable()) { - return false; - } else if (entity1.world.isClientSide && (!(entity instanceof EntityHuman) || !((EntityHuman) entity).cR())) { -@@ -83,9 +83,10 @@ public final class IEntitySelector { - if (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER) { - return false; - } else { -- boolean flag = scoreboardteambase1 != null && scoreboardteambase1.isAlly(scoreboardteambase); -+ boolean flag = scoreboardteambase != null && scoreboardteambase.isAlly(scoreboardteambase); // Paper - fix decompile error - -- return (scoreboardteambase_enumteampush1 == ScoreboardTeamBase.EnumTeamPush.HIDE_FOR_OWN_TEAM || scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.HIDE_FOR_OWN_TEAM) && flag ? false : scoreboardteambase_enumteampush1 != ScoreboardTeamBase.EnumTeamPush.HIDE_FOR_OTHER_TEAMS && scoreboardteambase_enumteampush != ScoreboardTeamBase.EnumTeamPush.HIDE_FOR_OTHER_TEAMS || flag; -+ // Paper - fix decompiler error -+ return (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.HIDE_FOR_OWN_TEAM || scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.HIDE_FOR_OWN_TEAM) && flag ? false : scoreboardteambase_enumteampush != ScoreboardTeamBase.EnumTeamPush.HIDE_FOR_OTHER_TEAMS && scoreboardteambase_enumteampush != ScoreboardTeamBase.EnumTeamPush.HIDE_FOR_OTHER_TEAMS || flag; - } - } - } -@@ -98,10 +99,12 @@ public final class IEntitySelector { - - public static Predicate b(final Entity entity) { - return new Predicate() { -- public boolean a(@Nullable Entity entity) { -+ public boolean a(@Nullable Entity entity1) { // Paper - fix decompile error - while (true) { -- if (entity.isPassenger()) { -- entity = entity.bB(); -+ // Paper start - fix decompile error - entity -> entity1 - double check this -+ if (entity1.isPassenger()) { -+ entity1 = entity.bB(); -+ // Paper end - if (entity != entity1) { - continue; - } -@@ -139,7 +142,7 @@ public final class IEntitySelector { - } - } - -- public boolean apply(@Nullable Object object) { -+ public boolean apply(@Nullable Entity object) { - return this.a((Entity) object); - } - } diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java index f5bcbdb..3190cad 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java diff --git a/Spigot-Server-Patches/0017-Player-affects-spawning-API.patch b/Spigot-Server-Patches/0017-Player-affects-spawning-API.patch index 923c9f1d33..e4dd6e9bc0 100644 --- a/Spigot-Server-Patches/0017-Player-affects-spawning-API.patch +++ b/Spigot-Server-Patches/0017-Player-affects-spawning-API.patch @@ -1,43 +1,50 @@ -From 3c03eaa436c6bba260c5bde3eb2acaf58476e1ef Mon Sep 17 00:00:00 2001 +From 7e906e2d453bbdae56d399a03f9e3f5f640d15c8 Mon Sep 17 00:00:00 2001 From: Jedediah Smith Date: Tue, 1 Mar 2016 14:47:52 -0600 Subject: [PATCH] Player affects spawning API diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java -index 9f115d1..ae86ebc 100644 +index 9f115d1..e9757d1 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -63,6 +63,7 @@ public abstract class EntityHuman extends EntityLiving { private final ItemCooldown bV; @Nullable public EntityFishingHook hookedFish; -+ public boolean affectsSpawning = true; // Paper - AffectsSpawning API ++ public boolean affectsSpawning = true; // CraftBukkit start public boolean fauxSleeping; -diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java -index dc0ffd8..f04aecb 100644 ---- a/src/main/java/net/minecraft/server/IEntitySelector.java -+++ b/src/main/java/net/minecraft/server/IEntitySelector.java -@@ -44,13 +44,14 @@ public final class IEntitySelector { - }; - public static final Predicate e = new Predicate() { - public boolean a(@Nullable Entity entity) { -- return !(entity instanceof EntityHuman) || !((EntityHuman) entity).isSpectator(); -+ return !(entity instanceof EntityHuman) || !((EntityHuman) entity).isSpectator() || !((EntityHuman) entity).affectsSpawning; // Paper - Affects Spawning API - } +diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java +index 3f7eae1..a8f3645 100644 +--- a/src/main/java/net/minecraft/server/EntityInsentient.java ++++ b/src/main/java/net/minecraft/server/EntityInsentient.java +@@ -617,7 +617,7 @@ public abstract class EntityInsentient extends EntityLiving { + } else { + EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D); - public boolean apply(@Nullable Object object) { - return this.a((Entity) object); +- if (entityhuman != null) { ++ if (entityhuman != null && entityhuman.affectsSpawning) { // Paper - Affects Spawning API + double d0 = entityhuman.locX - this.locX; + double d1 = entityhuman.locY - this.locY; + double d2 = entityhuman.locZ - this.locZ; +diff --git a/src/main/java/net/minecraft/server/EntitySilverfish.java b/src/main/java/net/minecraft/server/EntitySilverfish.java +index fce2498..e2423c2 100644 +--- a/src/main/java/net/minecraft/server/EntitySilverfish.java ++++ b/src/main/java/net/minecraft/server/EntitySilverfish.java +@@ -99,8 +99,7 @@ public class EntitySilverfish extends EntityMonster { + public boolean cM() { + if (super.cM()) { + EntityHuman entityhuman = this.world.b(this, 5.0D); +- +- return entityhuman == null; ++ return !(entityhuman != null && !entityhuman.affectsSpawning) && entityhuman == null; // Paper - Affects Spawning API + } else { + return false; } - }; -+ public static final Predicate CAN_MOBS_TARGET = e; // Paper - OBFHELPER - - public static Predicate a(final double d0, final double d1, final double d2, double d3) { - final double d4 = d3 * d3; diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java -index bec25e4..171410e 100644 +index bec25e4..30aacc9 100644 --- a/src/main/java/net/minecraft/server/SpawnerCreature.java +++ b/src/main/java/net/minecraft/server/SpawnerCreature.java @@ -52,7 +52,7 @@ public final class SpawnerCreature { @@ -45,10 +52,23 @@ index bec25e4..171410e 100644 EntityHuman entityhuman = (EntityHuman) iterator.next(); - if (!entityhuman.isSpectator()) { -+ if (!entityhuman.isSpectator() && entityhuman.affectsSpawning) { // Paper - AffectsSpawning API ++ if (!entityhuman.isSpectator() && entityhuman.affectsSpawning) { int l = MathHelper.floor(entityhuman.locX / 16.0D); j = MathHelper.floor(entityhuman.locZ / 16.0D); +diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java +index 52171a3..3d70c50 100644 +--- a/src/main/java/net/minecraft/server/World.java ++++ b/src/main/java/net/minecraft/server/World.java +@@ -2750,7 +2750,7 @@ public abstract class World implements IBlockAccess { + for (int i = 0; i < this.players.size(); ++i) { + EntityHuman entityhuman = (EntityHuman) this.players.get(i); + +- if (IEntitySelector.e.apply(entityhuman)) { ++ if (IEntitySelector.e.apply(entityhuman) && entityhuman.affectsSpawning) { // Paper - Affects Spawning API + double d4 = entityhuman.d(d0, d1, d2); + + if (d3 < 0.0D || d4 < d3 * d3) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 3784c32..3bda255 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index 927f1de1a5..13a7d13345 100755 --- a/scripts/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -61,7 +61,6 @@ import EULA import EntitySquid import EntityWaterAnimal import FileIOThread -import IEntitySelector import IHopper import ItemBlock import ItemMonsterEgg