Search in sources :

Example 6 with EntityRegistration

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);
}
Also used : BiomeColorHelper(net.minecraft.world.biome.BiomeColorHelper) ModelBakeEvent(net.minecraftforge.client.event.ModelBakeEvent) Item(net.minecraft.item.Item) ParticleGravityHarvester(stevekung.mods.moreplanets.moons.koentus.client.particle.ParticleGravityHarvester) ModelRegistryEvent(net.minecraftforge.client.event.ModelRegistryEvent) MPBlocks(stevekung.mods.moreplanets.init.MPBlocks) ParticleDarkPortal(stevekung.mods.moreplanets.planets.diona.client.particle.ParticleDarkPortal) FMLMessage(net.minecraftforge.fml.common.network.internal.FMLMessage) ObfuscationReflectionHelper(net.minecraftforge.fml.common.ObfuscationReflectionHelper) Side(net.minecraftforge.fml.relauncher.Side) EntityVeinBall(stevekung.mods.moreplanets.planets.nibiru.entity.projectile.EntityVeinBall) ClientEventHandler(stevekung.mods.moreplanets.core.event.ClientEventHandler) MPSchematics(stevekung.mods.moreplanets.init.MPSchematics) ItemCapsule(stevekung.mods.moreplanets.items.ItemCapsule) EntitySmallCheeseSpore(stevekung.mods.moreplanets.planets.chalos.entity.projectile.EntitySmallCheeseSpore) Function(com.google.common.base.Function) ParticleInfectedPurloniteFlame(stevekung.mods.moreplanets.planets.diona.client.particle.ParticleInfectedPurloniteFlame) MorePlanetsMod(stevekung.mods.moreplanets.core.MorePlanetsMod) ParticleInfectedGuardianAppearance(stevekung.mods.moreplanets.planets.nibiru.client.particle.ParticleInfectedGuardianAppearance) ModelLoaderRegistry(net.minecraftforge.client.model.ModelLoaderRegistry) MPItems(stevekung.mods.moreplanets.init.MPItems) EnumParticleTypesMP(stevekung.mods.moreplanets.utils.EnumParticleTypesMP) FMLClientHandler(net.minecraftforge.fml.client.FMLClientHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) stevekung.mods.moreplanets.utils.client.particle(stevekung.mods.moreplanets.utils.client.particle) CommonUtils(stevekung.mods.stevekunglib.utils.CommonUtils) EntityCheeseSpore(stevekung.mods.moreplanets.planets.chalos.entity.projectile.EntityCheeseSpore) FMLPostInitializationEvent(net.minecraftforge.fml.common.event.FMLPostInitializationEvent) WorldClient(net.minecraft.client.multiplayer.WorldClient) stevekung.mods.moreplanets.client.renderer(stevekung.mods.moreplanets.client.renderer) Minecraft(net.minecraft.client.Minecraft) ParticleKoentusMeteor(stevekung.mods.moreplanets.moons.koentus.client.particle.ParticleKoentusMeteor) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) BlocksItemsRegistry(stevekung.mods.moreplanets.utils.BlocksItemsRegistry) FMLPreInitializationEvent(net.minecraftforge.fml.common.event.FMLPreInitializationEvent) FMLInitializationEvent(net.minecraftforge.fml.common.event.FMLInitializationEvent) ColorUtils(stevekung.mods.stevekunglib.utils.ColorUtils) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Entity(net.minecraft.entity.Entity) CompatibilityManagerMP(stevekung.mods.moreplanets.utils.CompatibilityManagerMP) ClientRegistryUtils(stevekung.mods.stevekunglib.utils.client.ClientRegistryUtils) ParticleAlienBerryLeavesSpark(stevekung.mods.moreplanets.planets.nibiru.client.particle.ParticleAlienBerryLeavesSpark) IMorePlanetsBoss(stevekung.mods.moreplanets.utils.IMorePlanetsBoss) ParticleInfectedSpore(stevekung.mods.moreplanets.planets.nibiru.client.particle.ParticleInfectedSpore) EntitySpaceFishHook(stevekung.mods.moreplanets.entity.projectile.EntitySpaceFishHook) BlockColors(net.minecraft.client.renderer.color.BlockColors) EntityRegistration(net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) ItemBlock(net.minecraft.item.ItemBlock) ParticleAlienMinerSpark(stevekung.mods.moreplanets.planets.diona.client.particle.ParticleAlienMinerSpark) EntityRegistry(net.minecraftforge.fml.common.registry.EntityRegistry) Entity(net.minecraft.entity.Entity) EntityVeinBall(stevekung.mods.moreplanets.planets.nibiru.entity.projectile.EntityVeinBall) FMLMessage(net.minecraftforge.fml.common.network.internal.FMLMessage) EntitySmallCheeseSpore(stevekung.mods.moreplanets.planets.chalos.entity.projectile.EntitySmallCheeseSpore) EntityCheeseSpore(stevekung.mods.moreplanets.planets.chalos.entity.projectile.EntityCheeseSpore) WorldClient(net.minecraft.client.multiplayer.WorldClient) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntitySpaceFishHook(stevekung.mods.moreplanets.entity.projectile.EntitySpaceFishHook) EntityRegistration(net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration)

Aggregations

EntityRegistration (net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration)6 Entity (net.minecraft.entity.Entity)4 WorldClient (net.minecraft.client.multiplayer.WorldClient)3 Function (com.google.common.base.Function)2 Minecraft (net.minecraft.client.Minecraft)2 BlockColors (net.minecraft.client.renderer.color.BlockColors)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 Item (net.minecraft.item.Item)2 ItemBlock (net.minecraft.item.ItemBlock)2 BiomeColorHelper (net.minecraft.world.biome.BiomeColorHelper)2 ModelBakeEvent (net.minecraftforge.client.event.ModelBakeEvent)2 ModelRegistryEvent (net.minecraftforge.client.event.ModelRegistryEvent)2 TextureStitchEvent (net.minecraftforge.client.event.TextureStitchEvent)2 ModelLoaderRegistry (net.minecraftforge.client.model.ModelLoaderRegistry)2 FMLClientHandler (net.minecraftforge.fml.client.FMLClientHandler)2 ModContainer (net.minecraftforge.fml.common.ModContainer)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 EntityRegistry (net.minecraftforge.fml.common.registry.EntityRegistry)2 Side (net.minecraftforge.fml.relauncher.Side)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2