Search in sources :

Example 41 with ItemSword

use of net.minecraft.item.ItemSword 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 42 with ItemSword

use of net.minecraft.item.ItemSword in project SpongeCommon by SpongePowered.

the class ToolTypePropertyStore method getFor.

@Override
protected Optional<ToolTypeProperty> getFor(ItemStack itemStack) {
    if (itemStack.getItem() instanceof ItemTool) {
        final ItemTool tool = (ItemTool) itemStack.getItem();
        final Item.ToolMaterial toolMaterial = tool.toolMaterial;
        return Optional.of(new ToolTypeProperty((ToolType) (Object) toolMaterial));
    } else if (itemStack.getItem() instanceof ItemSword) {
        final ItemSword itemSword = (ItemSword) itemStack.getItem();
        final Item.ToolMaterial swordMaterial = itemSword.material;
        return Optional.of(new ToolTypeProperty((ToolType) (Object) swordMaterial));
    } else if (itemStack.getItem() instanceof ItemHoe) {
        final ItemHoe itemHoe = (ItemHoe) itemStack.getItem();
        final Item.ToolMaterial hoeMaterial = itemHoe.toolMaterial;
        return Optional.of(new ToolTypeProperty((ToolType) (Object) hoeMaterial));
    }
    return Optional.empty();
}
Also used : ItemSword(net.minecraft.item.ItemSword) Item(net.minecraft.item.Item) ItemHoe(net.minecraft.item.ItemHoe) ItemTool(net.minecraft.item.ItemTool) ToolType(org.spongepowered.api.data.type.ToolType) ToolTypeProperty(org.spongepowered.api.data.property.item.ToolTypeProperty)

Example 43 with ItemSword

use of net.minecraft.item.ItemSword in project Armourers-Workshop by RiskyKen.

the class RenderBlockMannequinItems method renderRightArmStack.

public void renderRightArmStack(MannequinFakePlayer fakePlayer, ItemStack stack, ModelBiped targetBiped, RenderManager rm, byte[] extraColours, double distance) {
    Item targetItem = stack.getItem();
    float blockScale = 0.5F;
    float itemScale = 1 - (float) 1 / 3;
    Tessellator tessellator = Tessellator.instance;
    // Movement
    GL11.glTranslatef(-5F * scale, 0F, 0F);
    GL11.glTranslatef(0F, 2F * scale, 0F);
    GL11.glRotated(Math.toDegrees(targetBiped.bipedRightArm.rotateAngleZ), 0F, 0F, 1F);
    GL11.glRotated(Math.toDegrees(targetBiped.bipedRightArm.rotateAngleY), 0F, 1F, 0F);
    GL11.glRotated(Math.toDegrees(targetBiped.bipedRightArm.rotateAngleX), 1F, 0F, 0F);
    GL11.glTranslatef(-2F * scale, 0F, 0F);
    GL11.glTranslatef(0F, 10F * scale, 0F);
    if (SkinNBTHelper.stackHasSkinData(stack)) {
        SkinPointer sp = SkinNBTHelper.getSkinPointerFromStack(stack);
        if (sp.getIdentifier().getSkinType() == SkinTypeRegistry.skinSword | sp.getIdentifier().getSkinType() == SkinTypeRegistry.skinBow) {
            GL11.glRotatef(90, 1, 0, 0);
            GL11.glTranslated(1 * scale, 0 * scale, 2 * scale);
            SkinModelRenderer.INSTANCE.renderEquipmentPartFromStack(stack, null, extraColours, distance, true);
            return;
        }
    }
    GL11.glRotatef(-90, 0, 1, 0);
    GL11.glRotatef(45, 0, 0, 1);
    GL11.glScalef(itemScale, itemScale, itemScale);
    GL11.glRotatef(-335.0F, 0.0F, 0.0F, 1.0F);
    GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F);
    if (targetItem instanceof ItemBlock) {
        GL11.glTranslatef(-3 * scale, 4 * scale, 2 * scale);
        GL11.glScalef(-blockScale, -blockScale, blockScale);
        GL11.glRotatef(30F, 0F, 1F, 0F);
        GL11.glRotatef(130F, 1F, 0F, 0F);
    } else {
        if (!(targetItem instanceof ItemSword)) {
            // GL11.glRotatef(90F, 0F, 1F, 0F);
            GL11.glScalef(0.75F, 0.75F, 0.75F);
        }
    }
    if (targetItem.requiresMultipleRenderPasses()) {
        int passes = targetItem.getRenderPasses(stack.getItemDamage());
        for (int i = 0; i < passes; i++) {
            int c = targetItem.getColorFromItemStack(stack, i);
            float r = (float) (c >> 16 & 255) / 255.0F;
            float g = (float) (c >> 8 & 255) / 255.0F;
            float b = (float) (c & 255) / 255.0F;
            GL11.glColor4f(r, g, b, 1F);
            rm.itemRenderer.renderItem(fakePlayer, stack, i, ItemRenderType.EQUIPPED);
        }
        GL11.glColor4f(1F, 1F, 1F, 1F);
    } else {
        int c = targetItem.getColorFromItemStack(stack, 0);
        float r = (float) (c >> 16 & 255) / 255.0F;
        float g = (float) (c >> 8 & 255) / 255.0F;
        float b = (float) (c & 255) / 255.0F;
        GL11.glColor4f(r, g, b, 1F);
        rm.itemRenderer.renderItem(fakePlayer, stack, 0, ItemRenderType.EQUIPPED);
        GL11.glColor4f(1F, 1F, 1F, 1F);
    }
}
Also used : ItemSword(net.minecraft.item.ItemSword) Item(net.minecraft.item.Item) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) Tessellator(net.minecraft.client.renderer.Tessellator) ItemBlock(net.minecraft.item.ItemBlock)

Example 44 with ItemSword

use of net.minecraft.item.ItemSword in project Armourers-Workshop by RiskyKen.

the class RenderBlockMannequinItems method renderLeftArmStack.

public void renderLeftArmStack(MannequinFakePlayer fakePlayer, ItemStack stack, ModelBiped targetBiped, RenderManager rm, byte[] extraColours, double distance) {
    Item targetItem = stack.getItem();
    float blockScale = 0.5F;
    float itemScale = 1 - (float) 1 / 3;
    // Movement
    GL11.glTranslatef(5F * scale, 0F, 0F);
    GL11.glTranslatef(0F, 2F * scale, 0F);
    GL11.glRotated(Math.toDegrees(targetBiped.bipedLeftArm.rotateAngleZ), 0F, 0F, 1F);
    GL11.glRotated(Math.toDegrees(targetBiped.bipedLeftArm.rotateAngleY), 0F, 1F, 0F);
    GL11.glRotated(Math.toDegrees(targetBiped.bipedLeftArm.rotateAngleX), 1F, 0F, 0F);
    GL11.glTranslatef(1F * scale, 0F, 0F);
    GL11.glTranslatef(0F, 10F * scale, 0F);
    if (SkinNBTHelper.stackHasSkinData(stack)) {
        SkinPointer sp = SkinNBTHelper.getSkinPointerFromStack(stack);
        if (sp.getIdentifier().getSkinType() == SkinTypeRegistry.skinSword | sp.getIdentifier().getSkinType() == SkinTypeRegistry.skinBow) {
            GL11.glRotatef(90, 1, 0, 0);
            GL11.glTranslated(0 * scale, 0 * scale, 2 * scale);
            GL11.glScalef(-1, 1, 1);
            GL11.glCullFace(GL11.GL_FRONT);
            SkinModelRenderer.INSTANCE.renderEquipmentPartFromStack(stack, null, extraColours, distance, true);
            GL11.glCullFace(GL11.GL_BACK);
            return;
        }
    }
    GL11.glRotatef(-90, 0, 1, 0);
    GL11.glRotatef(45, 0, 0, 1);
    GL11.glScalef(itemScale, itemScale, itemScale);
    GL11.glRotatef(-335.0F, 0.0F, 0.0F, 1.0F);
    GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F);
    if (targetItem instanceof ItemBlock) {
        GL11.glTranslatef(-2 * scale, 4 * scale, 2 * scale);
        GL11.glScalef(-blockScale, -blockScale, blockScale);
        GL11.glRotatef(50F, 0F, 1F, 0F);
        GL11.glRotatef(130F, 1F, 0F, 0F);
    } else {
        if (!(targetItem instanceof ItemSword)) {
            // GL11.glRotatef(-45F, 1F, 0F, 1F);
            GL11.glScalef(0.75F, 0.75F, 0.75F);
        }
    }
    if (targetItem.requiresMultipleRenderPasses()) {
        int passes = targetItem.getRenderPasses(stack.getItemDamage());
        for (int i = 0; i < passes; i++) {
            int c = targetItem.getColorFromItemStack(stack, i);
            float r = (float) (c >> 16 & 255) / 255.0F;
            float g = (float) (c >> 8 & 255) / 255.0F;
            float b = (float) (c & 255) / 255.0F;
            GL11.glColor4f(r, g, b, 1F);
            rm.itemRenderer.renderItem(fakePlayer, stack, i, ItemRenderType.EQUIPPED);
        }
        GL11.glColor4f(1F, 1F, 1F, 1F);
    } else {
        int c = targetItem.getColorFromItemStack(stack, 0);
        float r = (float) (c >> 16 & 255) / 255.0F;
        float g = (float) (c >> 8 & 255) / 255.0F;
        float b = (float) (c & 255) / 255.0F;
        GL11.glColor4f(r, g, b, 1F);
        rm.itemRenderer.renderItem(fakePlayer, stack, 0, ItemRenderType.EQUIPPED);
        GL11.glColor4f(1F, 1F, 1F, 1F);
    }
}
Also used : ItemSword(net.minecraft.item.ItemSword) Item(net.minecraft.item.Item) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ItemBlock(net.minecraft.item.ItemBlock)

Example 45 with ItemSword

use of net.minecraft.item.ItemSword in project Minechem by iopleke.

the class PotionCoatingRecipe method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack s = inv.getStackInSlot(i);
        if (s != null && s.getItem() instanceof ItemSword) {
            for (int j = 0; j < inv.getSizeInventory(); j++) {
                ItemStack s2 = inv.getStackInSlot(j);
                if (s2 != null && s2.getItem() instanceof MoleculeItem && PharmacologyEffectRegistry.hasEffect(MoleculeEnum.getById(s2.getItemDamage()))) {
                    NBTTagList l = s2.getEnchantmentTagList();
                    int level = 0;
                    if (l != null) {
                        for (int k = 0; k < l.tagCount(); k++) {
                            NBTTagCompound tag = l.getCompoundTagAt(k);
                            if (tag.getShort("id") == PotionEnchantmentCoated.chemLookup.get(MoleculeEnum.getById(s2.getItemDamage())).effectId) {
                                level = tag.getShort("lvl");
                                ItemStack result = s.copy();
                                result.getEnchantmentTagList().getCompoundTagAt(k).setInteger("lvl", level + 1);
                            }
                        }
                    }
                    ItemStack result = s.copy();
                    result.addEnchantment(PotionEnchantmentCoated.chemLookup.get(MoleculeEnum.getById(s2.getItemDamage())), 1);
                    return result;
                }
            }
        }
    }
    return null;
}
Also used : ItemSword(net.minecraft.item.ItemSword) NBTTagList(net.minecraft.nbt.NBTTagList) MoleculeItem(minechem.item.molecule.MoleculeItem) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemSword (net.minecraft.item.ItemSword)76 ItemStack (net.minecraft.item.ItemStack)53 Item (net.minecraft.item.Item)25 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)23 EntityPlayer (net.minecraft.entity.player.EntityPlayer)22 ItemTool (net.minecraft.item.ItemTool)21 ItemHoe (net.minecraft.item.ItemHoe)18 IBlockState (net.minecraft.block.state.IBlockState)17 ItemBow (net.minecraft.item.ItemBow)15 Entity (net.minecraft.entity.Entity)13 Block (net.minecraft.block.Block)9 EntityLivingBase (net.minecraft.entity.EntityLivingBase)8 ItemAxe (net.minecraft.item.ItemAxe)8 ItemBlock (net.minecraft.item.ItemBlock)8 World (net.minecraft.world.World)7 ItemArmor (net.minecraft.item.ItemArmor)6 ItemFishingRod (net.minecraft.item.ItemFishingRod)6 DamageSource (net.minecraft.util.DamageSource)6 ItemDoor (net.minecraft.item.ItemDoor)5 ItemShield (net.minecraft.item.ItemShield)5