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);
}
}
}
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);
}
}
}
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);
}
}
}
}
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);
}
}
}
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);
}
}
}
}
Aggregations