testserver/Spigot-Server-Patches/0017-Player-affects-spawnin...

151 lines
7.0 KiB
Diff
Raw Normal View History

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