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

The following examples show how to use net.minecraft.item.Item#getItemById() . 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 check out the related API usage on the sidebar.
Example 1
Source File: EntityBison.java    From TFC2 with 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
Source File: EntityElk.java    From TFC2 with 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 3
Source File: EntityBear.java    From TFC2 with 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 4
Source File: EntityHippo.java    From TFC2 with 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 5
Source File: EntityRhino.java    From TFC2 with 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
Source File: MappingRegistry.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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 7
Source File: MappingRegistry.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
public int itemIdToRegistry(int id) {
	Item item = Item.getItemById(id);

	return getIdForItem(item);
}
 
Example 8
Source File: ForgePlayerBlockBag.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@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 9
Source File: ForgePlayerBlockBag.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@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 File: EntityDireWolf.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
@Override
protected Item getDropItem() {
  return Item.getItemById(-1);
}
 
Example 11
Source File: EntityBigCat.java    From TFC2 with 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
Source File: EntityBoar.java    From TFC2 with 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 13
Source File: ForgePlayerBlockBag.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@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
Source File: CraftMagicNumbers.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Deprecated
// A bad method for bad magic.
public static Item getItem(int id) {
    return Item.getItemById(id);
}
 
Example 15
Source File: CraftMagicNumbers.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static Item getItem(Material material) {
    // TODO: Don't use ID
    Item item = Item.getItemById(material.getId());
    return item;
}
 
Example 16
Source File: WeightedRandomLoot.java    From minecraft-roguelike with GNU General Public License v3.0 4 votes vote down vote up
public WeightedRandomLoot(Block block, int i) {
	this(Item.getItemById(Block.getIdFromBlock(block)), i);
}
 
Example 17
Source File: EntityFoxRed.java    From TFC2 with 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 File: WrapperItem.java    From ClientBase with MIT License 4 votes vote down vote up
public static WrapperItem getItemById(int var0) {
    return new WrapperItem(Item.getItemById(var0));
}
 
Example 19
Source File: EntityElephant.java    From TFC2 with 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 File: ItemPneumaticArmor.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
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"));
}