net.minecraft.item.ItemTool Java Examples

The following examples show how to use net.minecraft.item.ItemTool. 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: EventTooltip.java    From Levels with GNU General Public License v2.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onTooltip(ItemTooltipEvent event)
{
	ArrayList<String> tooltip = (ArrayList<String>) event.getToolTip();
	ItemStack stack = event.getItemStack();
	NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
	
	if (stack != null && nbt != null)
	{
		if (stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemBow || stack.getItem() instanceof ItemShield || stack.getItem() instanceof ItemTool)
		{
			Rarity rarity = Rarity.getRarity(nbt);
			
			if (rarity != Rarity.DEFAULT)
			{
				addTooltips(tooltip, stack, nbt);
			}
		}
	}
}
 
Example #2
Source File: MetaTileEntityWorkbench.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
    if (!(stack.getItem() instanceof ToolMetaItem) &&
        !(stack.getItem() instanceof ItemTool) &&
        !(stack.isItemStackDamageable())) {
        return stack;
    }
    return super.insertItem(slot, stack, simulate);
}
 
Example #3
Source File: QuestMine.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<ItemStack> complete(QuestData data, List<ItemStack> in) {
	if (in == null) {
		return null;
	}

	List<ItemStack> givenItems = copyItems(in);

	int requiredLeft = getTargetAmount(data);
	boolean toolIncluded = false;

	for (ItemStack item : givenItems) {
		if (isForThisQuest(data, item)) {
			if (item.getItem() instanceof ItemTool) {
				toolIncluded = true;
				item.setCount(0);
			} else {
				requiredLeft -= item.getCount();
				item.setCount(0);
			}
		} else {
		}
	}

	if (requiredLeft > 0) {
		data.getPlayer().sendMessage(new TextComponentString("You are " + requiredLeft + " short"));
		return null;
	}

	if (!toolIncluded) {
		data.getPlayer().sendMessage(new TextComponentString("You must turn in the tool that you were given"));
		return null;
	}

	givenItems = removeEmptyItemStacks(givenItems);
	addRewardItems(data, givenItems);
	return givenItems;
}
 
Example #4
Source File: GuiItemInformation.java    From Levels with GNU General Public License v2.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
protected void actionPerformed(GuiButton button) throws IOException 
{
	EntityPlayerSP player = mc.player;
	
	if (player != null)
	{
		ItemStack stack = player.inventory.getCurrentItem();
		
		if (stack != null)
		{
			if (button == selection)
			{
				if (stack.getItem() instanceof ItemSword)
				{
					player.openGui(Levels.instance, GuiHandler.WEAPON_ATTRIBUTES, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ);
				}
				else if (stack.getItem() instanceof ItemArmor)
				{
					player.openGui(Levels.instance, GuiHandler.ARMOR_ATTRIBUTES, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ);
				}
				else if (stack.getItem() instanceof ItemBow)
				{
					player.openGui(Levels.instance, GuiHandler.BOW_ATTRIBUTES, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ);
				}
				else if (stack.getItem() instanceof ItemShield)
				{
					player.openGui(Levels.instance, GuiHandler.SHIELD_ATTRIBUTES, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ);
				}
				else if (stack.getItem() instanceof ItemTool)
				{
					//player.openGui(Levels.instance, GuiHandler., player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ);
				}
			}
		}
	}
}
 
Example #5
Source File: EventInput.java    From Levels with GNU General Public License v2.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onKeyPress(InputEvent.KeyInputEvent event)
{
	KeyBinding l = ClientProxy.keyBindingL;
	Minecraft mc = Minecraft.getMinecraft();
	EntityPlayer player = mc.player;
	
	if (player != null)
	{
		ItemStack stack = player.inventory.getCurrentItem();
		
		if (stack != null)
		{
			Item current = stack.getItem();
			
			if (current != null)
			{
				if (current instanceof ItemSword || current instanceof ItemTool || current instanceof ItemArmor || current instanceof ItemBow || current instanceof ItemShield)
				{
					if (l.isPressed())
					{
						player.openGui(Levels.instance, GuiHandler.ITEM_INFORMATION, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ);
					}
				}
			}
		}
	}
}
 
Example #6
Source File: InventoryChiselSelection.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isItemValidForSlot(int i, ItemStack stack) {
	//Really didn't think people would chisel a shovel
	if (stack.getItem() instanceof ItemTool) {
		return false;
	}

	return !(stack != null && (stack.getItem() instanceof ItemChisel)) && i == normalSlots;
}
 
Example #7
Source File: DiamondTofuToolHandler.java    From TofuCraftReload with MIT License 4 votes vote down vote up
public DiamondTofuToolHandler(ItemTool tool) {
    this.tool = tool;
}
 
Example #8
Source File: GuiItemInformation.java    From Levels with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the strings for the ability selection screen.
 * @param stack
 * @param abilities
 * @param nbt
 */
private void drawStrings(ItemStack stack, NBTTagCompound nbt)
{
	Rarity rarity = Rarity.getRarity(nbt);
	
	drawCenteredString(fontRendererObj, stack.getDisplayName(), width / 2, 20, rarity.getHex());
	drawString(fontRendererObj, I18n.format("levels.misc.rarity") + ": " + rarity.getName(), width / 2 - 50, 40, rarity.getHex());
	drawCenteredString(fontRendererObj, I18n.format("levels.misc.attributes"), width / 2, 80, 0xFFFFFF);
	drawCenteredString(fontRendererObj, I18n.format("levels.misc.attributes.tokens") + ": " + Experience.getAttributeTokens(nbt), width / 2 - 112, 100, 0xFFFFFF);
	drawCenteredString(fontRendererObj, I18n.format("levels.misc.attributes.current"), width / 2 + 112, 100, 0xFFFFFF);
	
	if (Experience.getLevel(nbt) == Config.maxLevel)
	{
		drawString(fontRendererObj, I18n.format("levels.misc.level") + ": " + I18n.format("levels.misc.max"), width / 2 - 50, 50, 0xFFFFFF);
		drawString(fontRendererObj, I18n.format("levels.misc.experience") + ": " + I18n.format("levels.misc.max"), width / 2 - 50, 60, 0xFFFFFF);
	}
	else
	{
		drawString(fontRendererObj, I18n.format("levels.misc.level") + ": " + Experience.getLevel(nbt), width / 2 - 50, 50, 0xFFFFFF);
		drawString(fontRendererObj, I18n.format("levels.misc.experience") + ": " + Experience.getExperience(nbt) + " / " + Experience.getNextLevelExperience(Experience.getLevel(nbt)), width / 2 - 50, 60, 0xFFFFFF);
	}
	
	int k = -1;
	
	if (stack.getItem() instanceof ItemSword)
	{	
		for (int i = 0; i < WeaponAttribute.WEAPON_ATTRIBUTES.size(); i++)
		{
			if (WeaponAttribute.WEAPON_ATTRIBUTES.get(i).hasAttribute(nbt))
			{
				k++;
				drawCenteredString(fontRendererObj, WeaponAttribute.WEAPON_ATTRIBUTES.get(i).getName(nbt), width / 2 + 112, 115 + (10 * k), WeaponAttribute.WEAPON_ATTRIBUTES.get(i).getHex());
			}
		}
	}
	else if (stack.getItem() instanceof ItemTool)
	{
		
	}
	else if (stack.getItem() instanceof ItemBow)
	{
		for (int i = 0; i < BowAttribute.BOW_ATTRIBUTES.size(); i++)
		{
			if (BowAttribute.BOW_ATTRIBUTES.get(i).hasAttribute(nbt))
			{
				k++;
				drawCenteredString(fontRendererObj, BowAttribute.BOW_ATTRIBUTES.get(i).getName(nbt), width / 2 + 112, 115 + (10 * k), BowAttribute.BOW_ATTRIBUTES.get(i).getHex());
			}
		}
	}
	else if (stack.getItem() instanceof ItemArmor)
	{
		for (int i = 0; i < ArmorAttribute.ARMOR_ATTRIBUTES.size(); i++)
		{
			if (ArmorAttribute.ARMOR_ATTRIBUTES.get(i).hasAttribute(nbt))
			{
				k++;
				drawCenteredString(fontRendererObj, ArmorAttribute.ARMOR_ATTRIBUTES.get(i).getName(nbt), width / 2 + 112, 115 + (10 * k), ArmorAttribute.ARMOR_ATTRIBUTES.get(i).getHex());
			}
		}
	}
	else if (stack.getItem() instanceof ItemShield)
	{
		for (int i = 0; i < ShieldAttribute.SHIELD_ATTRIBUTES.size(); i++)
		{
			if (ShieldAttribute.SHIELD_ATTRIBUTES.get(i).hasAttribute(nbt))
			{
				k++;
				drawCenteredString(fontRendererObj, ShieldAttribute.SHIELD_ATTRIBUTES.get(i).getName(nbt), width / 2 + 112, 115 + (10 * k), ShieldAttribute.SHIELD_ATTRIBUTES.get(i).getHex());
			}
		}
	}
}
 
Example #9
Source File: ItemToolMetaProvider.java    From OpenPeripheral-Integration with MIT License 4 votes vote down vote up
@Override
public Object getMeta(ItemTool target, ItemStack stack) {
	Map<String, Object> result = Maps.newHashMap();
	result.put("material", target.getToolMaterialName());
	return result;
}
 
Example #10
Source File: TileEntityEnderFurnace.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't fuel
 * @param stack
 * @return
 */
private static int getItemBurnTime(ItemStack stack)
{
    if (stack.isEmpty())
    {
        return 0;
    }

    int burnTime = ForgeEventFactory.getItemBurnTime(stack) * COOKTIME_DEFAULT * 3 / 400;

    if (burnTime >= 0)
    {
        return burnTime;
    }

    Item item = stack.getItem();

    if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR)
    {
        Block block = Block.getBlockFromItem(item);
        if (block.getDefaultState().getMaterial() == Material.WOOD) { return COOKTIME_DEFAULT * 225 / 100; }
        if (block == Blocks.COAL_BLOCK) { return COOKTIME_DEFAULT * 120; }
        if (block == Blocks.WOODEN_SLAB) { return COOKTIME_DEFAULT * 45 / 40; }
        if (block == Blocks.SAPLING) return COOKTIME_DEFAULT * 3 / 4;
    }
    else
    {
        if (item == Items.COAL) return COOKTIME_DEFAULT * 12;
        if (item == Items.BLAZE_ROD) return COOKTIME_DEFAULT * 18;

        if (item == Items.LAVA_BUCKET) return COOKTIME_DEFAULT * 150;
        if (item == Items.STICK) return COOKTIME_DEFAULT * 3 / 4;
        if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10;
        if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10;
        if (item instanceof ItemHoe && ((ItemHoe)item).getMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10;

        // Ender Furnace custom fuels
        if (item == Items.BLAZE_POWDER) return COOKTIME_DEFAULT * 9;
        if (item == Items.ENDER_PEARL) { return COOKTIME_DEFAULT * 8; }
        if (item == Items.ENDER_EYE) { return COOKTIME_DEFAULT * 17; }
    }

    return 0;
}