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

Hey guys,

 

I am wondering how would I go about making a item not get destroyed or infused with a crafting recipe?

 

For example

 

When making a diamond pickaxe, the diamonds and the sticks are destroyed or 'infused' with each other to make the pickaxe.

 

I want to use hell souls and a purity gem to make a pure soul but I dont want the purity gem destroyed when crafted.

 

This is used in DivineRPG with the dream powder.

 

Thanks :)

STOP CRUCIFYING NEW MODDERS!!!!

in Item.class there is something like

public ItemStack getContainerItemForItemStack(ItemStack i)

use this to return what you want

I think its my java of the variables.

  • Author

in Item.class there is something like

public ItemStack getContainerItemForItemStack(ItemStack i)

use this to return what you want

 

Thanks, I will try it :)

STOP CRUCIFYING NEW MODDERS!!!!

  • Author

in Item.class there is something like

public ItemStack getContainerItemForItemStack(ItemStack i)

use this to return what you want

 

what would i return?

STOP CRUCIFYING NEW MODDERS!!!!

lets say you want to return a glass bottle:

@Override
public ItemStack getContainerItemStack(ItemStack i){
return new ItemStack(Item.glassBottle);
}

I think its my java of the variables.

  • Author

I forgot to return new Itemstack.

 

I tried to return the item straight away xD

STOP CRUCIFYING NEW MODDERS!!!!

  • Author

lets say you want to return a glass bottle:

@Override
public ItemStack getContainerItemStack(ItemStack i){
return new ItemStack(Item.glassBottle);
}

 

It didnt work :(

package assassinhero.parallelworlds.common.items;

import assassinhero.parallelworlds.ParallelWorldsMain;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

public class ItemPurityGemItem extends Item{

public ItemPurityGemItem(int par1) {
	super(par1);
	setCreativeTab(CreativeTabs.tabMaterials);

}

public ItemStack getContainerItemForItemStack(ItemStack i){
	return new ItemStack(ParallelWorldsMain.PurityGem);
}

public void updateIcons(IconRegister par1iconregister){
	this.iconIndex = par1iconregister.registerIcon("ParallelWorlds:PurityGem");

}


}

 

Thats my code

 

When i use @Override I get an error

STOP CRUCIFYING NEW MODDERS!!!!

You could use a crafthandler for it.

 

here is an example:

 

https://github.com/Rikmuld/Camping-Mod/blob/master/common/rikmuld/core/handlers/CraftHandler.java

 

and this would make an item never get destroyed when used in a crafting recipie:

 


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

         for(int i=0; i < inv.getSizeInventory(); i++)
        {  		
            if(inv.getStackInSlot(i) != null)
            {
                ItemStack j = inv.getStackInSlot(i);
                if(j.getItem() != null&&j.getItem()==The Item That Shouldn't get destroyed)
                {
                     inv.setInventorySlotContents(i, j);
                }
             }      
        }

 

the itemstack in the method is the item you are crafting, so you also could specify the recipe for when it should not get destroyed.

 

Ps. don't forget to register the crafting handler in you init for if you don't already have an craftHandler.

GameRegistry.registerCraftingHandler(new CraftHandler());

If all you want to do is return the item without making it take damage add this to the super constructor

 

this.maxStackSize = 1;
this.setContainerItem(this);

 

otherwise if you seek to make it take damage, you will need a crafting handler

If all you want to do is return the item without making it take damage add this to the super constructor

 

this.maxStackSize = 1;
this.setContainerItem(this);

 

otherwise if you seek to make it take damage, you will need a crafting handler

Works if you don't have subtypes.... which I should have asked if you do in the first place,

If it's your own Item you can do that without having a crafting listener being passed data constantly:

public ItemStack getContainerItemStack(ItemStack i){
	i.setItemDamage(i.getItemDamage()--);
return i;
}

I also forgot to mention that you need to return true in

public boolean hasContainerItem(){}

I think its my java of the variables.

Guest
This topic is now closed to further replies.

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.