mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-27 04:25:21 +01:00
fix
This commit is contained in:
parent
da3b435ddf
commit
62a78b3330
@ -32,7 +32,7 @@ public class SpawnerStack {
|
|||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
|
|
||||||
CreatureSpawner creatureSpawner = (CreatureSpawner)location.getBlock().getState();
|
CreatureSpawner creatureSpawner = (CreatureSpawner)location.getBlock().getState();
|
||||||
Reflection.setRange(creatureSpawner, 4 * amount);
|
Reflection.setRange(creatureSpawner, 4 * amount, amount > 6 ? amount + 3 : 6);
|
||||||
creatureSpawner.update();
|
creatureSpawner.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ import java.lang.reflect.Method;
|
|||||||
public class Reflection {
|
public class Reflection {
|
||||||
private static Class<?> clazzCraftCreatureSpawner, clazzTileEntityMobSpawner = null;
|
private static Class<?> clazzCraftCreatureSpawner, clazzTileEntityMobSpawner = null;
|
||||||
private static Method methodGetTileEntity, methodGetSpawner;
|
private static Method methodGetTileEntity, methodGetSpawner;
|
||||||
private static Field fieldSpawnRange;
|
private static Field fieldSpawnRange, fieldMaxNearbyEntities;
|
||||||
|
|
||||||
public static CreatureSpawner setRange(CreatureSpawner creatureSpawner, int amount) {
|
public static CreatureSpawner setRange(CreatureSpawner creatureSpawner, int amount, int max) {
|
||||||
try {
|
try {
|
||||||
if (clazzCraftCreatureSpawner == null) {
|
if (clazzCraftCreatureSpawner == null) {
|
||||||
String ver = Bukkit.getServer().getClass().getPackage().getName().substring(23);
|
String ver = Bukkit.getServer().getClass().getPackage().getName().substring(23);
|
||||||
@ -22,12 +22,15 @@ public class Reflection {
|
|||||||
methodGetSpawner = clazzTileEntityMobSpawner.getDeclaredMethod("getSpawner");
|
methodGetSpawner = clazzTileEntityMobSpawner.getDeclaredMethod("getSpawner");
|
||||||
fieldSpawnRange = clazzMobSpawnerAbstract.getDeclaredField("spawnRange");
|
fieldSpawnRange = clazzMobSpawnerAbstract.getDeclaredField("spawnRange");
|
||||||
fieldSpawnRange.setAccessible(true);
|
fieldSpawnRange.setAccessible(true);
|
||||||
|
fieldMaxNearbyEntities = clazzMobSpawnerAbstract.getDeclaredField("maxNearbyEntities");
|
||||||
|
fieldSpawnRange.setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object objCraftCreatureSpawner = clazzCraftCreatureSpawner.cast(creatureSpawner);
|
Object objCraftCreatureSpawner = clazzCraftCreatureSpawner.cast(creatureSpawner);
|
||||||
Object objTileEntityMobSpawner = clazzTileEntityMobSpawner.cast(methodGetTileEntity.invoke(objCraftCreatureSpawner));
|
Object objTileEntityMobSpawner = clazzTileEntityMobSpawner.cast(methodGetTileEntity.invoke(objCraftCreatureSpawner));
|
||||||
Object objMobSpawnerAbstract = methodGetSpawner.invoke(objTileEntityMobSpawner);
|
Object objMobSpawnerAbstract = methodGetSpawner.invoke(objTileEntityMobSpawner);
|
||||||
fieldSpawnRange.set(objMobSpawnerAbstract, amount);
|
fieldSpawnRange.set(objMobSpawnerAbstract, amount);
|
||||||
|
fieldMaxNearbyEntities.set(objMobSpawnerAbstract, max);
|
||||||
|
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user