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