use of net.minecraftforge.fml.common.network.internal.FMLMessage.EntitySpawnMessage in project MorePlanets by SteveKunG.
the class ClientProxyMP method handleSpaceFishHookSpawning.
private static void handleSpaceFishHookSpawning() {
EntityRegistration entityRegistration = EntityRegistry.instance().lookupModSpawn(EntitySpaceFishHook.class, false);
Function<EntitySpawnMessage, Entity> handler = input -> {
int entityID = 0;
double posX = 0;
double posY = 0;
double posZ = 0;
WorldClient world = FMLClientHandler.instance().getWorldClient();
try {
entityID = ReflectionHelper.findField(EntitySpawnMessage.class, "throwerId").getInt(input);
posX = ReflectionHelper.findField(EntitySpawnMessage.class, "rawX").getDouble(input);
posY = ReflectionHelper.findField(EntitySpawnMessage.class, "rawY").getDouble(input);
posZ = ReflectionHelper.findField(EntitySpawnMessage.class, "rawZ").getDouble(input);
} catch (Exception e) {
e.printStackTrace();
}
Entity angler = world.getEntityByID(entityID);
if (angler instanceof EntityPlayer) {
Entity entity = new EntitySpaceFishHook(world, (EntityPlayer) angler, posX, posY, posZ);
return entity;
}
return null;
};
entityRegistration.setCustomSpawning(handler, false);
}
Aggregations