Jump to content

thewaterwell

Forge Modder
  • Posts

    9
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

thewaterwell's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  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.
×
×
  • Create New...

Important Information

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