Search in sources :

Example 36 with SubscribeEvent

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

the class EventHandler method onCropPreGrow.

@SubscribeEvent
public static void onCropPreGrow(BlockEvent.CropGrowEvent.Pre event) {
    World world = event.getWorld();
    BlockPos pos = event.getPos();
    IBlockState state = event.getState();
    if (ConfigHandler.block.soulSand.doesNetherwartUseNewGrowthSystem && state.getBlock() == Blocks.NETHER_WART) {
        if (world.getBlockState(pos.down()) == NetherExBlocks.BLOCK_SAND_SOUL_TILLED.getDefaultState().withProperty(BlockTilledSoulSand.MOISTURE, 7)) {
            event.setResult(Event.Result.ALLOW);
        } else {
            event.setResult(Event.Result.DENY);
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 37 with SubscribeEvent

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

the class EventHandler method onLivingHeal.

@SubscribeEvent
public static void onLivingHeal(LivingHealEvent event) {
    Entity entity = event.getEntity();
    World world = entity.getEntityWorld();
    BlockPos pos = entity.getPosition();
    if (entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        if (!player.isPotionActive(MobEffects.REGENERATION) && !player.isPotionActive(MobEffects.ABSORPTION) && player.isPotionActive(NetherExEffects.FROSTBITE)) {
            event.setCanceled(true);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 38 with SubscribeEvent

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

the class EventHandler method onLivingAttacked.

@SubscribeEvent
public static void onLivingAttacked(LivingAttackEvent event) {
    EntityLivingBase entity = (EntityLivingBase) event.getEntity();
    World world = entity.getEntityWorld();
    BlockPos pos = entity.getPosition();
    DamageSource source = event.getSource();
    if (source.isFireDamage()) {
        if (!entity.isImmuneToFire() && entity.isRiding() && entity.getRidingEntity() instanceof EntityObsidianBoat) {
            event.setCanceled(true);
        }
    }
    if (entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        if (source.isFireDamage()) {
            if (ArmorUtil.isWearingFullArmorSet(player, NetherExMaterials.ARMOR_HIDE_SALAMANDER)) {
                event.setCanceled(true);
            }
        }
        if (player.dimension == -1) {
            if (source == DamageSource.LAVA && player.isPotionActive(MobEffects.FIRE_RESISTANCE)) {
                player.addStat(NetherExAchievements.STAYIN_FROSTY);
            }
        }
    }
}
Also used : DamageSource(net.minecraft.util.DamageSource) EntityObsidianBoat(nex.entity.item.EntityObsidianBoat) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 39 with SubscribeEvent

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

the class EventHandler method onBoneMealUse.

@SubscribeEvent
public static void onBoneMealUse(BonemealEvent event) {
    World world = event.getWorld();
    BlockPos pos = event.getPos();
    IBlockState state = event.getBlock();
    EntityPlayer player = event.getEntityPlayer();
    if (player.getHeldItem(EnumHand.MAIN_HAND).getItem() == NetherExItems.ITEM_DUST_WITHER) {
        if (state.getBlock() == Blocks.NETHER_WART) {
            int age = state.getValue(BlockNetherWart.AGE);
            if (age < 3) {
                state = state.withProperty(BlockNetherWart.AGE, age + 1);
                world.setBlockState(pos, state);
                event.setResult(Event.Result.ALLOW);
            }
        } else if (state.getBlock() instanceof IGrowable) {
            IGrowable growable = (IGrowable) state.getBlock();
            if (growable.canGrow(world, pos, state, world.isRemote)) {
                growable.grow(world, world.rand, pos, state);
            }
        } else {
            event.setCanceled(true);
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IGrowable(net.minecraft.block.IGrowable) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 40 with SubscribeEvent

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

the class EventHandler method onLivingDeath.

@SubscribeEvent
public static void onLivingDeath(LivingDeathEvent event) {
    Entity entity = event.getEntity();
    World world = entity.getEntityWorld();
    BlockPos pos = entity.getPosition();
    DamageSource source = event.getSource();
    if (entity instanceof AbstractSkeleton) {
        if (source.getSourceOfDamage() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) source.getSourceOfDamage();
            if (ArmorUtil.isWearingFullArmorSet(player, NetherExMaterials.ARMOR_BONE_WITHERED)) {
                player.addStat(NetherExAchievements.FROM_WITHIN);
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) AbstractSkeleton(net.minecraft.entity.monster.AbstractSkeleton) DamageSource(net.minecraft.util.DamageSource) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) 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