Paper/Spigot-Server-Patches/0439-Mob-Spawner-API-Enhancements.patch
Shane Freeder fb25dc17c6 Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
da08d022 SPIGOT-4700: Add PlayerFishEvent.State.REEL_IN
0cef14e4 Remove draft API from selectEntities

CraftBukkit Changes:
a46fdbc6 Remove outdated build delay.
3697519b SPIGOT-4708: Fix ExactChoice recipes neglecting material
9ead7009 SPIGOT-4677: Add minecraft.admin.command_feedback permission
c3749a23 Remove the Damage tag from items when it is 0.
f74c7b95 SPIGOT-4706: Can't interact with active item
494eef45 Mention requirement of JIRA ticket for bug fixes
51d62dec SPIGOT-4702: Exception when middle clicking certain slots
be557e69 SPIGOT-4700: Add PlayerFishEvent.State.REEL_IN
2019-04-22 22:36:14 +01:00

108 lines
4.9 KiB
Diff

From 965a2dc88afd9fb86088110cf7104e3aae020428 Mon Sep 17 00:00:00 2001
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
index af38e5396e..b0fbd4f6d8 100644
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
@@ -46,6 +46,7 @@ public abstract class MobSpawnerAbstract {
this.mobs.clear(); // CraftBukkit - SPIGOT-3496, MC-92282
}
+ public boolean isActivated() { return h(); } // Paper - OBFHELPER
private boolean h() {
BlockPosition blockposition = this.b();
@@ -176,6 +177,7 @@ public abstract class MobSpawnerAbstract {
}
}
+ public void resetTimer() { i(); } // Paper - OBFHELPER
private void i() {
if (this.maxSpawnDelay <= this.minSpawnDelay) {
this.spawnDelay = this.minSpawnDelay;
@@ -193,7 +195,13 @@ public abstract class MobSpawnerAbstract {
}
public void a(NBTTagCompound nbttagcompound) {
+ // 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
this.mobs.clear();
if (nbttagcompound.hasKeyOfType("SpawnPotentials", 9)) {
NBTTagList nbttaglist = nbttagcompound.getList("SpawnPotentials", 10);
@@ -208,10 +216,15 @@ public abstract class MobSpawnerAbstract {
} else if (!this.mobs.isEmpty()) {
this.a((MobSpawnerData) WeightedRandom.a(this.a().random, this.mobs));
}
-
+ // 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
if (nbttagcompound.hasKeyOfType("MinSpawnDelay", 99)) {
- this.minSpawnDelay = nbttagcompound.getShort("MinSpawnDelay");
- this.maxSpawnDelay = nbttagcompound.getShort("MaxSpawnDelay");
+ this.minSpawnDelay = nbttagcompound.getInt("MinSpawnDelay");
+ this.maxSpawnDelay = nbttagcompound.getInt("MaxSpawnDelay");
this.spawnCount = nbttagcompound.getShort("SpawnCount");
}
@@ -236,9 +249,20 @@ public abstract class MobSpawnerAbstract {
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
+ if (spawnDelay > Short.MAX_VALUE) {
+ nbttagcompound.setInt("Paper.Delay", this.spawnDelay);
+ }
+ nbttagcompound.setShort("Delay", (short) Math.min(Short.MAX_VALUE, this.spawnDelay));
+
+ if (minSpawnDelay > Short.MAX_VALUE || maxSpawnDelay > Short.MAX_VALUE) {
+ nbttagcompound.setInt("Paper.MinSpawnDelay", this.minSpawnDelay);
+ nbttagcompound.setInt("Paper.MaxSpawnDelay", this.maxSpawnDelay);
+ }
+
+ 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
index aa63b854d1..a3be2b141e 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java
@@ -122,4 +122,16 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
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
}
--
2.21.0