Search in sources :

Example 1 with ItemShield

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();
}
Also used : ItemShield(net.minecraft.item.ItemShield) ItemGemShield(net.silentchaos512.gems.item.tool.ItemGemShield) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft)

Example 2 with ItemShield

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());
        }
    }
}
Also used : ItemShield(net.minecraft.item.ItemShield) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with ItemShield

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
}
Also used : ItemSword(net.minecraft.item.ItemSword) ItemTool(net.minecraft.item.ItemTool) ItemShield(net.minecraft.item.ItemShield) ItemFishingRod(net.minecraft.item.ItemFishingRod) ItemArmor(net.minecraft.item.ItemArmor) ITool(net.silentchaos512.gems.api.ITool) ItemBow(net.minecraft.item.ItemBow) Item(net.minecraft.item.Item) ItemHoe(net.minecraft.item.ItemHoe) ItemShears(net.minecraft.item.ItemShears) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with ItemShield

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);
        }
    }
}
Also used : ItemShield(net.minecraft.item.ItemShield) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemShield (net.minecraft.item.ItemShield)4 ItemStack (net.minecraft.item.ItemStack)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 Minecraft (net.minecraft.client.Minecraft)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 Item (net.minecraft.item.Item)1 ItemArmor (net.minecraft.item.ItemArmor)1 ItemBow (net.minecraft.item.ItemBow)1 ItemFishingRod (net.minecraft.item.ItemFishingRod)1 ItemHoe (net.minecraft.item.ItemHoe)1 ItemShears (net.minecraft.item.ItemShears)1 ItemSword (net.minecraft.item.ItemSword)1 ItemTool (net.minecraft.item.ItemTool)1 ITool (net.silentchaos512.gems.api.ITool)1 ItemGemShield (net.silentchaos512.gems.item.tool.ItemGemShield)1