mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +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
4832b1a385
commit
2b8aa1a8f2
3 changed files with 39 additions and 80 deletions
|
@ -83,66 +83,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/IEntitySelector.java
|
||||
+++ b/src/main/java/net/minecraft/server/IEntitySelector.java
|
||||
@@ -0,0 +0,0 @@ public final class IEntitySelector {
|
||||
}
|
||||
|
||||
public boolean apply(@Nullable Object object) {
|
||||
- return this.a((Entity) object);
|
||||
+ return this.a((T) object); // Paper - Fix decompile error
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +0,0 @@ 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())) {
|
||||
@@ -0,0 +0,0 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +0,0 @@ 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;
|
||||
}
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java
|
||||
|
|
|
@ -12,30 +12,37 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
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
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/IEntitySelector.java
|
||||
+++ b/src/main/java/net/minecraft/server/IEntitySelector.java
|
||||
@@ -0,0 +0,0 @@ public final class IEntitySelector {
|
||||
};
|
||||
public static final Predicate<Entity> 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
|
||||
}
|
||||
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntitySilverfish.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntitySilverfish.java
|
||||
@@ -0,0 +0,0 @@ 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
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||
|
@ -45,10 +52,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
|
|
|
@ -61,7 +61,6 @@ import EULA
|
|||
import EntitySquid
|
||||
import EntityWaterAnimal
|
||||
import FileIOThread
|
||||
import IEntitySelector
|
||||
import IHopper
|
||||
import ItemBlock
|
||||
import ItemMonsterEgg
|
||||
|
|
Loading…
Reference in a new issue