mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-31 20:22:05 -07: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:
@@ -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
|
||||
|
Reference in New Issue
Block a user