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

The following examples show how to use net.minecraft.item.Item#getItemById() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: TFC2   File: EntityBigCat.java    License: GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the item ID for the item the mob drops on death.
 */
@Override
protected Item getDropItem()
{
	return Item.getItemById(0);
}
 
Example 2
public static ItemStack getSearchedStack(ItemStack helmetStack){
    if(helmetStack == null || !NBTUtil.hasTag(helmetStack, "SearchStack")) return null;
    NBTTagCompound tag = NBTUtil.getCompoundTag(helmetStack, "SearchStack");
    if(tag.getInteger("itemID") == -1) return null;
    return new ItemStack(Item.getItemById(tag.getInteger("itemID")), 1, tag.getInteger("itemDamage"));
}
 
Example 3
/**
 * Returns the item ID for the item the mob drops on death.
 */
@Override
protected Item getDropItem()
{
	return Item.getItemById(0);
}
 
Example 4
Source Project: ClientBase   File: WrapperItem.java    License: MIT License 4 votes vote down vote up
public static WrapperItem getItemById(int var0) {
    return new WrapperItem(Item.getItemById(var0));
}
 
Example 5
Source Project: TFC2   File: EntityFoxRed.java    License: GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the item ID for the item the mob drops on death.
 */
@Override
protected Item getDropItem()
{
	return Item.getItemById(0);
}
 
Example 6
public WeightedRandomLoot(Block block, int i) {
	this(Item.getItemById(Block.getIdFromBlock(block)), i);
}
 
Example 7
public static Item getItem(Material material) {
    // TODO: Don't use ID
    Item item = Item.getItemById(material.getId());
    return item;
}
 
Example 8
@Deprecated
// A bad method for bad magic.
public static Item getItem(int id) {
    return Item.getItemById(id);
}
 
Example 9
@Override
public void storeItem(BaseItem item) throws BlockBagException {
    final int id = item.getType();
    final int damage = item.getData();
    int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
    assert(amount <= 64);
    boolean usesDamageValue = ItemType.usesDamageValue(id);

    if (id == BlockID.AIR) {
        throw new IllegalArgumentException("Can't store air block");
    }

    loadInventory();

    int freeSlot = -1;

    for (int slot = 0; slot < items.length; ++slot) {
        ItemStack forgeItem = items[slot];

        if (forgeItem == null) {
            // Delay using up a free slot until we know there are no stacks
            // of this item to merge into

            if (freeSlot == -1) {
                freeSlot = slot;
            }
            continue;
        }

        int itemId = Item.getIdFromItem(forgeItem.getItem());
        if (itemId != id) {
            // Type id doesn't fit
            continue;
        }

        if (usesDamageValue && forgeItem.getItemDamage() != damage) {
            // Damage value doesn't fit.
            continue;
        }

        int currentAmount = forgeItem.stackSize;
        if (currentAmount < 0) {
            // Unlimited
            return;
        }
        if (currentAmount >= 64) {
            // Full stack
            continue;
        }

        changed = true;

        int spaceLeft = 64 - currentAmount;
        if (spaceLeft >= amount) {
            forgeItem.stackSize += amount;
            return;
        }

        forgeItem.stackSize = (64);
        amount -= spaceLeft;
    }

    if (freeSlot > -1) {
        changed = true;
        items[freeSlot] = new ItemStack(Item.getItemById(id), amount);
        return;
    }

    throw new OutOfSpaceException(id);
}
 
Example 10
Source Project: TFC2   File: EntityBoar.java    License: GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the item ID for the item the mob drops on death.
 */
@Override
protected Item getDropItem()
{
	return Item.getItemById(0);
}
 
Example 11
Source Project: TFC2   File: EntityBison.java    License: GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the item ID for the item the mob drops on death.
 */
@Override
protected Item getDropItem()
{
	return Item.getItemById(0);
}
 
Example 12
@Override
protected Item getDropItem() {
  return Item.getItemById(-1);
}
 
Example 13
@Override
public void storeItem(BaseItem item) throws BlockBagException {
    final int id = item.getType();
    final int damage = item.getData();
    int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
    assert(amount <= 64);
    boolean usesDamageValue = ItemType.usesDamageValue(id);

    if (id == BlockID.AIR) {
        throw new IllegalArgumentException("Can't store air block");
    }

    loadInventory();

    int freeSlot = -1;

    for (int slot = 0; slot < items.length; ++slot) {
        ItemStack forgeItem = items[slot];

        if (forgeItem == null) {
            // Delay using up a free slot until we know there are no stacks
            // of this item to merge into

            if (freeSlot == -1) {
                freeSlot = slot;
            }
            continue;
        }

        int itemId = Item.getIdFromItem(forgeItem.getItem());
        if (itemId != id) {
            // Type id doesn't fit
            continue;
        }

        if (usesDamageValue && forgeItem.getItemDamage() != damage) {
            // Damage value doesn't fit.
            continue;
        }

        int currentAmount = forgeItem.stackSize;
        if (currentAmount < 0) {
            // Unlimited
            return;
        }
        if (currentAmount >= 64) {
            // Full stack
            continue;
        }

        changed = true;

        int spaceLeft = 64 - currentAmount;
        if (spaceLeft >= amount) {
            forgeItem.stackSize += amount;
            return;
        }

        forgeItem.stackSize = (64);
        amount -= spaceLeft;
    }

    if (freeSlot > -1) {
        changed = true;
        items[freeSlot] = new ItemStack(Item.getItemById(id), amount);
        return;
    }

    throw new OutOfSpaceException(id);
}
 
Example 14
@Override
public void storeItem(BaseItem item) throws BlockBagException {
    final int id = item.getType();
    final int damage = item.getData();
    int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
    assert(amount <= 64);
    boolean usesDamageValue = ItemType.usesDamageValue(id);

    if (id == BlockID.AIR) {
        throw new IllegalArgumentException("Can't store air block");
    }

    loadInventory();

    int freeSlot = -1;

    for (int slot = 0; slot < items.length; ++slot) {
        ItemStack forgeItem = items[slot];

        if (forgeItem == null) {
            // Delay using up a free slot until we know there are no stacks
            // of this item to merge into

            if (freeSlot == -1) {
                freeSlot = slot;
            }
            continue;
        }

        int itemId = Item.getIdFromItem(forgeItem.getItem());
        if (itemId != id) {
            // Type id doesn't fit
            continue;
        }

        if (usesDamageValue && forgeItem.getItemDamage() != damage) {
            // Damage value doesn't fit.
            continue;
        }

        int currentAmount = forgeItem.getCount();
        if (currentAmount < 0) {
            // Unlimited
            return;
        }
        if (currentAmount >= 64) {
            // Full stack
            continue;
        }

        changed = true;

        int spaceLeft = 64 - currentAmount;
        if (spaceLeft >= amount) {
            forgeItem.setCount(forgeItem.getCount() + amount);
            return;
        }

        forgeItem.setCount(64);
        amount -= spaceLeft;
    }

    if (freeSlot > -1) {
        changed = true;
        items[freeSlot] = new ItemStack(Item.getItemById(id), amount);
        return;
    }

    throw new OutOfSpaceException(id);
}
 
Example 15
public int itemIdToRegistry(int id) {
	Item item = Item.getItemById(id);

	return getIdForItem(item);
}
 
Example 16
/**
 * Relocates a stack nbt from the world referential to the registry
 * referential.
 */
public void stackToRegistry(NBTTagCompound nbt) {
	Item item = Item.getItemById(nbt.getShort("id"));
	nbt.setShort("id", (short) getIdForItem(item));
}
 
Example 17
Source Project: TFC2   File: EntityRhino.java    License: GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the item ID for the item the mob drops on death.
 */
@Override
protected Item getDropItem()
{
	return Item.getItemById(0);
}
 
Example 18
Source Project: TFC2   File: EntityHippo.java    License: GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the item ID for the item the mob drops on death.
 */
@Override
protected Item getDropItem()
{
	return Item.getItemById(0);
}
 
Example 19
Source Project: TFC2   File: EntityBear.java    License: GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the item ID for the item the mob drops on death.
 */
@Override
protected Item getDropItem()
{
	return Item.getItemById(0);
}
 
Example 20
Source Project: TFC2   File: EntityElk.java    License: GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the item ID for the item the mob drops on death.
 */
@Override
protected Item getDropItem()
{
	return Item.getItemById(0);
}