Search in sources :

Example 1 with EntitySpaceFishHook

use of stevekung.mods.moreplanets.entity.projectile.EntitySpaceFishHook 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);
}
Also used : ParticleAlienMinerSpark(stevekung.mods.moreplanets.module.planets.diona.client.particle.ParticleAlienMinerSpark) BiomeColorHelper(net.minecraft.world.biome.BiomeColorHelper) ModelBakeEvent(net.minecraftforge.client.event.ModelBakeEvent) Item(net.minecraft.item.Item) ModelRegistryEvent(net.minecraftforge.client.event.ModelRegistryEvent) ClientRegisterHelper(stevekung.mods.moreplanets.util.helper.ClientRegisterHelper) ColorHelper(stevekung.mods.moreplanets.util.helper.ColorHelper) ItemRendererTieredRocket(stevekung.mods.moreplanets.util.client.renderer.item.ItemRendererTieredRocket) Side(net.minecraftforge.fml.relauncher.Side) ClientEventHandler(stevekung.mods.moreplanets.core.event.ClientEventHandler) ParticleDarkPortal(stevekung.mods.moreplanets.module.planets.diona.client.particle.ParticleDarkPortal) ParticleFallingDustMP(stevekung.mods.moreplanets.util.client.particle.ParticleFallingDustMP) MPSchematics(stevekung.mods.moreplanets.init.MPSchematics) ParticleInfectedSpore(stevekung.mods.moreplanets.module.planets.nibiru.client.particle.ParticleInfectedSpore) ParticleKoentusMeteor(stevekung.mods.moreplanets.module.moons.koentus.client.particle.ParticleKoentusMeteor) Function(com.google.common.base.Function) ModelLoaderRegistry(net.minecraftforge.client.model.ModelLoaderRegistry) EntitySpawnMessage(net.minecraftforge.fml.common.network.internal.FMLMessage.EntitySpawnMessage) MPItems(stevekung.mods.moreplanets.init.MPItems) ParticleAlienBerry(stevekung.mods.moreplanets.module.planets.nibiru.client.particle.ParticleAlienBerry) FMLClientHandler(net.minecraftforge.fml.client.FMLClientHandler) TileEntityItemStackRenderer(net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ParticleInfectedGuardianAppearance(stevekung.mods.moreplanets.module.planets.nibiru.client.particle.ParticleInfectedGuardianAppearance) EnumParticleTypes(net.minecraft.util.EnumParticleTypes) ParticleLiquidDrip(stevekung.mods.moreplanets.util.client.particle.ParticleLiquidDrip) CompatibilityManagerMP(stevekung.mods.moreplanets.util.CompatibilityManagerMP) ParticleBreakingMC(stevekung.mods.moreplanets.util.client.particle.ParticleBreakingMC) ParticleLavaMC(stevekung.mods.moreplanets.util.client.particle.ParticleLavaMC) EnumParticleTypesMP(stevekung.mods.moreplanets.util.EnumParticleTypesMP) ReflectionHelper(net.minecraftforge.fml.relauncher.ReflectionHelper) WorldClient(net.minecraft.client.multiplayer.WorldClient) IMorePlanetsBoss(stevekung.mods.moreplanets.util.IMorePlanetsBoss) stevekung.mods.moreplanets.client.renderer(stevekung.mods.moreplanets.client.renderer) DionaBlocks(stevekung.mods.moreplanets.module.planets.diona.blocks.DionaBlocks) ImmutableList(com.google.common.collect.ImmutableList) Minecraft(net.minecraft.client.Minecraft) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) TRSRTransformation(net.minecraftforge.common.model.TRSRTransformation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Entity(net.minecraft.entity.Entity) FronosBlocks(stevekung.mods.moreplanets.module.planets.fronos.blocks.FronosBlocks) CommonRegisterHelper(stevekung.mods.moreplanets.util.helper.CommonRegisterHelper) NibiruBlocks(stevekung.mods.moreplanets.module.planets.nibiru.blocks.NibiruBlocks) EntitySpaceFishHook(stevekung.mods.moreplanets.entity.projectile.EntitySpaceFishHook) BlockColors(net.minecraft.client.renderer.color.BlockColors) ParticleCrystallizeFlame(stevekung.mods.moreplanets.module.planets.diona.client.particle.ParticleCrystallizeFlame) ColorizerGrass(net.minecraft.world.ColorizerGrass) EntityRegistration(net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) Particle(net.minecraft.client.particle.Particle) ItemBlock(net.minecraft.item.ItemBlock) EntityRegistry(net.minecraftforge.fml.common.registry.EntityRegistry) Entity(net.minecraft.entity.Entity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntitySpaceFishHook(stevekung.mods.moreplanets.entity.projectile.EntitySpaceFishHook) EntitySpawnMessage(net.minecraftforge.fml.common.network.internal.FMLMessage.EntitySpawnMessage) WorldClient(net.minecraft.client.multiplayer.WorldClient) EntityRegistration(net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration)

Example 2 with EntitySpaceFishHook

use of stevekung.mods.moreplanets.entity.projectile.EntitySpaceFishHook in project MorePlanets by SteveKunG.

the class ItemSpaceFishingRod method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemStack = player.getHeldItem(hand);
    if (player.fishEntity != null) {
        int i = player.fishEntity.handleHookRetraction();
        itemStack.damageItem(i, player);
        player.swingArm(hand);
        if (itemStack.hasTagCompound() && itemStack.getTagCompound().getBoolean("Cast")) {
            itemStack.getTagCompound().setBoolean("Cast", false);
        }
    } else {
        world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
        if (!world.isRemote) {
            EntitySpaceFishHook entityfishhook = new EntitySpaceFishHook(world, player);
            int lure = EnchantmentHelper.getFishingSpeedBonus(itemStack);
            int luck = EnchantmentHelper.getFishingLuckBonus(itemStack);
            if (lure > 0) {
                entityfishhook.setLureSpeed(lure);
            }
            if (luck > 0) {
                entityfishhook.setLuck(luck);
            }
            world.spawnEntity(entityfishhook);
        }
        if (itemStack.hasTagCompound()) {
            itemStack.getTagCompound().setBoolean("Cast", true);
        } else {
            itemStack.setTagCompound(new NBTTagCompound());
            itemStack.getTagCompound().setBoolean("Cast", true);
        }
        player.swingArm(hand);
        player.addStat(StatList.getObjectUseStats(this));
    }
    return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntitySpaceFishHook(stevekung.mods.moreplanets.entity.projectile.EntitySpaceFishHook) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntitySpaceFishHook (stevekung.mods.moreplanets.entity.projectile.EntitySpaceFishHook)2 Function (com.google.common.base.Function)1 ImmutableList (com.google.common.collect.ImmutableList)1 Minecraft (net.minecraft.client.Minecraft)1 WorldClient (net.minecraft.client.multiplayer.WorldClient)1 Particle (net.minecraft.client.particle.Particle)1 BlockColors (net.minecraft.client.renderer.color.BlockColors)1 TileEntityItemStackRenderer (net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer)1 Entity (net.minecraft.entity.Entity)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 Item (net.minecraft.item.Item)1 ItemBlock (net.minecraft.item.ItemBlock)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 EnumParticleTypes (net.minecraft.util.EnumParticleTypes)1 ColorizerGrass (net.minecraft.world.ColorizerGrass)1 BiomeColorHelper (net.minecraft.world.biome.BiomeColorHelper)1 ModelBakeEvent (net.minecraftforge.client.event.ModelBakeEvent)1 ModelRegistryEvent (net.minecraftforge.client.event.ModelRegistryEvent)1 TextureStitchEvent (net.minecraftforge.client.event.TextureStitchEvent)1