Fixed issue causing mobs to spawn non hostile.

This commit is contained in:
Brianna O'Keefe 2019-02-12 16:12:50 -05:00
parent d4b7430ece
commit 5277e6f391

View File

@ -41,7 +41,7 @@ public class SpawnOptionEntity implements SpawnOption {
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, fieldFromMobSpawner;
private Field fieldWorldRandom;
public SpawnOptionEntity(EntityType... types) {
this.types = types;
@ -80,7 +80,6 @@ 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,9 +185,7 @@ public class SpawnOptionEntity implements SpawnOption {
float zz = (float) (0 + (Math.random() * 1));
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);