2015-06-05 12:45:30 +00:00
|
|
|
From 60cb36b88b86ace4deada026a6a4989535ee5706 Mon Sep 17 00:00:00 2001
|
2015-05-19 00:22:48 +00:00
|
|
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
2015-05-18 23:41:57 +00:00
|
|
|
Date: Mon, 18 May 2015 17:52:45 -0500
|
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
|
2015-06-05 12:45:30 +00:00
|
|
|
index 0fac7c9..8d2b3a1 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
|
2014-12-07 19:29:55 +00:00
|
|
|
@@ -61,6 +61,7 @@ public abstract class EntityHuman extends EntityLiving {
|
2015-03-08 01:16:09 +00:00
|
|
|
private final GameProfile bH;
|
|
|
|
private boolean bI = false;
|
2014-11-28 01:17:45 +00:00
|
|
|
public EntityFishingHook hookedFish;
|
|
|
|
+ public boolean affectsSpawning = true; // PaperSpigot
|
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
|
2015-05-18 23:41:57 +00:00
|
|
|
index fdca016..2a57b24 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
|
2015-05-18 23:41:57 +00:00
|
|
|
@@ -430,7 +430,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);
|
|
|
|
+ EntityHuman entityhuman = this.world.findNearbyPlayerWhoAffectsSpawning(this, -1.0D); // PaperSpigot - Affects Spawning API
|
|
|
|
|
|
|
|
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
|
2015-05-18 23:41:57 +00:00
|
|
|
index 1680918..eca4679 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
|
2015-03-08 01:16:09 +00:00
|
|
|
@@ -52,7 +52,7 @@ public abstract class MobSpawnerAbstract {
|
2014-11-28 01:17:45 +00:00
|
|
|
private boolean g() {
|
|
|
|
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);
|
2015-03-08 01:16:09 +00:00
|
|
|
+ return this.a().isPlayerNearbyWhoAffectsSpawning((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, (double) this.requiredPlayerRange); // PaperSpigot - 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
|
2015-06-05 12:45:30 +00:00
|
|
|
index 3964e3f..611b8fd 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
|
|
|
|
@@ -52,7 +52,7 @@ public final class SpawnerCreature {
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
|
|
|
|
2015-05-18 23:41:57 +00:00
|
|
|
- if (!entityhuman.isSpectator()) {
|
2015-05-19 00:22:48 +00:00
|
|
|
+ if (!entityhuman.isSpectator() || !entityhuman.affectsSpawning) { // PaperSpigot
|
2014-11-28 01:17:45 +00:00
|
|
|
int l = MathHelper.floor(entityhuman.locX / 16.0D);
|
|
|
|
|
|
|
|
j = MathHelper.floor(entityhuman.locZ / 16.0D);
|
2015-03-08 01:16:09 +00:00
|
|
|
@@ -156,7 +156,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;
|
|
|
|
|
|
|
|
- if (!worldserver.isPlayerNearby((double) f, (double) k3, (double) f1, 24.0D) && blockposition.c((double) f, (double) k3, (double) f1) >= 576.0D) {
|
2015-03-08 01:16:09 +00:00
|
|
|
+ if (!worldserver.isPlayerNearbyWhoAffectsSpawning((double) f, (double) k3, (double) f1, 24.0D) && blockposition.c((double) f, (double) k3, (double) f1) >= 576.0D) { // PaperSpigot - Affects Spawning API
|
|
|
|
if (biomebase_biomemeta == null) {
|
|
|
|
biomebase_biomemeta = worldserver.a(enumcreaturetype, blockposition2);
|
|
|
|
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
|
2015-06-05 12:45:30 +00:00
|
|
|
index 8bcb4ad..fae5eb7 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
|
2015-05-18 23:41:57 +00:00
|
|
|
@@ -2,35 +2,23 @@ package net.minecraft.server;
|
2014-11-28 01:17:45 +00:00
|
|
|
|
2015-05-18 23:41:57 +00:00
|
|
|
import com.google.common.base.Predicate;
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
-import com.google.common.collect.Sets;
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Calendar;
|
|
|
|
-import java.util.Collection;
|
|
|
|
-import java.util.Iterator;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Random;
|
|
|
|
-import java.util.Set;
|
|
|
|
-import java.util.UUID;
|
|
|
|
-import java.util.concurrent.Callable;
|
|
|
|
-
|
|
|
|
-// CraftBukkit start
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
-import java.util.Map;
|
|
|
|
-
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.block.BlockState;
|
|
|
|
-import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
|
|
|
-import org.bukkit.craftbukkit.util.LongHashSet;
|
|
|
|
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
|
|
|
-import org.bukkit.generator.ChunkGenerator;
|
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
|
|
|
import org.bukkit.craftbukkit.CraftWorld;
|
|
|
|
+import org.bukkit.craftbukkit.SpigotTimings;
|
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
|
|
|
import org.bukkit.event.block.BlockCanBuildEvent;
|
|
|
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
|
|
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|
|
|
-import org.bukkit.event.weather.WeatherChangeEvent;
|
|
|
|
-import org.bukkit.event.weather.ThunderChangeEvent;
|
|
|
|
+import org.bukkit.generator.ChunkGenerator;
|
|
|
|
+
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.concurrent.Callable;
|
2015-03-08 01:16:09 +00:00
|
|
|
+
|
2015-05-18 23:41:57 +00:00
|
|
|
+// CraftBukkit start
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
public abstract class World implements IBlockAccess {
|
2015-06-05 12:45:30 +00:00
|
|
|
@@ -2814,6 +2802,53 @@ public abstract class World implements IBlockAccess {
|
2015-05-18 23:41:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-03-08 01:16:09 +00:00
|
|
|
+ // PaperSpigot start - Modified methods for affects spawning
|
|
|
|
+ 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
|
|
|
+ }
|
2015-05-18 23:41:57 +00:00
|
|
|
+ // PaperSpigot end
|
|
|
|
+
|
|
|
|
public EntityHuman a(String s) {
|
|
|
|
for (int i = 0; i < this.players.size(); ++i) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) this.players.get(i);
|
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
|
2015-05-18 23:41:57 +00:00
|
|
|
index 40ee4d3..130dcce 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
|
2015-05-18 23:41:57 +00:00
|
|
|
@@ -6,6 +6,7 @@ import io.netty.buffer.Unpooled;
|
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
+import java.lang.Override;
|
|
|
|
import java.net.InetSocketAddress;
|
|
|
|
import java.net.SocketAddress;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
@@ -1443,6 +1444,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2014-12-14 22:25:11 +00:00
|
|
|
packet.components = components;
|
|
|
|
getHandle().playerConnection.sendPacket(packet);
|
2014-11-28 01:17:45 +00:00
|
|
|
}
|
|
|
|
+
|
2015-03-08 01:16:09 +00:00
|
|
|
+ // PaperSpigot start - Implement affects spawning API
|
|
|
|
+ @Override
|
2014-11-28 01:17:45 +00:00
|
|
|
+ public boolean getAffectsSpawning() {
|
|
|
|
+ return getHandle().affectsSpawning;
|
|
|
|
+ }
|
2015-03-08 01:16:09 +00:00
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setAffectsSpawning(boolean affects) {
|
|
|
|
+ getHandle().affectsSpawning = affects;
|
|
|
|
+ }
|
2014-11-28 01:17:45 +00:00
|
|
|
+ // PaperSpigot end
|
|
|
|
};
|
|
|
|
|
|
|
|
public Player.Spigot spigot()
|
|
|
|
--
|
2015-06-05 12:45:30 +00:00
|
|
|
1.9.5.msysgit.1
|
2014-11-28 01:17:45 +00:00
|
|
|
|