use of net.minecraft.item.ItemShield in project SilentGems by SilentChaos512.
the class EquipmentTooltips method renderForShield.
private void renderForShield(RenderTooltipEvent.PostText event, ItemStack stack) {
Minecraft mc = Minecraft.getMinecraft();
FontRenderer fontRenderer = event.getFontRenderer();
ItemStack currentEquip = mc.player.getHeldItemMainhand();
double scale = 0.75;
int x = (int) (event.getX() / scale);
int y = (int) ((event.getY() - 16) / scale);
int durability = getDurability(stack, 0);
int equippedDurability = getDurability(currentEquip, durability);
float magicProtection = stack.getItem() instanceof ItemGemShield ? 100f * ToolHelper.getMagicProtection(stack) : 0f;
float equippedMagicProtection = currentEquip.getItem() instanceof ItemGemShield ? 100f * ToolHelper.getMagicProtection(currentEquip) : 0f;
boolean bothAreShield = stack.getItem() instanceof ItemShield && currentEquip.getItem() instanceof ItemShield;
GlStateManager.pushMatrix();
GlStateManager.color(1f, 1f, 1f, 1f);
GlStateManager.scale(scale, scale, scale);
mc.renderEngine.bindTexture(TEXTURE);
// Durability
x = renderStat(mc, fontRenderer, 0, x, y, durability, equippedDurability, StackHelper.isValid(currentEquip));
x = renderStat(mc, fontRenderer, 9, x, y, magicProtection, equippedMagicProtection, bothAreShield);
lastWidth = (int) (x * scale - event.getX());
GlStateManager.popMatrix();
}
use of net.minecraft.item.ItemShield in project takumicraft by TNTModders.
the class TakumiEvents method damage.
@SubscribeEvent
public void damage(LivingAttackEvent event) {
/* if (event.getSource().isExplosion() && event.getSource().getTrueSource() instanceof EntityTakumiArrow &&
event.getSource().getImmediateSource() == event.getEntity()) {
event.setCanceled(true);
} else*/
if (!event.getSource().isMagicDamage() && event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityLivingBase) {
ItemStack stack = ((EntityLivingBase) event.getSource().getTrueSource()).getHeldItemMainhand();
if (!EnchantmentHelper.getEnchantments(stack).isEmpty() && EnchantmentHelper.getEnchantments(stack).containsKey(TakumiEnchantmentCore.ANTI_POWERED) && event.getEntityLiving() instanceof EntityCreeper && ((EntityCreeper) event.getEntityLiving()).getPowered()) {
event.getEntityLiving().attackEntityFrom(DamageSource.causeMobDamage((EntityLivingBase) event.getSource().getTrueSource()).setMagicDamage(), 20f);
TakumiUtils.takumiSetPowered((EntityCreeper) event.getEntityLiving(), false);
if (event.getSource().getTrueSource() instanceof EntityPlayerMP) {
TakumiUtils.giveAdvancementImpossible((EntityPlayerMP) event.getSource().getTrueSource(), new ResourceLocation(TakumiCraftCore.MODID, "creeperbomb"), new ResourceLocation(TakumiCraftCore.MODID, "disarmament"));
}
}
}
if (event.getSource().isExplosion() && event.getSource() != DamageSource.GENERIC && event.getEntityLiving().getActiveItemStack().getItem() instanceof ItemShield) {
if (event.getEntityLiving().getActiveItemStack().getItem() != TakumiItemCore.TAKUMI_SHIELD) {
event.getEntityLiving().attackEntityFrom(DamageSource.GENERIC.setExplosion().setDamageIsAbsolute(), event.getAmount());
}
}
}
use of net.minecraft.item.ItemShield in project SilentGems by SilentChaos512.
the class EquipmentTooltips method onRenderTooltip.
@SubscribeEvent
public void onRenderTooltip(RenderTooltipEvent.PostText event) {
ItemStack stack = event.getStack();
Item item = stack.getItem();
boolean isTinkersHarvestTool = isTinkersLoaded && item instanceof slimeknights.tconstruct.library.tools.AoeToolCore;
boolean isTinkersWeapon = isTinkersLoaded && item instanceof slimeknights.tconstruct.library.tools.SwordCore;
boolean isTinkersBow = isTinkersLoaded && item instanceof slimeknights.tconstruct.library.tools.ranged.BowCore;
// Tools (pickaxes, shovels, axes, and more)
if (item instanceof ItemTool || item instanceof ItemHoe || item instanceof ItemShears || item instanceof ItemFishingRod || isTinkersHarvestTool) {
renderBackground(event);
renderForTool(event, stack);
} else // Swords
if (item instanceof ItemSword || isTinkersWeapon) {
boolean isCaster = item instanceof ITool && ToolHelper.getToolTier(stack).ordinal() >= EnumMaterialTier.SUPER.ordinal();
renderBackground(event);
renderForWeapon(event, stack);
} else // Bows
if (item instanceof ItemBow || isTinkersBow) {
renderBackground(event);
renderForBow(event, stack);
} else // Shields
if (item instanceof ItemShield) {
renderBackground(event);
renderForShield(event, stack);
} else // Armor
if (item instanceof ItemArmor) {
renderBackground(event);
renderForArmor(event, stack);
}
// Unknown
}
use of net.minecraft.item.ItemShield in project BetterWithAddons by DaedalusGame.
the class EntityKarateZombie method disarm.
private void disarm(EntityLivingBase entity) {
ItemStack mainhand = entity.getHeldItem(EnumHand.MAIN_HAND);
ItemStack offhand = entity.getHeldItem(EnumHand.OFF_HAND);
if (!(mainhand.getItem() instanceof ItemShield) && !(offhand.getItem() instanceof ItemShield)) {
if (!EnchantmentHelper.hasBindingCurse(mainhand)) {
entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY);
entity.entityDropItem(mainhand, 0);
}
if (!EnchantmentHelper.hasBindingCurse(offhand)) {
entity.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY);
entity.entityDropItem(offhand, 0);
}
}
}
Aggregations