2019-12-13 17:22:16 +01:00
|
|
|
From e01d52625f08e8115a1145fe158643465a5d8fb0 Mon Sep 17 00:00:00 2001
|
2019-04-19 19:41:38 +02:00
|
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
|
|
Date: Fri, 19 Apr 2019 12:41:13 -0500
|
|
|
|
Subject: [PATCH] Mob Spawner API Enhancements
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
2019-12-12 17:20:43 +01:00
|
|
|
index 90ca1ee14..b179893a1 100644
|
2019-04-19 19:41:38 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
2019-12-12 17:20:43 +01:00
|
|
|
@@ -47,6 +47,7 @@ public abstract class MobSpawnerAbstract {
|
2019-04-19 19:41:38 +02:00
|
|
|
this.mobs.clear(); // CraftBukkit - SPIGOT-3496, MC-92282
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public boolean isActivated() { return h(); } // Paper - OBFHELPER
|
|
|
|
private boolean h() {
|
|
|
|
BlockPosition blockposition = this.b();
|
|
|
|
|
2019-06-25 03:47:58 +02:00
|
|
|
@@ -206,6 +207,7 @@ public abstract class MobSpawnerAbstract {
|
2019-04-19 19:41:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public void resetTimer() { i(); } // Paper - OBFHELPER
|
|
|
|
private void i() {
|
|
|
|
if (this.maxSpawnDelay <= this.minSpawnDelay) {
|
|
|
|
this.spawnDelay = this.minSpawnDelay;
|
2019-06-25 03:47:58 +02:00
|
|
|
@@ -223,7 +225,13 @@ public abstract class MobSpawnerAbstract {
|
2019-04-19 19:41:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
2019-04-20 20:22:43 +02:00
|
|
|
+ // Paper start - use larger int if set
|
|
|
|
+ if (nbttagcompound.hasKey("Paper.Delay")) {
|
|
|
|
+ this.spawnDelay = nbttagcompound.getInt("Paper.Delay");
|
|
|
|
+ } else {
|
|
|
|
this.spawnDelay = nbttagcompound.getShort("Delay");
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2019-04-19 19:41:38 +02:00
|
|
|
this.mobs.clear();
|
|
|
|
if (nbttagcompound.hasKeyOfType("SpawnPotentials", 9)) {
|
|
|
|
NBTTagList nbttaglist = nbttagcompound.getList("SpawnPotentials", 10);
|
2019-06-25 03:47:58 +02:00
|
|
|
@@ -238,10 +246,15 @@ public abstract class MobSpawnerAbstract {
|
2019-04-20 20:22:43 +02:00
|
|
|
} else if (!this.mobs.isEmpty()) {
|
2019-05-14 04:20:58 +02:00
|
|
|
this.setSpawnData((MobSpawnerData) WeightedRandom.a(this.a().random, this.mobs));
|
2019-04-19 19:41:38 +02:00
|
|
|
}
|
2019-04-20 20:22:43 +02:00
|
|
|
-
|
|
|
|
+ // Paper start - use ints if set
|
|
|
|
+ if (nbttagcompound.hasKeyOfType("Paper.MinSpawnDelay", 99)) {
|
|
|
|
+ this.minSpawnDelay = nbttagcompound.getInt("Paper.MinSpawnDelay");
|
|
|
|
+ this.maxSpawnDelay = nbttagcompound.getInt("Paper.MaxSpawnDelay");
|
|
|
|
+ this.spawnCount = nbttagcompound.getShort("SpawnCount");
|
|
|
|
+ } else // Paper end
|
2019-04-19 19:41:38 +02:00
|
|
|
if (nbttagcompound.hasKeyOfType("MinSpawnDelay", 99)) {
|
|
|
|
- this.minSpawnDelay = nbttagcompound.getShort("MinSpawnDelay");
|
|
|
|
- this.maxSpawnDelay = nbttagcompound.getShort("MaxSpawnDelay");
|
2019-04-20 20:22:43 +02:00
|
|
|
+ this.minSpawnDelay = nbttagcompound.getInt("MinSpawnDelay");
|
|
|
|
+ this.maxSpawnDelay = nbttagcompound.getInt("MaxSpawnDelay");
|
2019-04-19 19:41:38 +02:00
|
|
|
this.spawnCount = nbttagcompound.getShort("SpawnCount");
|
|
|
|
}
|
|
|
|
|
2019-06-25 03:47:58 +02:00
|
|
|
@@ -266,9 +279,20 @@ public abstract class MobSpawnerAbstract {
|
2019-04-19 19:41:38 +02:00
|
|
|
if (minecraftkey == null) {
|
|
|
|
return nbttagcompound;
|
|
|
|
} else {
|
|
|
|
- nbttagcompound.setShort("Delay", (short) this.spawnDelay);
|
|
|
|
- nbttagcompound.setShort("MinSpawnDelay", (short) this.minSpawnDelay);
|
|
|
|
- nbttagcompound.setShort("MaxSpawnDelay", (short) this.maxSpawnDelay);
|
|
|
|
+ // Paper start
|
2019-04-20 20:22:43 +02:00
|
|
|
+ if (spawnDelay > Short.MAX_VALUE) {
|
|
|
|
+ nbttagcompound.setInt("Paper.Delay", this.spawnDelay);
|
|
|
|
+ }
|
2019-04-19 19:41:38 +02:00
|
|
|
+ nbttagcompound.setShort("Delay", (short) Math.min(Short.MAX_VALUE, this.spawnDelay));
|
2019-04-20 20:22:43 +02:00
|
|
|
+
|
|
|
|
+ if (minSpawnDelay > Short.MAX_VALUE || maxSpawnDelay > Short.MAX_VALUE) {
|
|
|
|
+ nbttagcompound.setInt("Paper.MinSpawnDelay", this.minSpawnDelay);
|
|
|
|
+ nbttagcompound.setInt("Paper.MaxSpawnDelay", this.maxSpawnDelay);
|
|
|
|
+ }
|
|
|
|
+
|
2019-04-19 19:41:38 +02:00
|
|
|
+ nbttagcompound.setShort("MinSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.minSpawnDelay));
|
|
|
|
+ nbttagcompound.setShort("MaxSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.maxSpawnDelay));
|
|
|
|
+ // Paper end
|
|
|
|
nbttagcompound.setShort("SpawnCount", (short) this.spawnCount);
|
|
|
|
nbttagcompound.setShort("MaxNearbyEntities", (short) this.maxNearbyEntities);
|
|
|
|
nbttagcompound.setShort("RequiredPlayerRange", (short) this.requiredPlayerRange);
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java
|
2019-09-29 22:02:04 +02:00
|
|
|
index 5c4c3c70c..e78e3804b 100644
|
2019-04-19 19:41:38 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java
|
2019-05-05 19:19:34 +02:00
|
|
|
@@ -121,4 +121,16 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
|
2019-04-19 19:41:38 +02:00
|
|
|
public void setSpawnRange(int spawnRange) {
|
|
|
|
this.getSnapshot().getSpawner().spawnRange = spawnRange;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isActivated() {
|
|
|
|
+ return this.getSnapshot().getSpawner().isActivated();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void resetTimer() {
|
|
|
|
+ this.getSnapshot().getSpawner().resetTimer();
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
--
|
2019-12-12 17:20:43 +01:00
|
|
|
2.24.1
|
2019-04-19 19:41:38 +02:00
|
|
|
|