@SubscribeEvent public void onEntityConstructing(EntityConstructing event) { if (event.entity instanceof EntityLivingBase && ZSSEntityInfo.get((EntityLivingBase) event.entity) == null) { ZSSEntityInfo.register((EntityLivingBase) event.entity); } if (event.entity instanceof EntityVillager && ZSSVillagerInfo.get((EntityVillager) event.entity) == null) { ZSSVillagerInfo.register((EntityVillager) event.entity); } if (event.entity instanceof EntityPlayer && ZSSPlayerInfo.get((EntityPlayer) event.entity) == null) { ZSSPlayerInfo.register((EntityPlayer) event.entity); } }
@Override public void renderOverlay(ScaledResolution resolution) { int xPos = Config.isBuffBarLeft ? 2 : resolution.getScaledWidth() - (ICON_SPACING + 2); int yPos = 2; int offset = 0; int increment = Config.isBuffBarHorizontal && !Config.isBuffBarLeft ? -ICON_SPACING : ICON_SPACING; Collection<BuffBase> collection = ZSSEntityInfo.get(mc.thePlayer).getActiveBuffsMap().values(); if (!collection.isEmpty()) { GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); // alpha test and blend needed due to vanilla or Forge rendering bug GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); mc.getTextureManager().bindTexture(textures); for (Iterator<BuffBase> iterator = ZSSEntityInfo.get(mc.thePlayer).getActiveBuffsMap().values().iterator(); iterator.hasNext(); offset = increment) { BuffBase buff = iterator.next(); int index = buff.getIconIndex(); xPos += (Config.isBuffBarHorizontal ? offset : 0); yPos += (Config.isBuffBarHorizontal ? 0 : offset); drawTexturedModalRect( xPos, yPos, index % ICONS_PER_ROW * ICON_SIZE, index / ICONS_PER_ROW * ICON_SIZE, ICON_SIZE, ICON_SIZE); if (buff.displayArrow()) { drawTexturedModalRect( xPos, yPos, buff.isDebuff() ? ICON_SIZE : 0, 0, ICON_SIZE, ICON_SIZE); } } GL11.glPopAttrib(); } }
@SubscribeEvent public void onEntityJoinWorld(EntityJoinWorldEvent event) { if (!event.entity.worldObj.isRemote) { if (event.entity instanceof EntityPlayer) { ZSSEntityInfo.get((EntityPlayer) event.entity).onJoinWorld(); ZSSPlayerInfo.get((EntityPlayer) event.entity).onJoinWorld(); } else if (event.entity.getClass() == EntityVillager.class) { EntityGoron.doVillagerSpawn((EntityVillager) event.entity, event.entity.worldObj); } if (!Config.areVanillaBuffsDisabled() && event.entity instanceof EntityLivingBase) { initBuffs((EntityLivingBase) event.entity); } } }
@SubscribeEvent public void onLivingUpdate(LivingUpdateEvent event) { if (event.entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entity; ZSSPlayerInfo.get(player).onUpdate(); if (player.motionY < -0.25D) { boolean flag = player.getHeldItem() != null && player.getHeldItem().getItem() == ZSSItems.rocsFeather; if (flag || (player.getCurrentArmor(ArmorIndex.WORN_HELM) != null && player.getCurrentArmor(ArmorIndex.WORN_HELM).getItem() == ZSSItems.maskDeku)) { player.motionY = -0.25D; player.fallDistance = 0.0F; } } } if (event.entity instanceof EntityLivingBase) { ZSSEntityInfo.get((EntityLivingBase) event.entity).onUpdate(); } if (event.entity instanceof EntityVillager) { ZSSVillagerInfo.get((EntityVillager) event.entity).onUpdate(); } }
/** Applies permanent buffs / debuffs to vanilla mobs */ private void initBuffs(EntityLivingBase entity) { if (!ZSSEntityInfo.get(entity).getActiveBuffsMap().isEmpty()) { return; } // double damage from cold effects, highly resistant to fire damage if (entity.isImmuneToFire()) { ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_FIRE, Integer.MAX_VALUE, 75); ZSSEntityInfo.get(entity).applyBuff(Buff.WEAKNESS_COLD, Integer.MAX_VALUE, 100); } if (entity.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) { if (!entity.isImmuneToFire()) { ZSSEntityInfo.get(entity).applyBuff(Buff.WEAKNESS_FIRE, Integer.MAX_VALUE, 50); } ZSSEntityInfo.get(entity).applyBuff(Buff.WEAKNESS_HOLY, Integer.MAX_VALUE, 300); ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_COLD, Integer.MAX_VALUE, 50); ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_STUN, Integer.MAX_VALUE, 50); } if (entity instanceof EntityGolem) { ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_COLD, Integer.MAX_VALUE, 100); ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_STUN, Integer.MAX_VALUE, 100); } if (entity instanceof EntityWitch) { ZSSEntityInfo.get(entity).applyBuff(Buff.RESIST_MAGIC, Integer.MAX_VALUE, 75); } if (entity instanceof EntityWither) { ZSSEntityInfo.get(entity).removeBuff(Buff.WEAKNESS_COLD); } }
@SubscribeEvent public void onClonePlayer(PlayerEvent.Clone event) { // Can't send update packets from here - use EntityJoinWorldEvent ZSSEntityInfo.get(event.entityPlayer).copy(ZSSEntityInfo.get(event.original)); ZSSPlayerInfo.get(event.entityPlayer).copy(ZSSPlayerInfo.get(event.original)); }