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.

thewaterwell

Forge Modder
  • Joined

  • Last visited

  1. I used the onItemRightClick and it worked! thank you for helping eveyone!
  2. ok, am trying to find a place where it runs and does not just sit there EDIT: found it, now to get the if working...
  3. what I am aiming for is for the item ItemExpCatalyst to serve as an exp "battery". sneak right click to charge and right click to absorb. p.s. I am going to try using onItemRightClick, to check.
  4. I did not really understand how to. I would be greatful if you would show me how here is the code for ItemMyMod public class ItemMyMod extends Item { public ItemMyMod() { super(); this.setCreativeTab(CreativeTabLMRB.LMRB_TAB); } @Override public String getUnlocalizedName() { return String.format("item.%s%s", Reference.MOD_ID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } @Override public String getUnlocalizedName(ItemStack itemStack) { return String.format("item.%s%s", Reference.MOD_ID.toLowerCase() + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1)); } protected String getUnwrappedUnlocalizedName(String unlocalizedName) { return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); } } this is from pahimar's tutorial.
  5. I removed it from the event handler and yes, I have a NBTHelper class in the utility package. since then, it stopped crashing but it does not print the "ON USE ITEM". I think it is because I am regisrting the Item as the top function only but I am uncertain.
  6. ok here it is... this is what is in the item's code regarding this not working. I registered it and maybe added a crafting recipe, that is all. public class ItemExpCatalyst extends ItemMyMod { public ItemExpCatalyst() { super(); this.setUnlocalizedName("expCatalyst"); this.setMaxStackSize(1); } @Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float px, float py, float pz) { System.out.println("ON ITEM USE"); if (player.experienceLevel>0 && player.isSneaking()) { NBTHelper.setInteger(itemstack,"exp stored", (NBTHelper.getInt(itemstack,"exp stored")+1)); System.out.println("EXP Stored: "+NBTHelper.getInt(itemstack,"exp stored")); if(!player.capabilities.isCreativeMode) { player.addExperienceLevel(-1); } } if (!player.isSneaking()) { System.out.println("not crouching"); System.out.println(NBTHelper.getInt(itemstack,"exp stored")); if (NBTHelper.getInt(itemstack, "exp stored")>0) { System.out.println("outputing levels..."); player.addExperienceLevel(1); if(!player.capabilities.isCreativeMode) { NBTHelper.setInteger(itemstack,"exp stored", NBTHelper.getInt(itemstack,"exp stored")-1); } } } return true; } }
  7. hi, I tried it, but in the code I try to create and set NBT to the stack but it crashes with the following:
  8. my hand was not empty, I was holding the Item. I tried holding bottles of enchanting from vanilla and empty hand, all crashed.
  9. hello, I want to operate a piece of code when a item is right clicked. I get a crash from the following code: @SubscribeEvent public void ExpCatalyst (PlayerInteractEvent event) { //crash here if(event.entityPlayer.getItemInUse().getItem().getUnlocalizedName().contains(ModItems.expCatalyst.getUnlocalizedName()) && ModItems.expCatalyst.getUnlocalizedName().contains(event.entityPlayer.getItemInUse().getItem().getUnlocalizedName()) ) the crash report is here From what I tried, I saw the crash was caused because "getItemInUse()" returned null, but I right clicked the Item. If anyone could help, I would highly appreciate.

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.