Search in sources :

Example 1 with Item

use of net.minecraft.item.Item in project BetterStorage by copygirl.

the class SlotArmorBackpack method isItemValid.

@Override
public boolean isItemValid(ItemStack stack) {
    if (stack == null)
        return false;
    EntityPlayer player = ((InventoryPlayer) inventory).player;
    Item item = stack.getItem();
    if ((item instanceof ItemBackpack) && !ItemBackpack.canEquipBackpack(player))
        return false;
    return item.isValidArmor(stack, armorType, player);
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) Item(net.minecraft.item.Item) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemBackpack(net.mcft.copy.betterstorage.item.ItemBackpack)

Example 2 with Item

use of net.minecraft.item.Item in project BetterStorage by copygirl.

the class RecipeInputBase method craft.

@Override
public void craft(ItemStack input, ContainerInfo containerInfo) {
    if (input == null)
        return;
    Item item = input.getItem();
    ItemStack containerItem = item.getContainerItem(input.copy());
    boolean doesLeaveCrafting = item.doesContainerItemLeaveCraftingGrid(input);
    containerInfo.set(containerItem, doesLeaveCrafting);
    input.stackSize -= getAmount();
}
Also used : Item(net.minecraft.item.Item) ItemStack(net.minecraft.item.ItemStack)

Example 3 with Item

use of net.minecraft.item.Item in project BetterStorage by copygirl.

the class RenderUtils method renderItemIn3d.

public static void renderItemIn3d(ItemStack stack) {
    TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
    // Not sure why but this can be null when the world loads.
    if (textureManager == null)
        return;
    Item item = stack.getItem();
    GL11.glPushMatrix();
    Tessellator tessellator = Tessellator.instance;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glTranslatef(-0.5F, -0.5F, 1 / 32.0F);
    int passes = item.getRenderPasses(stack.getItemDamage());
    for (int pass = 0; pass < passes; pass++) {
        textureManager.bindTexture(((stack.getItemSpriteNumber() == 0) ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture));
        IIcon icon = item.getIcon(stack, pass);
        float minU = icon.getMinU();
        float maxU = icon.getMaxU();
        float minV = icon.getMinV();
        float maxV = icon.getMaxV();
        RenderUtils.setColorFromInt(item.getColorFromItemStack(stack, pass));
        ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), 0.0625F);
    }
    if (stack.hasEffect(0)) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        textureManager.bindTexture(glint);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
        float f7 = 0.76F;
        GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        float f8 = 0.125F;
        GL11.glScalef(f8, f8, f8);
        float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
        GL11.glTranslatef(f9, 0.0F, 0.0F);
        GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        GL11.glScalef(f8, f8, f8);
        f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F;
        GL11.glTranslatef(-f9, 0.0F, 0.0F);
        GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
    }
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}
Also used : Item(net.minecraft.item.Item) TextureManager(net.minecraft.client.renderer.texture.TextureManager) Tessellator(net.minecraft.client.renderer.Tessellator) IIcon(net.minecraft.util.IIcon)

Example 4 with Item

use of net.minecraft.item.Item in project BetterStorage by copygirl.

the class CratePileData method fromCompound.

public static CratePileData fromCompound(CratePileCollection collection, int crateId, NBTTagCompound compound) {
    int numCrates = compound.getShort("numCrates");
    CratePileData pileData = new CratePileData(collection, crateId, numCrates);
    NBTTagList stacks = compound.getTagList("stacks", NBT.TAG_COMPOUND);
    for (int j = 0; j < stacks.tagCount(); j++) {
        NBTTagCompound stackCompound = stacks.getCompoundTagAt(j);
        Item item = Item.getItemById(stackCompound.getShort("id"));
        int count = stackCompound.getInteger("Count");
        int damage = stackCompound.getShort("Damage");
        ItemStack stack = new ItemStack(item, count, damage);
        if (stackCompound.hasKey("tag"))
            stack.stackTagCompound = stackCompound.getCompoundTag("tag");
        if (stack.getItem() != null)
            pileData.getContents().set(new ItemIdentifier(stack), stack.stackSize);
    }
    if (compound.hasKey("map"))
        pileData.map = CratePileMap.fromCompound(compound.getCompoundTag("map"));
    return pileData;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) Item(net.minecraft.item.Item) ItemIdentifier(net.mcft.copy.betterstorage.misc.ItemIdentifier) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 5 with Item

use of net.minecraft.item.Item in project BluePower by Qmunity.

the class BlockEngine method onBlockActivated.

@SuppressWarnings("cast")
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
    if (player.inventory.getCurrentItem() != null) {
        Item item = player.inventory.getCurrentItem().getItem();
        if (item == BPItems.screwdriver) {
            if (!world.isRemote) {
                int direction = 0;
                int facing = 0;
                if (player.rotationPitch > 45) {
                    facing = 5;
                } else if (player.rotationPitch < -45) {
                    facing = 4;
                } else {
                    facing = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
                }
                TileEngine engine = (TileEngine) world.getTileEntity(x, y, z);
                if (facing == 0) {
                    if (player.isSneaking())
                        direction = ForgeDirection.NORTH.ordinal();
                    direction = ForgeDirection.SOUTH.ordinal();
                } else if (facing == 1) {
                    if (player.isSneaking())
                        direction = ForgeDirection.EAST.ordinal();
                    direction = ForgeDirection.WEST.ordinal();
                } else if (facing == 2) {
                    if (player.isSneaking())
                        direction = ForgeDirection.SOUTH.ordinal();
                    direction = ForgeDirection.NORTH.ordinal();
                } else if (facing == 3) {
                    if (player.isSneaking())
                        direction = ForgeDirection.WEST.ordinal();
                    direction = ForgeDirection.EAST.ordinal();
                } else if (facing == 4) {
                    if (player.isSneaking())
                        direction = ForgeDirection.DOWN.ordinal();
                    direction = ForgeDirection.UP.ordinal();
                } else if (facing == 5) {
                    if (player.isSneaking())
                        direction = ForgeDirection.UP.ordinal();
                    direction = ForgeDirection.DOWN.ordinal();
                }
                engine.setOrientation(direction);
                world.markBlockForUpdate(x, y, z);
            }
        }
    }
    return false;
}
Also used : Item(net.minecraft.item.Item) TileEngine(com.bluepowermod.tile.tier3.TileEngine)

Aggregations

Item (net.minecraft.item.Item)191 ItemStack (net.minecraft.item.ItemStack)116 Block (net.minecraft.block.Block)69 ResourceLocation (net.minecraft.util.ResourceLocation)32 ArrayList (java.util.ArrayList)29 EntityItem (net.minecraft.entity.item.EntityItem)22 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)18 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)18 ItemBlock (net.minecraft.item.ItemBlock)16 HashMap (java.util.HashMap)13 IBlockState (net.minecraft.block.state.IBlockState)12 List (java.util.List)11 TileEntity (net.minecraft.tileentity.TileEntity)11 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 FluidStack (net.minecraftforge.fluids.FluidStack)8 Map (java.util.Map)7 Init (cpw.mods.fml.common.Mod.Init)6 World (net.minecraft.world.World)6 SideOnly (cpw.mods.fml.relauncher.SideOnly)5 Method (java.lang.reflect.Method)5