Added fromMobSpawner method.

This commit is contained in:
Brianna O'Keefe 2019-01-30 17:12:56 -05:00
parent 6bb98a77a6
commit b8b75df430

View File

@ -39,9 +39,7 @@ public class SpawnOptionEntity implements SpawnOption {
private EpicSpawnersPlugin instance = EpicSpawnersPlugin.getInstance();
private Map<String, Integer> cache = new HashMap<>();
private Class<?> clazzMobSpawnerData, clazzNBTTagCompound, clazzNBTTagList, clazzCraftWorld, clazzWorld, clazzChunkRegionLoader, clazzEntity, clazzCraftEntity, clazzEntityInsentient, clazzGroupDataEntity, clazzDifficultyDamageScaler, clazzBlockPosition, clazzIWorldReader, clazzAxisAlignedBB;
private Method methodB, methodSetString, methodGetHandle, methodChunkRegionLoaderA, methodEntityGetBukkitEntity, methodCraftEntityTeleport, methodEntityInsentientCanSpawn, methodEntityInsentientPrepare, methodChunkRegionLoaderA2, methodGetDamageScaler, methodGetCubes, methodGetBoundingBox;
private Field fieldWorldRandom;
private Field fieldWorldRandom, fieldFromMobSpawner;
public SpawnOptionEntity(EntityType... types) {
this.types = types;
@ -80,6 +78,7 @@ public class SpawnOptionEntity implements SpawnOption {
methodGetHandle = clazzCraftWorld.getDeclaredMethod("getHandle");
methodChunkRegionLoaderA = clazzChunkRegionLoader.getDeclaredMethod("a", clazzNBTTagCompound, clazzWorld, double.class, double.class, double.class, boolean.class);
methodEntityGetBukkitEntity = clazzEntity.getDeclaredMethod("getBukkitEntity");
fieldFromMobSpawner = clazzEntity.getDeclaredField("fromMobSpawner");
methodCraftEntityTeleport = clazzCraftEntity.getDeclaredMethod("teleport", Location.class);
methodEntityInsentientCanSpawn = clazzEntityInsentient.getDeclaredMethod("canSpawn");
methodEntityInsentientPrepare = clazzEntityInsentient.getDeclaredMethod("prepare", clazzDifficultyDamageScaler, clazzGroupDataEntity, clazzNBTTagCompound);
@ -186,6 +185,8 @@ public class SpawnOptionEntity implements SpawnOption {
spot.getWorld().spawnParticle(particleType.getEffect(), spot, 5, xx, yy, zz, 0);
}
fieldFromMobSpawner.set(objEntity, true);
Entity craftEntity = (Entity) methodEntityGetBukkitEntity.invoke(objEntity);
SpawnerSpawnEvent event = new SpawnerSpawnEvent(craftEntity, spawner);