April 26, 201510 yr Author It prints out two times in the console saying it set. I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
April 26, 201510 yr It prints out two times in the console saying it set. add print in stackTag in on created after fix tags, and see what it gives. Also, nbt manipulations must be server side only. Check that... Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
April 26, 201510 yr Author I do check if it is the server: if(world.isRemote) return; And when it printed out it said this: [01:38:47] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:46]: {MiningSize:"1x1",} [01:38:47] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:46]: {MiningSize:"3x3",} The fixNBT sets it to 1x1 and then I set it to 3x3. Both of those are called by doing: System.out.println(stack.stackTagCompound); I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
April 26, 201510 yr One more thing: for your item, no need for event, use onBlockDestroyed method instead!!! Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
April 26, 201510 yr Author Even when I do that, it would still require me to be able to set and update the nbt for the item from the GUI class. I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
April 26, 201510 yr Even when I do that, it would still require me to be able to set and update the nbt for the item from the GUI class. Yes, but use it instead... It's better... Are you sure that you are using same tool. Now, please, if you can, post your final code and console log (with print in stack tag)... Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
April 26, 201510 yr Author What do you mean by the same tool? And there would be no final code as of yet considering my problem is not solved. I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
April 26, 201510 yr Author So, I did what you said but still the same problem. I moved my code under the "onBlockDestroyed" method in my item class yet, the NBT of the stack still returns null. Am I not setting it correctly? Ignore the GUI stuff. public void onCreated(ItemStack stack, World world, EntityPlayer player) { if(world.isRemote) return; NBTTagCompound cmp = stack.stackTagCompound; if(cmp == null) { System.out.println("NBT TAG SET"); cmp = new NBTTagCompound(); stack.stackTagCompound = cmp; } this.fixNBT(stack); System.out.println(stack.stackTagCompound); cmp.setString("MiningSize", "3x3"); } public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean flag) { list.add(EnumChatFormatting.RED + "Use SHIFT + Right-Click to"); list.add(EnumChatFormatting.RED + "open the modification menu."); list.add(""); list.add(EnumChatFormatting.GREEN + "Hit Left-ALT to open the"); list.add(EnumChatFormatting.GREEN + "quick change menu."); } public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if(player.isSneaking()) { FMLNetworkHandler.openGui(player, CrewMod.instance, GuiId.guiCrewHammerID, world, (int)player.posX, (int)player.posY, (int)player.posZ); } return stack; } public static void fixNBT(ItemStack hammer){ NBTTagCompound cmp = hammer.stackTagCompound; if(cmp == null) { System.out.println("CMP WAS NULL, FIXING..."); hammer.stackTagCompound = new NBTTagCompound(); cmp = hammer.stackTagCompound; } if(!cmp.hasKey("MiningSize")){ System.out.println("MiningSize WAS NULL, FIXING..."); cmp.setString("MiningSize", "1x1"); } hammer.stackTagCompound = cmp; } public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { EntityPlayer player = (EntityPlayer)entity; System.out.println("CALLED"); if(world != null && player != null) { System.out.println("WORLD WAS NOT NULL NOR WAS PLAYER"); if(player.inventory.getCurrentItem() != null) { if(player.inventory.getCurrentItem().getItem().equals(CrewMod.crewHammer)) { int direction = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; ItemStack hammer = stack; //System.out.println("ITEM IN HAND IS CREW HAMMER"); //Block block = event.block; //World world = event.world; //int x = event.x; //int y = event.y; //int z = event.z; CrewHammer.fixNBT(hammer); NBTTagCompound cmp = hammer.stackTagCompound; //if(event.isCanceled()) //return; String miningArea = null; if(cmp != null) { miningArea = cmp.getString("MiningSize"); //System.out.println("CMP WAS NOT NULL"); } System.out.println(miningArea); this.breakBlock(world, player, hammer, x, y, z, direction, miningArea); }else { super.onBlockDestroyed(stack, world, block, x, y, z, entity); } }else { super.onBlockDestroyed(stack, world, block, x, y, z, entity); } } return true; } I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
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.