mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Simplify the affects spawning API implementation
Get the hell away from EntitySelectors, not that that one right anyway Fixes GH-482
This commit is contained in:
parent
a6d146a939
commit
7e37e54053
3 changed files with 44 additions and 85 deletions
|
@ -1,4 +1,4 @@
|
||||||
From 3feb3accfd0afbeb9d2896bf9f1561dab0959fb7 Mon Sep 17 00:00:00 2001
|
From ac03240e79862b55067a1317bea4ab1a14ab9a95 Mon Sep 17 00:00:00 2001
|
||||||
From: Aikar <aikar@aikar.co>
|
From: Aikar <aikar@aikar.co>
|
||||||
Date: Wed, 30 Mar 2016 19:36:20 -0400
|
Date: Wed, 30 Mar 2016 19:36:20 -0400
|
||||||
Subject: [PATCH] MC Dev fixes
|
Subject: [PATCH] MC Dev fixes
|
||||||
|
@ -83,66 +83,6 @@ index fe74068..b669884 100644
|
||||||
return this.a((ICommand) object);
|
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<Entity> 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
|
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
|
index f5bcbdb..3190cad 100644
|
||||||
--- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java
|
--- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java
|
||||||
|
|
|
@ -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 <jedediah@silencegreys.com>
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
||||||
Date: Tue, 1 Mar 2016 14:47:52 -0600
|
Date: Tue, 1 Mar 2016 14:47:52 -0600
|
||||||
Subject: [PATCH] Player affects spawning API
|
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
|
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
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
||||||
+++ b/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 {
|
@@ -63,6 +63,7 @@ public abstract class EntityHuman extends EntityLiving {
|
||||||
private final ItemCooldown bV;
|
private final ItemCooldown bV;
|
||||||
@Nullable
|
@Nullable
|
||||||
public EntityFishingHook hookedFish;
|
public EntityFishingHook hookedFish;
|
||||||
+ public boolean affectsSpawning = true; // Paper - AffectsSpawning API
|
+ public boolean affectsSpawning = true;
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
public boolean fauxSleeping;
|
public boolean fauxSleeping;
|
||||||
diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java
|
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||||
index dc0ffd8..f04aecb 100644
|
index 3f7eae1..a8f3645 100644
|
||||||
--- a/src/main/java/net/minecraft/server/IEntitySelector.java
|
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||||
+++ b/src/main/java/net/minecraft/server/IEntitySelector.java
|
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||||
@@ -44,13 +44,14 @@ public final class IEntitySelector {
|
@@ -617,7 +617,7 @@ public abstract class EntityInsentient extends EntityLiving {
|
||||||
};
|
} else {
|
||||||
public static final Predicate<Entity> e = new Predicate() {
|
EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D);
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean apply(@Nullable Object object) {
|
- if (entityhuman != null) {
|
||||||
return this.a((Entity) object);
|
+ 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<Entity> CAN_MOBS_TARGET = e; // Paper - OBFHELPER
|
|
||||||
|
|
||||||
public static <T extends Entity> Predicate<T> 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
|
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
|
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||||
+++ b/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 {
|
@@ -52,7 +52,7 @@ public final class SpawnerCreature {
|
||||||
|
@ -45,10 +52,23 @@ index bec25e4..171410e 100644
|
||||||
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
||||||
|
|
||||||
- if (!entityhuman.isSpectator()) {
|
- if (!entityhuman.isSpectator()) {
|
||||||
+ if (!entityhuman.isSpectator() && entityhuman.affectsSpawning) { // Paper - AffectsSpawning API
|
+ if (!entityhuman.isSpectator() && entityhuman.affectsSpawning) {
|
||||||
int l = MathHelper.floor(entityhuman.locX / 16.0D);
|
int l = MathHelper.floor(entityhuman.locX / 16.0D);
|
||||||
|
|
||||||
j = MathHelper.floor(entityhuman.locZ / 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
|
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
|
index 3784c32..3bda255 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||||
|
|
|
@ -61,7 +61,6 @@ import EULA
|
||||||
import EntitySquid
|
import EntitySquid
|
||||||
import EntityWaterAnimal
|
import EntityWaterAnimal
|
||||||
import FileIOThread
|
import FileIOThread
|
||||||
import IEntitySelector
|
|
||||||
import IHopper
|
import IHopper
|
||||||
import ItemBlock
|
import ItemBlock
|
||||||
import ItemMonsterEgg
|
import ItemMonsterEgg
|
||||||
|
|
Loading…
Reference in a new issue