Java Code Examples for net.minecraft.init.Items#string()

The following examples show how to use net.minecraft.init.Items#string() . 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: archimedes-ships   File: RecipeBalloon.java    License: MIT License 6 votes vote down vote up
@Override
public boolean matches(InventoryCrafting inventorycrafting, World world)
{
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			ItemStack itemstack = inventorycrafting.getStackInRowAndColumn(i, j);
			if (itemstack == null) continue;
			if (itemstack.getItem() == Item.getItemFromBlock(Blocks.wool))
			{
				ItemStack itemstack1 = inventorycrafting.getStackInRowAndColumn(i, j + 1);
				if (itemstack1 != null && itemstack1.getItem() == Items.string)
				{
					return true;
				}
				return false;
			}
			return false;
		}
	}
	return false;
}
 
Example 2
Source Project: archimedes-ships   File: RecipeBalloon.java    License: MIT License 6 votes vote down vote up
@Override
public ItemStack getCraftingResult(InventoryCrafting inventorycrafting)
{
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			ItemStack itemstack = inventorycrafting.getStackInRowAndColumn(i, j);
			if (itemstack == null) continue;
			if (itemstack.getItem() == Item.getItemFromBlock(Blocks.wool))
			{
				ItemStack itemstack1 = inventorycrafting.getStackInRowAndColumn(i, j + 1);
				if (itemstack1 != null && itemstack1.getItem() == Items.string)
				{
					return new ItemStack(ArchimedesShipMod.blockBalloon, 1, itemstack.getItemDamage());
				}
				return null;
			}
			return null;
		}
	}
	return null;
}
 
Example 3
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.inventorySlots.get(slotIndex);

    if (slot != null && slot.getHasStack()) {
        ItemStack itemstack1 = slot.getStack();
        itemstack = itemstack1.copy();

        int size = packagerInv.getSizeInventory();
        if (slotIndex < size) {
            if (!this.mergeItemStack(itemstack1, size, this.inventorySlots.size(), true)) {
                return null;
            }
        } else {
            int specialSlot = itemstack1.getItem() == Items.leather ? 9 : itemstack1.getItem() == Items.string ? 10 : -1;
            if(specialSlot != -1 && (packagerInv.getStackInSlot(specialSlot) == null || packagerInv.getStackInSlot(specialSlot).stackSize < 64)) {
                this.mergeItemStack(itemstack1, specialSlot, specialSlot + 1, false);

                if(itemstack1.stackSize == 0) {
                    slot.putStack(null);
                }

                return null;
            } else if (!this.mergeItemStack(itemstack1, 0, size - 3, false)) {
                return null;
            }
        }

        if (itemstack1.stackSize == 0) {
            slot.putStack(null);
        } else {
            slot.onSlotChanged();
        }
    }

    return itemstack;
}
 
Example 4
private boolean canPack() {
    if (getStackInSlot(11) != null) {
        return false;
    }

    boolean check = false;
    for (int i = 0; i < 9; i++) {
        if (getStackInSlot(i) != null) {
            check = true;
            break;
        }
    }

    if (!check) {
        return false;
    }

    if (useEssentia) {
        if (amount < 4) {
            return false;
        }
    } else {
        ItemStack leather = getStackInSlot(9);
        if (leather == null || leather.stackSize < 1 || leather.getItem() != Items.leather) {
            return false;
        }

        ItemStack string = getStackInSlot(10);
        if (string == null || string.stackSize < 1 || string.getItem() != Items.string) {
            return false;
        }
    }

    return true;
}
 
Example 5
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
    if (slot == 9) {
        return stack.getItem() == Items.leather;
    } else if (slot == 10) {
        return stack.getItem() == Items.string;
    } else if (slot == 11) {
        return false;
    }
    return true;
}
 
Example 6
Source Project: GardenCollection   File: WoodFenceRecipe.java    License: MIT License 5 votes vote down vote up
@Override
public ItemStack getCraftingResult (InventoryCrafting inventory) {
    int size = getGridSize(inventory);
    for (int row = 0; row < size - 1; row++) {
        for (int col = 0; col < size - 2; col++) {
            ItemStack string1 = inventory.getStackInRowAndColumn(col, row);
            ItemStack string2 = inventory.getStackInRowAndColumn(col + 2, row);
            if (string1 == null || string2 == null || string1.getItem() != Items.string || !string1.isItemEqual(string2))
                continue;

            ItemStack wood1 = inventory.getStackInRowAndColumn(col + 1, row);
            ItemStack wood2 = inventory.getStackInRowAndColumn(col + 1, row + 1);
            if (wood1 == null || wood2 == null || !wood1.isItemEqual(wood2))
                continue;
            if (Block.getBlockFromItem(wood1.getItem()) != ModBlocks.thinLog)
                continue;

            Block woodBlock = TileEntityWoodProxy.getBlockFromComposedMetadata(wood1.getItemDamage());
            int woodMeta = TileEntityWoodProxy.getMetaFromComposedMetadata(wood1.getItemDamage());

            if (!WoodRegistry.instance().contains(woodBlock, woodMeta))
                continue;

            if (woodBlock == woodType.getBlock() && woodMeta == woodType.meta)
                return new ItemStack(ModBlocks.thinLogFence, 3, TileEntityWoodProxy.composeMetadata(woodBlock, woodMeta));
        }
    }

    return null;
}