diff --git a/Spigot-Server-Patches/Add-player-view-distance-API.patch b/Spigot-Server-Patches/Add-player-view-distance-API.patch index b82e052c7..e40851498 100644 --- a/Spigot-Server-Patches/Add-player-view-distance-API.patch +++ b/Spigot-Server-Patches/Add-player-view-distance-API.patch @@ -92,10 +92,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - public void setAffectsSpawning(boolean affects) { - getHandle().affectsSpawning = affects; + return this.getHandle().affectsSpawning; } -+ + + @Override + public int getViewDistance() { + return getHandle().viewDistance; @@ -105,7 +104,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void setViewDistance(int viewDistance) { + ((WorldServer) getHandle().world).getPlayerChunkMap().updateViewDistance(getHandle(), viewDistance); + } - // Paper end - ++ // Spigot start + private final Player.Spigot spigot = new Player.Spigot() + { -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Complete-resource-pack-API.patch b/Spigot-Server-Patches/Complete-resource-pack-API.patch index 8d22f2000..c418a387e 100644 --- a/Spigot-Server-Patches/Complete-resource-pack-API.patch +++ b/Spigot-Server-Patches/Complete-resource-pack-API.patch @@ -52,10 +52,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public CraftPlayer(CraftServer server, EntityPlayer entity) { super(server, entity); @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - public void setViewDistance(int viewDistance) { ((WorldServer) getHandle().world).getPlayerChunkMap().updateViewDistance(getHandle(), viewDistance); } -+ + + @Override + public void setResourcePack(String url, String hash) { + Validate.notNull(url, "Resource pack URL cannot be null"); @@ -82,7 +81,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.resourcePackStatus = status; + this.resourcePackHash = hash; + } - // Paper end - ++ // Spigot start + private final Player.Spigot spigot = new Player.Spigot() + { -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Configurable-Player-Collision.patch b/Spigot-Server-Patches/Configurable-Player-Collision.patch deleted file mode 100644 index aca9f1f80..000000000 --- a/Spigot-Server-Patches/Configurable-Player-Collision.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Wed, 13 Apr 2016 02:10:49 -0400 -Subject: [PATCH] Configurable Player Collision - - -diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/com/destroystokyo/paper/PaperConfig.java -+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java -@@ -0,0 +0,0 @@ public class PaperConfig { - private static void regionFileCacheSize() { - regionFileCacheSize = getInt("settings.region-file-cache-size", 256); - } -+ -+ public static boolean enablePlayerCollisions = true; -+ private static void enablePlayerCollisions() { -+ enablePlayerCollisions = getBoolean("settings.enable-player-collisions", true); -+ } - } -diff --git a/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java b/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java -+++ b/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java -@@ -0,0 +0,0 @@ public class PacketPlayOutScoreboardTeam implements Packet affectsSpawningFilter() { ++ return new Predicate() { ++ @Override ++ public boolean apply(EntityHuman entityHuman) { ++ return entityHuman.affectsSpawning; ++ } ++ }; ++ } ++ // Paper end ++ // CraftBukkit start public boolean fauxSleeping; + public String spawnWorld = ""; 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/EntityInsentient.java @@ -25,10 +45,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.ticksFarFromPlayer = 0; } else { - EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D); -+ EntityHuman entityhuman = this.world.findNearbyPlayerWhoAffectsSpawning(this, -1.0D); // Paper - Affects Spawning API ++ EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D, EntityHuman.affectsSpawningFilter()); // Paper - affectsSpawning filter if (entityhuman != null) { double d0 = entityhuman.locX - this.locX; +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 cF() { + if (super.cF()) { +- EntityHuman entityhuman = this.world.b(this, 5.0D); ++ EntityHuman entityhuman = this.world.findNearbyPlayerNotInCreativeMode(this, 5.0D, EntityHuman.affectsSpawningFilter()); // Paper - affectsSpawning filter + + return entityhuman == null; + } else { +diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/EntityZombie.java ++++ b/src/main/java/net/minecraft/server/EntityZombie.java +@@ -0,0 +0,0 @@ public class EntityZombie extends EntityMonster { + + if (this.world.getType(new BlockPosition(i1, j1 - 1, k1)).q() && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) { + entityzombie.setPosition((double) i1, (double) j1, (double) k1); +- if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.a(entityzombie.getBoundingBox(), (Entity) entityzombie) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()).isEmpty() && !this.world.containsLiquid(entityzombie.getBoundingBox())) { ++ if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D, EntityHuman.affectsSpawningFilter()) && this.world.a(entityzombie.getBoundingBox(), (Entity) entityzombie) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()).isEmpty() && !this.world.containsLiquid(entityzombie.getBoundingBox())) { // Paper - affectsSpawning filter + this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit + entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); + entityzombie.prepare(this.world.D(new BlockPosition(entityzombie)), (GroupDataEntity) null); diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java @@ -38,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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); -+ 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 ++ return this.a().isPlayerNearby((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, (double) this.requiredPlayerRange, EntityHuman.affectsSpawningFilter()); // Paper - affectsSpawning filter } public void c() { @@ -50,17 +96,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 while (iterator.hasNext()) { EntityHuman entityhuman = (EntityHuman) iterator.next(); -- if (!entityhuman.isSpectator()) { -+ if (!entityhuman.isSpectator() || !entityhuman.affectsSpawning) { ++ if (!entityhuman.affectsSpawning) continue; // Paper - affectsSpawning check ++ + if (!entityhuman.isSpectator()) { int l = MathHelper.floor(entityhuman.locX / 16.0D); - j = MathHelper.floor(entityhuman.locZ / 16.0D); @@ -0,0 +0,0 @@ public final class SpawnerCreature { float f = (float) j3 + 0.5F; float f1 = (float) l3 + 0.5F; - 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) { ++ if (!worldserver.isPlayerNearby((double) f, (double) k3, (double) f1, 24.0D, EntityHuman.affectsSpawningFilter()) && blockposition.distanceSquared((double) f, (double) k3, (double) f1) >= 576.0D) { // Paper - affectsSpawning filter if (biomebase_biomemeta == null) { biomebase_biomemeta = worldserver.a(enumcreaturetype, (BlockPosition) blockposition_mutableblockposition); if (biomebase_biomemeta == null) { @@ -68,60 +114,73 @@ diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/m 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 @@ + import com.google.common.base.Function; + import com.google.common.base.Objects; + import com.google.common.base.Predicate; ++import com.google.common.base.Predicates; // Paper + import com.google.common.collect.Lists; + import java.util.ArrayList; + import java.util.Calendar; @@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { - return i; } -+ // Paper 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; -+ -+ for (int i = 0; i < this.players.size(); ++i) { -+ EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); -+ // CraftBukkit start - Fixed an NPE -+ if (entityhuman1 == null || entityhuman1.dead || !entityhuman1.affectsSpawning) { -+ continue; -+ } -+ // CraftBukkit end -+ -+ if (IEntitySelector.d.apply(entityhuman1)) { -+ double d5 = entityhuman1.e(d0, d1, d2); -+ -+ if ((d3 < 0.0D || d5 < d3 * d3) && (d4 == -1.0D || d5 < d4)) { -+ d4 = d5; -+ entityhuman = entityhuman1; -+ } -+ } -+ } -+ -+ return entityhuman; -+ } -+ -+ public boolean isPlayerNearbyWhoAffectsSpawning(double d0, double d1, double d2, double d3) { -+ for (int i = 0; i < this.players.size(); ++i) { -+ EntityHuman entityhuman = (EntityHuman) this.players.get(i); -+ -+ if (IEntitySelector.d.apply(entityhuman)) { -+ double d4 = entityhuman.e(d0, d1, d2); -+ -+ if (d3 < 0.0D || d4 < d3 * d3 && entityhuman.affectsSpawning) { -+ return true; -+ } -+ } -+ } -+ -+ return false; -+ } -+ // Paper end -+ public EntityHuman findNearbyPlayer(Entity entity, double d0) { - return this.a(entity.locX, entity.locY, entity.locZ, d0, false); +- return this.a(entity.locX, entity.locY, entity.locZ, d0, false); ++ // Paper start - Add filter parameter ++ return findNearbyPlayer(entity, d0, Predicates.alwaysTrue()); ++ } ++ ++ public EntityHuman findNearbyPlayer(Entity entity, double d0, Predicate filter) { ++ return this.findNearbyPlayer(entity.locX, entity.locY, entity.locZ, d0, false, filter); } + + public EntityHuman b(Entity entity, double d0) { +- return this.a(entity.locX, entity.locY, entity.locZ, d0, true); ++ return this.findNearbyPlayerNotInCreativeMode(entity, d0, Predicates.alwaysTrue()); ++ } ++ ++ public EntityHuman findNearbyPlayerNotInCreativeMode(Entity entity, double d0, Predicate filter) { ++ return this.findNearbyPlayer(entity.locX, entity.locY, entity.locZ, d0, true, filter); + } + + public EntityHuman a(double d0, double d1, double d2, double d3, boolean flag) { ++ return findNearbyPlayer(d0, d1, d2, d3, flag, Predicates.alwaysTrue()); ++ } ++ ++ public EntityHuman findNearbyPlayer(double d0, double d1, double d2, double d3, boolean flag, Predicate filter) { ++ // FYI the flag means "exclude creative mode players" ++ // Paper end + double d4 = -1.0D; + EntityHuman entityhuman = null; + +@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { + } + // CraftBukkit end + ++ if (!filter.apply(entityhuman1)) continue; // Paper - check filter ++ + if ((IEntitySelector.d.apply(entityhuman1) || !flag) && (IEntitySelector.e.apply(entityhuman1) || flag)) { + double d5 = entityhuman1.e(d0, d1, d2); + +@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { + } + + public boolean isPlayerNearby(double d0, double d1, double d2, double d3) { ++ // Paper start - add filter parameter ++ return isPlayerNearby(d0, d1, d2, d3, Predicates.alwaysTrue()); ++ } ++ ++ public boolean isPlayerNearby(double d0, double d1, double d2, double d3, Predicate filter) { ++ // Paper end + for (int i = 0; i < this.players.size(); ++i) { + EntityHuman entityhuman = (EntityHuman) this.players.get(i); + ++ if (!filter.apply(entityhuman)) continue; // Paper - check filter ++ + if (IEntitySelector.e.apply(entityhuman)) { + double d4 = entityhuman.e(d0, d1, d2); + 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 @@ -130,17 +189,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } -+ // Paper start + @Override -+ public boolean getAffectsSpawning() { -+ return getHandle().affectsSpawning; ++ public void setAffectsSpawning(boolean affects) { ++ this.getHandle().affectsSpawning = affects; + } + + @Override -+ public void setAffectsSpawning(boolean affects) { -+ getHandle().affectsSpawning = affects; ++ public boolean getAffectsSpawning() { ++ return this.getHandle().affectsSpawning; + } -+ // Paper end + // Spigot start private final Player.Spigot spigot = new Player.Spigot()