Java Code Examples for net.minecraft.item.Item.getItemById()

The following are Jave code examples for showing how to use getItemById() of the net.minecraft.item.Item class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Backmemed   File: PacketBuffer.java   View Source Code Vote up 6 votes
/**
 * Reads an ItemStack from this buffer
 */
public ItemStack readItemStackFromBuffer() throws IOException
{
    int i = this.readShort();

    if (i < 0)
    {
        return ItemStack.field_190927_a;
    }
    else
    {
        int j = this.readByte();
        int k = this.readShort();
        ItemStack itemstack = new ItemStack(Item.getItemById(i), j, k);
        itemstack.setTagCompound(this.readNBTTagCompoundFromBuffer());
        return itemstack;
    }
}
 
Example 2
Project: minecraft-quiverbow   File: Helper_Client.java   View Source Code Vote up 6 votes
public static void setTurretInventory(int entityID, int itemID, int itemSlot, int metadata) 
{
	Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(entityID);
	
	if (entity == null) { return; }	// Doesn't exist? Shame.
	
	if (entity instanceof Entity_AA)
	{
		Entity_AA turret = (Entity_AA) entity;
		
		if (itemSlot >= turret.storage.length)	// Received a slot that is higher than what we got, so assuming that this turret has a storage upgrade
		{
			AI_Properties.applyStorageUpgrade(turret);	// Safeguard
		}
		
		if (itemID == -1)
		{
			turret.storage[itemSlot] = null;	// Empty
		}
		else
		{
			turret.storage[itemSlot] = new ItemStack(Item.getItemById(itemID), 1, metadata);	// There ya go. Now the client knows about that too.
		}
	}
}
 
Example 3
Project: pnc-repressurized   File: ItemPneumaticArmor.java   View Source Code Vote up 5 votes
@Nonnull
public static ItemStack getSearchedStack(ItemStack helmetStack) {
    if (helmetStack.isEmpty() || !NBTUtil.hasTag(helmetStack, "SearchStack")) return ItemStack.EMPTY;
    NBTTagCompound tag = NBTUtil.getCompoundTag(helmetStack, "SearchStack");
    if (tag.getInteger("itemID") == -1) return ItemStack.EMPTY;
    return new ItemStack(Item.getItemById(tag.getInteger("itemID")), 1, tag.getInteger("itemDamage"));
}
 
Example 4
Project: DecompiledMinecraft   File: TileEntityFlowerPot.java   View Source Code Vote up 5 votes
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);

    if (compound.hasKey("Item", 8))
    {
        this.flowerPotItem = Item.getByNameOrId(compound.getString("Item"));
    }
    else
    {
        this.flowerPotItem = Item.getItemById(compound.getInteger("Item"));
    }

    this.flowerPotData = compound.getInteger("Data");
}
 
Example 5
Project: DecompiledMinecraft   File: TileEntityFlowerPot.java   View Source Code Vote up 5 votes
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);

    if (compound.hasKey("Item", 8))
    {
        this.flowerPotItem = Item.getByNameOrId(compound.getString("Item"));
    }
    else
    {
        this.flowerPotItem = Item.getItemById(compound.getInteger("Item"));
    }

    this.flowerPotData = compound.getInteger("Data");
}
 
Example 6
Project: Backmemed   File: TileEntityFlowerPot.java   View Source Code Vote up 5 votes
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);

    if (compound.hasKey("Item", 8))
    {
        this.flowerPotItem = Item.getByNameOrId(compound.getString("Item"));
    }
    else
    {
        this.flowerPotItem = Item.getItemById(compound.getInteger("Item"));
    }

    this.flowerPotData = compound.getInteger("Data");
}
 
Example 7
Project: BaseClient   File: NetHandlerPlayClient.java   View Source Code Vote up 5 votes
/**
 * Handles the creation of a nearby player entity, sets the position and held item
 */
public void handleSpawnPlayer(S0CPacketSpawnPlayer packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    double d0 = (double)packetIn.getX() / 32.0D;
    double d1 = (double)packetIn.getY() / 32.0D;
    double d2 = (double)packetIn.getZ() / 32.0D;
    float f = (float)(packetIn.getYaw() * 360) / 256.0F;
    float f1 = (float)(packetIn.getPitch() * 360) / 256.0F;
    EntityOtherPlayerMP entityotherplayermp = new EntityOtherPlayerMP(this.gameController.theWorld, this.getPlayerInfo(packetIn.getPlayer()).getGameProfile());
    entityotherplayermp.prevPosX = entityotherplayermp.lastTickPosX = (double)(entityotherplayermp.serverPosX = packetIn.getX());
    entityotherplayermp.prevPosY = entityotherplayermp.lastTickPosY = (double)(entityotherplayermp.serverPosY = packetIn.getY());
    entityotherplayermp.prevPosZ = entityotherplayermp.lastTickPosZ = (double)(entityotherplayermp.serverPosZ = packetIn.getZ());
    int i = packetIn.getCurrentItemID();

    if (i == 0)
    {
        entityotherplayermp.inventory.mainInventory[entityotherplayermp.inventory.currentItem] = null;
    }
    else
    {
        entityotherplayermp.inventory.mainInventory[entityotherplayermp.inventory.currentItem] = new ItemStack(Item.getItemById(i), 1, 0);
    }

    entityotherplayermp.setPositionAndRotation(d0, d1, d2, f, f1);
    this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entityotherplayermp);
    List<DataWatcher.WatchableObject> list = packetIn.func_148944_c();

    if (list != null)
    {
        entityotherplayermp.getDataWatcher().updateWatchedObjectsFromList(list);
    }
}
 
Example 8
Project: BaseClient   File: TileEntityFlowerPot.java   View Source Code Vote up 5 votes
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);

    if (compound.hasKey("Item", 8))
    {
        this.flowerPotItem = Item.getByNameOrId(compound.getString("Item"));
    }
    else
    {
        this.flowerPotItem = Item.getItemById(compound.getInteger("Item"));
    }

    this.flowerPotData = compound.getInteger("Data");
}
 
Example 9
Project: DecompiledMinecraft   File: EntityWolf.java   View Source Code Vote up 4 votes
protected Item getDropItem()
{
    return Item.getItemById(-1);
}
 
Example 10
Project: DecompiledMinecraft   File: EntityWolf.java   View Source Code Vote up 4 votes
protected Item getDropItem()
{
    return Item.getItemById(-1);
}
 
Example 11
Project: Backmemed   File: SPacketCooldown.java   View Source Code Vote up 4 votes
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.item = Item.getItemById(buf.readVarIntFromBuffer());
    this.ticks = buf.readVarIntFromBuffer();
}
 
Example 12
Project: CustomWorldGen   File: SPacketCooldown.java   View Source Code Vote up 4 votes
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.item = Item.getItemById(buf.readVarIntFromBuffer());
    this.ticks = buf.readVarIntFromBuffer();
}
 
Example 13
Project: BaseClient   File: CustomItemProperties.java   View Source Code Vote up 4 votes
private String[] getModelTextures()
{
    if (this.type == 1 && this.items.length == 1)
    {
        Item item = Item.getItemById(this.items[0]);

        if (item == Items.potionitem && this.damage != null && this.damage.getCountRanges() > 0)
        {
            RangeInt rangeint = this.damage.getRange(0);
            int i = rangeint.getMin();
            boolean flag = (i & 16384) != 0;
            String s5 = this.getMapTexture(this.mapTextures, "texture.potion_overlay", "items/potion_overlay");
            String s6 = null;

            if (flag)
            {
                s6 = this.getMapTexture(this.mapTextures, "texture.potion_bottle_splash", "items/potion_bottle_splash");
            }
            else
            {
                s6 = this.getMapTexture(this.mapTextures, "texture.potion_bottle_drinkable", "items/potion_bottle_drinkable");
            }

            return new String[] {s5, s6};
        }

        if (item instanceof ItemArmor)
        {
            ItemArmor itemarmor = (ItemArmor)item;

            if (itemarmor.getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER)
            {
                String s = "leather";
                String s1 = "helmet";

                if (itemarmor.armorType == 0)
                {
                    s1 = "helmet";
                }

                if (itemarmor.armorType == 1)
                {
                    s1 = "chestplate";
                }

                if (itemarmor.armorType == 2)
                {
                    s1 = "leggings";
                }

                if (itemarmor.armorType == 3)
                {
                    s1 = "boots";
                }

                String s2 = s + "_" + s1;
                String s3 = this.getMapTexture(this.mapTextures, "texture." + s2, "items/" + s2);
                String s4 = this.getMapTexture(this.mapTextures, "texture." + s2 + "_overlay", "items/" + s2 + "_overlay");
                return new String[] {s3, s4};
            }
        }
    }

    return new String[] {this.texture};
}
 
Example 14
Project: BaseClient   File: EntityWolf.java   View Source Code Vote up 4 votes
protected Item getDropItem()
{
    return Item.getItemById(-1);
}
 
Example 15
Project: BaseClient   File: EntityWolf.java   View Source Code Vote up 4 votes
protected Item getDropItem()
{
    return Item.getItemById(-1);
}
 
Example 16
Project: BaseClient   File: EntityBreakingFX.java   View Source Code Vote up 4 votes
public EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_)
{
    int i = p_178902_15_.length > 1 ? p_178902_15_[1] : 0;
    return new EntityBreakingFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, Item.getItemById(p_178902_15_[0]), i);
}
 
Example 17
Project: Backmemed   File: CustomItemProperties.java   View Source Code Vote up 4 votes
private String[] getModelTextures()
{
    if (this.type == 1 && this.items.length == 1)
    {
        Item item = Item.getItemById(this.items[0]);
        boolean flag = item == Items.POTIONITEM || item == Items.SPLASH_POTION || item == Items.LINGERING_POTION;

        if (flag && this.damage != null && this.damage.getCountRanges() > 0)
        {
            RangeInt rangeint = this.damage.getRange(0);
            int i = rangeint.getMin();
            boolean flag1 = (i & 16384) != 0;
            String s5 = this.getMapTexture(this.mapTextures, "texture.potion_overlay", "items/potion_overlay");
            String s6 = null;

            if (flag1)
            {
                s6 = this.getMapTexture(this.mapTextures, "texture.potion_bottle_splash", "items/potion_bottle_splash");
            }
            else
            {
                s6 = this.getMapTexture(this.mapTextures, "texture.potion_bottle_drinkable", "items/potion_bottle_drinkable");
            }

            return new String[] {s5, s6};
        }

        if (item instanceof ItemArmor)
        {
            ItemArmor itemarmor = (ItemArmor)item;

            if (itemarmor.getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER)
            {
                String s = "leather";
                String s1 = "helmet";

                if (itemarmor.armorType == EntityEquipmentSlot.HEAD)
                {
                    s1 = "helmet";
                }

                if (itemarmor.armorType == EntityEquipmentSlot.CHEST)
                {
                    s1 = "chestplate";
                }

                if (itemarmor.armorType == EntityEquipmentSlot.LEGS)
                {
                    s1 = "leggings";
                }

                if (itemarmor.armorType == EntityEquipmentSlot.FEET)
                {
                    s1 = "boots";
                }

                String s2 = s + "_" + s1;
                String s3 = this.getMapTexture(this.mapTextures, "texture." + s2, "items/" + s2);
                String s4 = this.getMapTexture(this.mapTextures, "texture." + s2 + "_overlay", "items/" + s2 + "_overlay");
                return new String[] {s3, s4};
            }
        }
    }

    return new String[] {this.texture};
}
 
Example 18
Project: Backmemed   File: ParticleBreaking.java   View Source Code Vote up 4 votes
public Particle createParticle(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_)
{
    int i = p_178902_15_.length > 1 ? p_178902_15_[1] : 0;
    return new ParticleBreaking(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, Item.getItemById(p_178902_15_[0]), i);
}
 
Example 19
Project: Zombe-Modpack   File: ZWrapper.java   View Source Code Vote up 4 votes
public static Item getItem(int id) {
    //return Item.itemsList[id]; // < 1.8
    return Item.getItemById(id);
}
 
Example 20
Project: EMC   File: IItemStack.java   View Source Code Vote up 4 votes
public static IItemStack cloneWithoutEffects(IItemStack stack) {
	return new IItemStack(new ItemStack(Item.getItemById(Item.getIdFromItem(stack.getStack().getItem())),
			stack.getStack().stackSize));
}