2016-03-08 05:54:14 +08:00
|
|
|
From 35e02674a6ff73cbeb7fa49e7048f74baeef5be8 Mon Sep 17 00:00:00 2001
|
2015-05-19 08:22:48 +08:00
|
|
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
2016-03-01 07:09:49 +08:00
|
|
|
Date: Tue, 1 Mar 2016 14:47:52 -0600
|
2014-11-28 09:17:45 +08:00
|
|
|
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
|
2016-03-03 17:46:26 +08:00
|
|
|
index 7b7025f..9534bf9 100644
|
2014-11-28 09:17:45 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
2016-03-01 07:09:49 +08:00
|
|
|
@@ -63,6 +63,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|
|
|
private ItemStack bT = null;
|
|
|
|
private final ItemCooldown bU = this.l();
|
2014-11-28 09:17:45 +08:00
|
|
|
public EntityFishingHook hookedFish;
|
2016-03-01 07:09:49 +08:00
|
|
|
+ public boolean affectsSpawning = true; // Paper
|
2015-03-08 09:16:09 +08:00
|
|
|
|
2014-11-28 09:17:45 +08:00
|
|
|
// CraftBukkit start
|
|
|
|
public boolean fauxSleeping;
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
|
2016-03-08 05:54:14 +08:00
|
|
|
index c0215e2..2df5f15 100644
|
2014-11-28 09:17:45 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
2016-03-08 05:54:14 +08:00
|
|
|
@@ -593,7 +593,7 @@ public abstract class EntityInsentient extends EntityLiving {
|
2014-11-28 09:17:45 +08:00
|
|
|
if (this.persistent) {
|
2015-03-08 09:16:09 +08:00
|
|
|
this.ticksFarFromPlayer = 0;
|
2014-11-28 09:17:45 +08:00
|
|
|
} else {
|
|
|
|
- EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D);
|
2016-03-01 07:09:49 +08:00
|
|
|
+ EntityHuman entityhuman = this.world.findNearbyPlayerWhoAffectsSpawning(this, -1.0D); // Paper - Affects Spawning API
|
2014-11-28 09:17:45 +08:00
|
|
|
|
|
|
|
if (entityhuman != null) {
|
|
|
|
double d0 = entityhuman.locX - this.locX;
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
2016-03-03 17:46:26 +08:00
|
|
|
index a7903a2..2eee845 100644
|
2014-11-28 09:17:45 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
2016-03-01 07:09:49 +08:00
|
|
|
@@ -32,7 +32,7 @@ public abstract class MobSpawnerAbstract {
|
|
|
|
private boolean h() {
|
2014-11-28 09:17:45 +08:00
|
|
|
BlockPosition blockposition = this.b();
|
|
|
|
|
|
|
|
- return this.a().isPlayerNearby((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, (double) this.requiredPlayerRange);
|
2016-03-01 07:09:49 +08:00
|
|
|
+ return this.a().isPlayerNearbyWhoAffectsSpawning((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, (double) this.requiredPlayerRange); // Paper - Affects spawning API
|
2014-11-28 09:17:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void c() {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
2016-03-01 07:09:49 +08:00
|
|
|
index 9e19dfd..b724586 100644
|
2014-11-28 09:17:45 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
2016-03-01 07:09:49 +08:00
|
|
|
@@ -50,7 +50,7 @@ public final class SpawnerCreature {
|
2014-11-28 09:17:45 +08:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
|
|
|
|
2015-05-19 07:41:57 +08:00
|
|
|
- if (!entityhuman.isSpectator()) {
|
2016-03-01 07:09:49 +08:00
|
|
|
+ if (!entityhuman.isSpectator() || !entityhuman.affectsSpawning) {
|
2014-11-28 09:17:45 +08:00
|
|
|
int l = MathHelper.floor(entityhuman.locX / 16.0D);
|
|
|
|
|
|
|
|
j = MathHelper.floor(entityhuman.locZ / 16.0D);
|
2016-03-01 07:09:49 +08:00
|
|
|
@@ -160,7 +160,7 @@ public final class SpawnerCreature {
|
2014-11-28 09:17:45 +08:00
|
|
|
float f = (float) j3 + 0.5F;
|
|
|
|
float f1 = (float) l3 + 0.5F;
|
|
|
|
|
2016-03-01 07:09:49 +08:00
|
|
|
- if (!worldserver.isPlayerNearby((double) f, (double) k3, (double) f1, 24.0D) && blockposition.distanceSquared((double) f, (double) k3, (double) f1) >= 576.0D) {
|
|
|
|
+ if (!worldserver.isPlayerNearbyWhoAffectsSpawning((double) f, (double) k3, (double) f1, 24.0D) && blockposition.distanceSquared((double) f, (double) k3, (double) f1) >= 576.0D) {
|
2015-03-08 09:16:09 +08:00
|
|
|
if (biomebase_biomemeta == null) {
|
2016-03-01 07:09:49 +08:00
|
|
|
biomebase_biomemeta = worldserver.a(enumcreaturetype, (BlockPosition) blockposition_mutableblockposition);
|
2015-03-08 09:16:09 +08:00
|
|
|
if (biomebase_biomemeta == null) {
|
2014-11-28 09:17:45 +08:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2016-03-07 04:59:17 +08:00
|
|
|
index 39afaae..f8737ef 100644
|
2014-11-28 09:17:45 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2016-03-07 04:59:17 +08:00
|
|
|
@@ -2679,6 +2679,53 @@ public abstract class World implements IBlockAccess {
|
2016-03-01 07:09:49 +08:00
|
|
|
return i;
|
2015-05-19 07:41:57 +08:00
|
|
|
}
|
|
|
|
|
2016-03-01 07:09:49 +08:00
|
|
|
+ // Paper start - Modified methods for affects spawning
|
2015-03-08 09:16:09 +08:00
|
|
|
+ public EntityHuman findNearbyPlayerWhoAffectsSpawning(Entity entity, double d0) {
|
|
|
|
+ return this.findNearbyPlayerWhoAffectsSpawning(entity.locX, entity.locY, entity.locZ, d0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public EntityHuman findNearbyPlayerWhoAffectsSpawning(double d0, double d1, double d2, double d3) {
|
|
|
|
+ double d4 = -1.0D;
|
|
|
|
+ EntityHuman entityhuman = null;
|
|
|
|
+
|
2014-11-28 09:17:45 +08:00
|
|
|
+ for (int i = 0; i < this.players.size(); ++i) {
|
2015-03-08 09:16:09 +08:00
|
|
|
+ EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
|
|
|
|
+ // CraftBukkit start - Fixed an NPE
|
|
|
|
+ if (entityhuman1 == null || entityhuman1.dead || !entityhuman1.affectsSpawning) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2014-11-28 09:17:45 +08:00
|
|
|
+
|
2015-03-08 09:16:09 +08:00
|
|
|
+ if (IEntitySelector.d.apply(entityhuman1)) {
|
|
|
|
+ double d5 = entityhuman1.e(d0, d1, d2);
|
2014-11-28 09:17:45 +08:00
|
|
|
+
|
2015-03-08 09:16:09 +08:00
|
|
|
+ if ((d3 < 0.0D || d5 < d3 * d3) && (d4 == -1.0D || d5 < d4)) {
|
|
|
|
+ d4 = d5;
|
|
|
|
+ entityhuman = entityhuman1;
|
2014-11-28 09:17:45 +08:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2015-03-08 09:16:09 +08:00
|
|
|
+ return entityhuman;
|
2014-11-28 09:17:45 +08:00
|
|
|
+ }
|
|
|
|
+
|
2015-03-08 09:16:09 +08:00
|
|
|
+ public boolean isPlayerNearbyWhoAffectsSpawning(double d0, double d1, double d2, double d3) {
|
2014-11-28 09:17:45 +08:00
|
|
|
+ for (int i = 0; i < this.players.size(); ++i) {
|
2015-03-08 09:16:09 +08:00
|
|
|
+ EntityHuman entityhuman = (EntityHuman) this.players.get(i);
|
2014-11-28 09:17:45 +08:00
|
|
|
+
|
2015-03-08 09:16:09 +08:00
|
|
|
+ if (IEntitySelector.d.apply(entityhuman)) {
|
|
|
|
+ double d4 = entityhuman.e(d0, d1, d2);
|
2014-11-28 09:17:45 +08:00
|
|
|
+
|
2015-03-08 09:16:09 +08:00
|
|
|
+ if (d3 < 0.0D || d4 < d3 * d3 && entityhuman.affectsSpawning) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
2014-11-28 09:17:45 +08:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2015-03-08 09:16:09 +08:00
|
|
|
+ return false;
|
2014-11-28 09:17:45 +08:00
|
|
|
+ }
|
2016-03-01 07:09:49 +08:00
|
|
|
+ // Paper end
|
2015-05-19 07:41:57 +08:00
|
|
|
+
|
2016-03-01 07:09:49 +08:00
|
|
|
public EntityHuman findNearbyPlayer(Entity entity, double d0) {
|
|
|
|
return this.a(entity.locX, entity.locY, entity.locZ, d0, false);
|
|
|
|
}
|
2014-11-28 09:17:45 +08:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2016-03-07 04:59:17 +08:00
|
|
|
index 377633e..935810c 100644
|
2014-11-28 09:17:45 +08:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2016-03-03 17:46:26 +08:00
|
|
|
@@ -1412,6 +1412,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2016-03-01 07:09:49 +08:00
|
|
|
|
|
|
|
}
|
2015-05-19 07:41:57 +08:00
|
|
|
|
2016-03-01 07:09:49 +08:00
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public boolean getAffectsSpawning() {
|
|
|
|
+ return getHandle().affectsSpawning;
|
|
|
|
+ }
|
2014-11-28 09:17:45 +08:00
|
|
|
+
|
2016-03-01 07:09:49 +08:00
|
|
|
+ @Override
|
|
|
|
+ public void setAffectsSpawning(boolean affects) {
|
|
|
|
+ getHandle().affectsSpawning = affects;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2015-03-08 09:16:09 +08:00
|
|
|
+
|
2016-03-01 07:09:49 +08:00
|
|
|
// Spigot start
|
|
|
|
private final Player.Spigot spigot = new Player.Spigot()
|
|
|
|
{
|
2014-11-28 09:17:45 +08:00
|
|
|
--
|
2016-03-01 07:09:49 +08:00
|
|
|
2.7.2
|
2014-11-28 09:17:45 +08:00
|
|
|
|