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

Does anyone know where I can find a link or know how to make an item which, when crafted with, isn't destroyed but it uses durability. I've looked everywhere! Either they are out of date (older versions of mc) or they make no sense.

 

Thanks.

Edited by Blu_Nighttime

  • Author

package mstrTiggyI.MoreBlocks.items;

 

import mstrTiggyI.MoreBlocks.MoreBlocks;
import mstrTiggyI.MoreBlocks.Reference;
import mstrTiggyI.MoreBlocks.init.ModItems;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;

 

 

public class ItemPulverizerTool extends Item {
 
 private ItemStack emptyItem = null;
 private static int maxDamage = 2048;
 
 public ItemPulverizerTool(){
      setUnlocalizedName(Reference.MoreBlocksItems.PULVERIZERTOOL.getUnlocalizedName());
      setRegistryName(Reference.MoreBlocksItems.PULVERIZERTOOL.getRegistryName());
      setCreativeTab(MoreBlocks.CREATIVE_TAB);
      setMaxDamage(maxDamage);
      setMaxStackSize(1);
      setNoRepair();

 }
 @Override
 public boolean hasContainerItem() {
     return true;
 }


 public void setEmptyItem(ItemStack ei) {
     this.emptyItem = ei;
 }

 

 public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) {
     return false;
 }


 public ItemStack getContainerItemStack(ItemStack stack) {
     int dmg = stack.getItemDamage();
     if (dmg == maxDamage) {
     return new ItemStack(stack.getItem(), 0, maxDamage);
     }
     ItemStack tr = copyStack(stack, 1);
     tr.setItemDamage(dmg + 1);
     return tr;
 }


 public static ItemStack copyStack(ItemStack stack, int n) {
     return new ItemStack(stack.itemID, n, stack.getItemDamage());
     }
}

 

This is the code. The problem is that (where underlined) is saying that field cannot be Resolved. It recommends using .getItem() but that crashes the game. I'm not sure what to use nor do?!

  • Author

A pic of the class for the tool (no methods are deprecated).

 

A couple variables:

public static ToolMaterial MATERIAL = EnumHelper.addToolMaterial("MATERIAL", 0, 2048, 1.5F, 1.0F, 0);

private static final Set EFFECTIVE_ON = Sets.newHashSet(new Block[] {Blocks.AIR});

 

Calling and registering:

pulverizertool = new ItemPulverizerTool(0.5F,MATERIAL,EFFECTIVE_ON);

GameRegistry.register(pulverizertool);

 

Crafting:

GameRegistry.addShapedRecipe(new ItemStack(ModItems.stonedust,9), "PS ", " ", " ",'P', new ItemStack(ModItems.pulverizertool,1,OreDictionary.WILDCARD_VALUE),'S',Blocks.STONE);

 

 

When the tool is used in crafting and product is made, the tool has a red zero next to it and disappears on click. I'm struggling to solve this one issue.

modpic.png

You aren't using the methods without parameters so of course they're not deprecated.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Hey thanks! I've managed to copy the item, although it's now indestructible, I now have something to work with. Now...how do I change the title to solve?

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.