Search in sources :

Example 41 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project NetherEx by LogicTechCorp.

the class EventHandler method onBlockBreak.

@SubscribeEvent
public static void onBlockBreak(BlockEvent.BreakEvent event) {
    World world = event.getWorld();
    BlockPos pos = event.getPos();
    IBlockState state = event.getState();
    if (!(event.getPlayer() instanceof FakePlayer)) {
        EntityPlayer player = event.getPlayer();
        if (state.getBlock() == Blocks.MAGMA) {
            if (ConfigHandler.block.magma.turnIntoLava) {
                if (EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) == 0) {
                    world.setBlockState(pos, Blocks.LAVA.getDefaultState(), 3);
                    player.getHeldItemMainhand().damageItem(1, player);
                    event.setCanceled(true);
                }
            }
        }
        if (player.dimension == -1) {
            boolean canSpawn = Arrays.asList(ConfigHandler.entity.nethermite.whitelist).contains(state.getBlock().getRegistryName().toString());
            if (canSpawn && world.rand.nextInt(ConfigHandler.entity.nethermite.chanceOfSpawning) == 0) {
                EntityNethermite nethermite = new EntityNethermite(world);
                nethermite.setPosition((double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D);
                world.spawnEntity(nethermite);
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EntityNethermite(nex.entity.monster.EntityNethermite) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) FakePlayer(net.minecraftforge.common.util.FakePlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 42 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project ImmersiveEngineering by BluSunrize.

the class BotaniaHelper method onPotatoRender.

@SubscribeEvent()
@SideOnly(Side.CLIENT)
public void onPotatoRender(TinyPotatoRenderEvent event) {
    if (event.tile.getWorld() == null)
        return;
    if (revolverEntity == null) {
        revolverEntity = new EntityItem(event.tile.getWorld(), 0.0D, 0.0D, 0.0D, new ItemStack(IEContent.itemRevolver));
        revolverEntity.hoverStart = 0;
    }
    try {
        String formattedName = event.name.replace("_", " ");
        ItemRevolver.SpecialRevolver special = null;
        if (formattedName.equalsIgnoreCase("Mr Damien Hazard") || formattedName.equalsIgnoreCase("Mr Hazard"))
            special = ItemRevolver.specialRevolversByTag.get("dev");
        else if (event.name.equalsIgnoreCase("BluSunrize"))
            special = ItemRevolver.specialRevolversByTag.get("fenrir");
        else {
            if (nameToSpecial.containsKey(event.name.toLowerCase(Locale.ENGLISH))) {
                List<SpecialRevolver> list = nameToSpecial.get(event.name.toLowerCase(Locale.ENGLISH));
                if (list != null && list.size() > 0) {
                    long ticks = event.tile.getWorld() != null ? event.tile.getWorld().getTotalWorldTime() / 100 : 0;
                    special = list.get((int) (ticks % list.size()));
                }
            }
        }
        if (special != null) {
            GlStateManager.pushMatrix();
            ((ItemRevolver) IEContent.itemRevolver).applySpecialCrafting(revolverEntity.getEntityItem(), special);
            GlStateManager.translate(-.16, 1.45, -.2);
            GlStateManager.rotate(-90, 0, 1, 0);
            GlStateManager.rotate(15, 0, 0, 1);
            GlStateManager.rotate(180, 1, 0, 0);
            GlStateManager.scale(.625f, .625f, .625f);
            ClientUtils.mc().getRenderManager().doRenderEntity(revolverEntity, 0, 0, 0, 0, 0, false);
            GlStateManager.popMatrix();
        }
    } catch (Exception e) {
    }
}
Also used : ItemRevolver(blusunrize.immersiveengineering.common.items.ItemRevolver) SpecialRevolver(blusunrize.immersiveengineering.common.items.ItemRevolver.SpecialRevolver) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 43 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Totemic by TeamTotemic.

the class ClientTickHandler method tickEnd.

@SubscribeEvent
public void tickEnd(TickEvent.ClientTickEvent event) {
    if (event.phase == TickEvent.Phase.END && event.type == TickEvent.Type.CLIENT) {
        GuiScreen gui = Minecraft.getMinecraft().currentScreen;
        int ticksToOpen = 10;
        if (gui instanceof GuiLexicon) {
            if (ticksWithLexicaOpen < 0)
                ticksWithLexicaOpen = 0;
            if (ticksWithLexicaOpen < ticksToOpen)
                ticksWithLexicaOpen++;
            if (pageFlipTicks > 0)
                pageFlipTicks--;
        } else {
            pageFlipTicks = 0;
            if (ticksWithLexicaOpen > 0) {
                if (ticksWithLexicaOpen > ticksToOpen)
                    ticksWithLexicaOpen = ticksToOpen;
                ticksWithLexicaOpen--;
            }
        }
    }
}
Also used : GuiLexicon(pokefenn.totemic.client.gui.GuiLexicon) GuiScreen(net.minecraft.client.gui.GuiScreen) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 44 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Totemic by TeamTotemic.

the class EntitySpawn method onEntityJoin.

@SubscribeEvent
public void onEntityJoin(EntityJoinWorldEvent event) {
    if (event.getEntity() instanceof EntitySkeleton) {
        EntitySkeleton entity = (EntitySkeleton) event.getEntity();
        entity.targetTasks.addTask(10, new EntityAINearestAttackableTarget<>(entity, EntityBuffalo.class, true));
    }
}
Also used : EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) EntityBuffalo(pokefenn.totemic.entity.animal.EntityBuffalo) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 45 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Totemic by TeamTotemic.

the class EntityUpdate method onEntityUpdate.

@SubscribeEvent
public void onEntityUpdate(LivingEvent.LivingUpdateEvent event) {
    if (event.getEntityLiving() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getEntityLiving();
        if (player.isPotionActive(ModPotions.batPotion) && !player.capabilities.isCreativeMode && player.isSneaking() && !player.onGround) {
            player.moveRelative(0.0F, 0.0F, 0.5F, 0.1F);
        }
        if (player.isPotionActive(ModPotions.spiderPotion)) {
            PotionEffect pot = player.getActivePotionEffect(ModPotions.spiderPotion);
            if (pot.getDuration() > 10) {
                if (player.isSneaking())
                    player.stepHeight = 0.60001F;
                else
                    player.stepHeight = 1F;
            } else
                player.stepHeight = 0.6F;
            climb(player);
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1135 ItemStack (net.minecraft.item.ItemStack)316 EntityPlayer (net.minecraft.entity.player.EntityPlayer)314 World (net.minecraft.world.World)196 BlockPos (net.minecraft.util.math.BlockPos)179 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)136 IBlockState (net.minecraft.block.state.IBlockState)120 ResourceLocation (net.minecraft.util.ResourceLocation)102 Entity (net.minecraft.entity.Entity)93 Block (net.minecraft.block.Block)86 EntityLivingBase (net.minecraft.entity.EntityLivingBase)84 Minecraft (net.minecraft.client.Minecraft)72 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)66 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)64 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)55 Item (net.minecraft.item.Item)53 EntityItem (net.minecraft.entity.item.EntityItem)48 TileEntity (net.minecraft.tileentity.TileEntity)46 TextComponentString (net.minecraft.util.text.TextComponentString)42 Random (java.util.Random)37