mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
148 lines
No EOL
7.3 KiB
Diff
148 lines
No EOL
7.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
|
Date: Tue, 1 Mar 2016 14:47:52 -0600
|
|
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
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -0,0 +0,0 @@ public abstract class EntityHuman extends EntityLiving {
|
|
private ItemStack bT = null;
|
|
private final ItemCooldown bU = this.l();
|
|
public EntityFishingHook hookedFish;
|
|
+ public boolean affectsSpawning = true; // Paper
|
|
|
|
// 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
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- 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 {
|
|
if (this.persistent) {
|
|
this.ticksFarFromPlayer = 0;
|
|
} else {
|
|
- EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D);
|
|
+ EntityHuman entityhuman = this.world.findNearbyPlayerWhoAffectsSpawning(this, -1.0D); // Paper - 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
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
@@ -0,0 +0,0 @@ public abstract class MobSpawnerAbstract {
|
|
private boolean h() {
|
|
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
|
|
}
|
|
|
|
public void c() {
|
|
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
|
|
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
@@ -0,0 +0,0 @@ public final class SpawnerCreature {
|
|
while (iterator.hasNext()) {
|
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
|
|
|
- if (!entityhuman.isSpectator()) {
|
|
+ if (!entityhuman.isSpectator() || !entityhuman.affectsSpawning) {
|
|
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 (biomebase_biomemeta == null) {
|
|
biomebase_biomemeta = worldserver.a(enumcreaturetype, (BlockPosition) blockposition_mutableblockposition);
|
|
if (biomebase_biomemeta == null) {
|
|
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 {
|
|
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);
|
|
}
|
|
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
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public boolean getAffectsSpawning() {
|
|
+ return getHandle().affectsSpawning;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setAffectsSpawning(boolean affects) {
|
|
+ getHandle().affectsSpawning = affects;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
// Spigot start
|
|
private final Player.Spigot spigot = new Player.Spigot()
|
|
{
|
|
--
|