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

I'm trying to make a grinder where you put a grinder and one ore and it returns 2 dust. It works to some extent but when i put a whole stack in, it takes the whole stack and only returns 2 dust. Here's my code:

 

Recipe: GameRegistry.addRecipe(new ItemStack (CopperDust, 2), new Object [] {

"GO ", "  ", "  ", 'G', (new ItemStack(AlchemyMain.Grinder, 1, Short.MAX_VALUE)), 'O', AlchemyMain.CopperOre

});

 

 

Crafting Handler: public class AlchemyCraftingHandler 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.getStackInSlotOnClosing(i);

 

if(j.getItem() != null && j.getItem() == AlchemyMain.Grinder)

{

ItemStack k = new ItemStack(AlchemyMain.Grinder, 2, (j.getItemDamage() + 1));

 

if(k.getItemDamage() >= k.getMaxDamage())

{

k.stackSize--;

}

craftMatrix.setInventorySlotContents(i, k);

}

}

}

}

 

@Override

public void onSmelting(EntityPlayer player, ItemStack item)

{

 

}

}

 

Grinder Class: public class ItemGrinder extends Item

{

private ItemStack emptyItem = null;

public ItemGrinder(int par1, EnumToolMaterial toolGrinder)

{

super(par1);

maxStackSize = 1;

this.setMaxDamage(1000);

this.setCreativeTab(AlchemyMain.TabAlchemy);

}

public void registerIcons(IconRegister iconRegister)

{

itemIcon = iconRegister.registerIcon("alchemy:Grinder");

}

}

 

 

If you need anything else ill post it. Thanks

Ah, pls use spoiler and code tags.

I will have a look at it as soon as I am back at my pc.

 

Ok:

 

You loop through the crafting matrix to find your grinder. Good

 

You get your grinder. Good

 

You set the damage and place it in the correct slot. Good

 

But you never check how many items are crafted. You have to check the output stack size and than add it to the damage from j.

Here could be your advertisement!

  • Author

Ok, that works alright now, but is there a way to leave the grinder in the crafting table and not having it go back to my inventory?

 

btw i used diesieben07's method so i got rid of my crafting handler

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.