Skip to content

Chisel Bug: Durability = Item Stack #64

@ghost

Description

If you make a pure obsidian chisel (obsidian tool rod and obsidian head), the tool has a total of 56 durability. I didn't pay any attention to that at first, since I intended to make it unbreakable anyway...

However, I noticed that if you put in a full-stack (say cobblestone) and chisel it, you'll only get 56 back, not the 64 you should be.

I put a diamond on the chisel to confirm, I now get the 64 back I should be.

The issue lies here: https://github.com/KnightMiner/TinkersComplement/blob/master/src/main/java/knightminer/tcomplement/plugin/chisel/items/ItemChisel.java

@Optional.Method(modid="chisel")
	@Override
	public ItemStack craftItem(ItemStack chisel, ItemStack source, ItemStack target, EntityPlayer player) {
		int toCraft = Math.min(source.getCount(), target.getMaxStackSize());
		int damageLeft = chisel.getMaxDamage() - chisel.getItemDamage();
		toCraft = Math.min(toCraft, damageLeft);
		ToolHelper.damageTool(chisel, toCraft, player);
		// add XP for chiseling, this will safely do nothing if tool leveling is not loaded
		ToolLevelingPlugin.xpAdder.addXp(chisel, toCraft, player);

		ItemStack res = target.copy();
		source.shrink(toCraft);
		res.setCount(toCraft);
		return res;
	}

Take the tool I made...

@Optional.Method(modid="chisel")
	@Override
	public ItemStack craftItem(ItemStack chisel, ItemStack source, ItemStack target, EntityPlayer player) {
		int toCraft = Math.min(64,64);
		int damageLeft = 54 - 0;
		toCraft = Math.min(64,54);
		ToolHelper.damageTool(chisel, 54, player);
		// add XP for chiseling, this will safely do nothing if tool leveling is not loaded
		ToolLevelingPlugin.xpAdder.addXp(chisel, toCraft, player);

		ItemStack res = target.copy();
		source.shrink(toCraft);
		res.setCount(toCraft);
		return res;
	}

The issue becomes obvious. This is obviously a check to make sure it only crafts the correct amount that the tool can handle... That's a good check... however, it should be ignored if the tool is unbreakable (having 5 reinforcement modifiers).

Fix? Check if the tool is unbreakable, if so don't bother with the damage check, since it isn't needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions