Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello. I was just wondering how you would go about making a custom tool repairable.

 

Let's say I have an Obsidian Pickaxe (ModItems.obsidian_pickaxe) and I want to repair it with Obsidian (Blocks.obsidian) in an anvil. How might I do that?

 

Best regards,

Jarod Beau

[email protected]

 

 

Try overriding the getIsRepairable method, not sure if it still works :)

Don't blame me if i always ask for your help. I just want to learn to be better :)

To override the getRepairItemStack he need to create a custom Tool Material class, i guess

Don't blame me if i always ask for your help. I just want to learn to be better :)

I bunce into this discussion, so we can solve two problems at once ;)

I have my custom ItemArmor class, now to say at the game "if i have a ruby armor and i'm using a ruby in the anvil than repair my armor" how could i do? I think is the same question that the guy above is making

package mw.items;

import mw.core.MW;
import mw.core.MWItems;
import mw.core.utils.Utils;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;

public class ItemArmorMW extends ItemArmor {

private String material;
public ItemArmorMW(ArmorMaterial par1, int par2, int par3, String name) {
	super(par1, par2, par3);
	Utils.setCombatItemInfo(this, name);
	this.material = par1.name().toLowerCase();
}

public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
{
	if(slot == 2)
		return MW.MODID + ":" + "textures/models/armor/" + this.material + "_2.png";
	else
		return MW.MODID + ":" + "textures/models/armor/" + this.material + "_1.png";
}


@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
{
	if(repair.equals(MWItems.ruby) && toRepair.equals(this))
		return true;
	else
		return false;
}
}

I've tried overriding the getIsRepairable method but is not working

Don't blame me if i always ask for your help. I just want to learn to be better :)

Ok, so i found the solution. You need to add to override the function getIsRepairable in your ItemArmor class (wich of course it must extend the vanilla ItemArmor class) or in your custom Tool class. To do this you need to add this lines

@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
{

	if(repair.getItem().equals(-MY ARMOR ITEM (example: Obsidian)))
		return true;
	else
		return false;
}

 

Basically what you need to check is if the Item in the second andvil slot is equal to an item that you want (in this case you check if that item is an obsidian block, so you can repair an obsidian armor/tool). Hope this helped, at least for armor it works for me :)

Don't blame me if i always ask for your help. I just want to learn to be better :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.