mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
5b6dfb3463
This work is 100% unfinished. I am pushing it up so that we as a team can work on this update. Do not try to use this branch. You will fail.
108 lines
5.0 KiB
Diff
108 lines
5.0 KiB
Diff
From fd20af56dbf1982c04406fcd9a0360b54568d965 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 40efd6c60..1aa32bf11 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -72,6 +72,9 @@ public abstract class EntityHuman extends EntityLiving {
|
|
private final ItemCooldown ce;
|
|
@Nullable
|
|
public EntityFishingHook hookedFish;
|
|
+ // Paper start
|
|
+ public boolean affectsSpawning = true;
|
|
+ // Paper end
|
|
|
|
// 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 c8c191667..d29364b01 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
@@ -614,7 +614,7 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
} else {
|
|
EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D);
|
|
|
|
- if (entityhuman != null) {
|
|
+ if (entityhuman != null && entityhuman.affectsSpawning) { // Paper - Affects Spawning API
|
|
double d0 = entityhuman.locX - this.locX;
|
|
double d1 = entityhuman.locY - this.locY;
|
|
double d2 = entityhuman.locZ - this.locZ;
|
|
diff --git a/src/main/java/net/minecraft/server/EntitySilverfish.java b/src/main/java/net/minecraft/server/EntitySilverfish.java
|
|
index 6cb4f889c..a1ebf5c68 100644
|
|
--- a/src/main/java/net/minecraft/server/EntitySilverfish.java
|
|
+++ b/src/main/java/net/minecraft/server/EntitySilverfish.java
|
|
@@ -96,7 +96,7 @@ public class EntitySilverfish extends EntityMonster {
|
|
if (super.a(generatoraccess)) {
|
|
EntityHuman entityhuman = generatoraccess.b(this, 5.0D);
|
|
|
|
- return entityhuman == null;
|
|
+ return !(entityhuman != null && !entityhuman.affectsSpawning) && entityhuman == null; // Paper - Affects Spawning API
|
|
} else {
|
|
return false;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
index 44fb75c6f..aec9cdae5 100644
|
|
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
@@ -37,7 +37,7 @@ public final class SpawnerCreature {
|
|
while (iterator.hasNext()) {
|
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
|
|
|
- if (!entityhuman.isSpectator()) {
|
|
+ if (!entityhuman.isSpectator() && entityhuman.affectsSpawning) { // Paper
|
|
int l = MathHelper.floor(entityhuman.locX / 16.0D);
|
|
|
|
j = MathHelper.floor(entityhuman.locZ / 16.0D);
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 05d363171..fd64b75ed 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -28,6 +28,7 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
|
import org.bukkit.craftbukkit.util.LongHashSet; // Paper
|
|
+import org.bukkit.entity.Player;
|
|
import org.bukkit.event.block.BlockCanBuildEvent;
|
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|
@@ -2407,7 +2408,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
|
for (int i = 0; i < this.players.size(); ++i) {
|
|
EntityHuman entityhuman = (EntityHuman) this.players.get(i);
|
|
|
|
- if (IEntitySelector.e.test(entityhuman)) {
|
|
+ if (IEntitySelector.e.test(entityhuman) && entityhuman.affectsSpawning) { // Paper - Affects Spawning API
|
|
double d4 = entityhuman.d(d0, d1, d2);
|
|
|
|
if (d3 < 0.0D || d4 < d3 * d3) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index fad258f11..c67137a80 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -1585,7 +1585,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
@Override
|
|
public String getLocale() {
|
|
return getHandle().locale;
|
|
+
|
|
+ }
|
|
+
|
|
+ // Paper start
|
|
+ public void setAffectsSpawning(boolean affects) {
|
|
+ this.getHandle().affectsSpawning = affects;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean getAffectsSpawning() {
|
|
+ return this.getHandle().affectsSpawning;
|
|
}
|
|
+ // Paper end
|
|
|
|
// Spigot start
|
|
private final Player.Spigot spigot = new Player.Spigot()
|
|
--
|
|
2.18.0
|
|
|