Jump to content

[Solved] Making a RP2 Handsaw type item help.


Rowsell99

Recommended Posts

I'm working on a mod at the moment and I'm trying to make a Red Power 2 handsaw or Equivalent Exchange 3 minium stone type item where you can use it in a crafting recipe and it will give it back but more damaged but I cant figure out how, if anybody knew I would be really thankful.

Link to comment
Share on other sites

Hey,

you need a crafting handler, create a new class an name it as you want.

Then define it in your mod_xxx.java in the "public void init..." method with

GameRegistry.registerCraftingHandler(new CraftingHandler());

In this example I called the CraftingHandler "CraftingHandler" :)

Now you have to make your Item and then add the following:

aloeVeraMilk = (new ItemXXX(975)).setIconIndex(75).setItemName("Test Item").setMaxDamage(10); // Add your Max. Damge here!!!

Now we want, that you won't loose your Item after crafting. Go the crafting handler and add:

public class CraftingHandler implements ICraftingHandler {

@Override
public void onCrafting(EntityPlayer player, ItemStack item,
		IInventory craftMatrix) {

	for(int i=0; i < craftMatrix.getSizeInventory(); i++)
    {
        if(craftMatrix.getStackInSlot(i) != null)
        {
            ItemStack j = craftMatrix.getStackInSlot(i);
            if(j.getItem() != null && j.getItem() == mod_eltrixscience.vaporizerItem)
            {
                ItemStack k = new ItemStack(mod_xxx.xxxItem, 2, (j.getItemDamage() - 1)); // <-- Set the Damage after crafting...
                craftMatrix.setInventorySlotContents(i, k); //<-- Put the item back into the crafting gui!
            }
            
        }
    }

}

}

 

Hope I helped you!

Greetings from germany!

Link to comment
Share on other sites

Oh by the way this line of code:

ItemStack k = new ItemStack(mod_xxx.xxxItem, 2, (j.getItemDamage() - 1));

 

Should be changed to:

ItemStack k = new ItemStack(mod_xxx.xxxItem, 2, (j.getItemDamage() + 1));

 

Because otherwise you are taking away from the damage value which adds to the durability so it will go from 123 to 124 instead of 123 to 122.

Link to comment
Share on other sites

Also you will want to remove this piece of code at the bottom of the code:

craftMatrix.setInventorySlotContents(i, k);

 

And put in this if else statement so if the item has no durability left it gets destroyed:

if(k.getItemDamage() < k.getMaxDamage()){
	craftMatrix.setInventorySlotContents(i, k);
  }else{
	ItemStack l = new ItemStack(Block.blockClay, 0);
	craftMatrix.setInventorySlotContents(i, j);
   }

 

The Block.blockClay can be replaced with anything because the 0 after it means that 0 of whatever item is stated will be put in your inventory.

 

So the final code should look like this:

@Override
public void onCrafting(EntityPlayer player, ItemStack item,
		IInventory craftMatrix) {
	for(int i = 0; i < craftMatrix.getSizeInventory(); i++ ){
		if(craftMatrix.getStackInSlot(i) != null){
			ItemStack j = craftMatrix.getStackInSlot(i);
			if(j.getItem() != null && j.getItem() == YourMod.yourItem){
				ItemStack k = new ItemStack(YourMod.yourItem, 2, (j.getItemDamage() + 1));
				if(k.getItemDamage() < k.getMaxDamage()){
					craftMatrix.setInventorySlotContents(i, k);
				}else{
					ItemStack l = new ItemStack(Block.blockClay, 0);
					craftMatrix.setInventorySlotContents(i, j);
				}	
			}
		}
	}

}

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Situs Slot Bonus New Member 100 di Awal To Kecil 3x 7x Terbaru 2024 Daftar Disini >>> https://d6wx.short.gy/Link-Bonus-Bebas-IP Link Alternatif >>> https://c4b8.short.gy/hanyakamu Masih mencari Slot Bonus New Member 100 di awal to 7x terbaru tahun 2024 yang selalu memberikan update bonus new member 100 di depan di indonesia? idnslot menghadirkan situs dengan promo depo 25 bonus 25, bonus cashback, dan slot bonus 100 di depan to kecil untuk deposit pertamamu. Kami memberikan promo paling besar untuk kesejahteraan member dalam melakukan betting dari game gacor terlengkap yang di sediakan. Dengan adanya promosi slot bonus new member 100 to 3x 5x 7x 10x tentunya sangat menguntungkan kamu tahun 2024 ini. Sekian banyak situs dengan mengempurkan diri untuk memberikan kenyamanan kepada member tetapi idnslot login adalah situs satu-satunya yang langsung memberikan to rendah dari bonus new member 100 (slot game). Khusus pecinta slot bonus kamu hanya dengan minimal deposit 10rb saja bisa dapat jackpot terbesar. Berikut adalah game slot bonus new member 100 game paling gacor hari ini: Slot Bonus Mahjong Ways Slot Bonus Gates Of Olympus Slot Bonus Lucky Neko Slot Bonus Starlight Princess Slot Bonus PG Soft Slot Bonus Pragmatic Play
    • Situs Slot Bonus New Member 100 di Awal To Kecil 3x 7x Terbaru 2024 Daftar Disini >>> https://d6wx.short.gy/Link-Bonus-Bebas-IP Link Alternatif >>> https://c4b8.short.gy/hanyakamu Masih mencari Slot Bonus New Member 100 di awal to 7x terbaru tahun 2024 yang selalu memberikan update bonus new member 100 di depan di indonesia? pay4d menghadirkan situs dengan promo depo 25 bonus 25, bonus cashback, dan slot bonus 100 di depan to kecil untuk deposit pertamamu. Kami memberikan promo paling besar untuk kesejahteraan member dalam melakukan betting dari game gacor terlengkap yang di sediakan. Dengan adanya promosi slot bonus new member 100 to 3x 5x 7x 10x tentunya sangat menguntungkan kamu tahun 2024 ini. Sekian banyak situs dengan mengempurkan diri untuk memberikan kenyamanan kepada member tetapi pay4d login adalah situs satu-satunya yang langsung memberikan to rendah dari bonus new member 100 (slot game). Khusus pecinta slot bonus kamu hanya dengan minimal deposit 10rb saja bisa dapat jackpot terbesar. Berikut adalah game slot bonus new member 100 game paling gacor hari ini: Slot Bonus Mahjong Ways Slot Bonus Gates Of Olympus Slot Bonus Lucky Neko Slot Bonus Starlight Princess Slot Bonus PG Soft Slot Bonus Pragmatic Play
    • Situs Slot Bonus New Member 100 di Awal To Kecil 3x 7x Terbaru 2024 Daftar Disini >>> https://d6wx.short.gy/Link-Bonus-Bebas-IP Link Alternatif >>> https://c4b8.short.gy/hanyakamu Masih mencari Slot Bonus New Member 100 di awal to 7x terbaru tahun 2024 yang selalu memberikan update bonus new member 100 di depan di indonesia? Huat138 menghadirkan situs dengan promo depo 25 bonus 25, bonus cashback, dan slot bonus 100 di depan to kecil untuk deposit pertamamu. Kami memberikan promo paling besar untuk kesejahteraan member dalam melakukan betting dari game gacor terlengkap yang di sediakan. Dengan adanya promosi slot bonus new member 100 to 3x 5x 7x 10x tentunya sangat menguntungkan kamu tahun 2024 ini. Sekian banyak situs dengan mengempurkan diri untuk memberikan kenyamanan kepada member tetapi Naga Hoki88 login adalah situs satu-satunya yang langsung memberikan to rendah dari bonus new member 100 (slot game). Khusus pecinta slot bonus kamu hanya dengan minimal deposit 10rb saja bisa dapat jackpot terbesar. Berikut adalah game slot bonus new member 100 game paling gacor hari ini: Slot Bonus Mahjong Ways Slot Bonus Gates Of Olympus Slot Bonus Lucky Neko Slot Bonus Starlight Princess Slot Bonus PG Soft Slot Bonus Pragmatic Play
    • Did it crash before you added mods to the pack? If not, try readding the mods 1-2 at a time testing in between to find the broken/incompatible mod
  • Topics

×
×
  • Create New...

Important Information

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