70ce6ce831
This makes it easier for downstream projects (forks) to replace the version fetching system with their own. It is as simple as implementing an interface and overriding the default implementation of org.bukkit.UnsafeValues#getVersionFetcher() It also makes it easier for us to organize things like the version history feature. Lastly I have updated the paper implementation to check against the site API rather than against jenkins.
107 lines
4.9 KiB
Diff
107 lines
4.9 KiB
Diff
From c596f9df47e0204ca49538a3b3f5d198baaacb6d 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 dbb8098d6..e9bcb5aba 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();
|
|
|
|
@@ -205,6 +206,7 @@ public abstract class MobSpawnerAbstract {
|
|
}
|
|
}
|
|
|
|
+ public void resetTimer() { i(); } // Paper - OBFHELPER
|
|
private void i() {
|
|
if (this.maxSpawnDelay <= this.minSpawnDelay) {
|
|
this.spawnDelay = this.minSpawnDelay;
|
|
@@ -222,7 +224,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);
|
|
@@ -237,10 +245,15 @@ public abstract class MobSpawnerAbstract {
|
|
} else if (!this.mobs.isEmpty()) {
|
|
this.setSpawnData((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");
|
|
}
|
|
|
|
@@ -265,9 +278,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 5c4c3c70c..e78e3804b 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java
|
|
@@ -121,4 +121,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
|
|
|