use of net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration in project MorePlanets by SteveKunG.
the class ClientProxyMP method handleCustomSpawning.
private static void handleCustomSpawning() {
EntityRegistration entityRegistration = EntityRegistry.instance().lookupModSpawn(EntitySpaceFishHook.class, false);
Function<FMLMessage.EntitySpawnMessage, Entity> handler = input -> {
WorldClient world = FMLClientHandler.instance().getWorldClient();
int entityID = 0;
double posX = 0;
double posY = 0;
double posZ = 0;
try {
entityID = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "throwerId").getInt(input);
posX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawX").getDouble(input);
posY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawY").getDouble(input);
posZ = ObfuscationReflectionHelper.findField(FMLMessage.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);
entityRegistration = EntityRegistry.instance().lookupModSpawn(EntityCheeseSpore.class, false);
handler = input -> {
WorldClient world = FMLClientHandler.instance().getWorldClient();
double posX = 0;
double posY = 0;
double posZ = 0;
double speedScaledX = 0;
double speedScaledY = 0;
double speedScaledZ = 0;
try {
posX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawX").getDouble(input);
posY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawY").getDouble(input);
posZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawZ").getDouble(input);
speedScaledX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledX").getDouble(input);
speedScaledY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledY").getDouble(input);
speedScaledZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledZ").getDouble(input);
} catch (Exception e) {
e.printStackTrace();
}
Entity entity = new EntityCheeseSpore(world, posX, posY, posZ, speedScaledX, speedScaledY, speedScaledZ);
return entity;
};
entityRegistration.setCustomSpawning(handler, false);
entityRegistration = EntityRegistry.instance().lookupModSpawn(EntitySmallCheeseSpore.class, false);
handler = input -> {
WorldClient world = FMLClientHandler.instance().getWorldClient();
double posX = 0;
double posY = 0;
double posZ = 0;
double speedScaledX = 0;
double speedScaledY = 0;
double speedScaledZ = 0;
try {
posX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawX").getDouble(input);
posY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawY").getDouble(input);
posZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawZ").getDouble(input);
speedScaledX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledX").getDouble(input);
speedScaledY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledY").getDouble(input);
speedScaledZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledZ").getDouble(input);
} catch (Exception e) {
e.printStackTrace();
}
Entity entity = new EntitySmallCheeseSpore(world, posX, posY, posZ, speedScaledX, speedScaledY, speedScaledZ);
return entity;
};
entityRegistration.setCustomSpawning(handler, false);
entityRegistration = EntityRegistry.instance().lookupModSpawn(EntityVeinBall.class, false);
handler = input -> {
WorldClient world = FMLClientHandler.instance().getWorldClient();
double posX = 0;
double posY = 0;
double posZ = 0;
double speedScaledX = 0;
double speedScaledY = 0;
double speedScaledZ = 0;
try {
posX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawX").getDouble(input);
posY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawY").getDouble(input);
posZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "rawZ").getDouble(input);
speedScaledX = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledX").getDouble(input);
speedScaledY = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledY").getDouble(input);
speedScaledZ = ObfuscationReflectionHelper.findField(FMLMessage.EntitySpawnMessage.class, "speedScaledZ").getDouble(input);
} catch (Exception e) {
e.printStackTrace();
}
Entity entity = new EntityVeinBall(world, posX, posY, posZ, speedScaledX, speedScaledY, speedScaledZ);
return entity;
};
entityRegistration.setCustomSpawning(handler, false);
}
Aggregations