Posted May 9, 201510 yr I have a block that you right click on to "store" a certain item in, when it's stored a boolean is made true, which is being written to NBT, when its taken out, the boolean is made false. The issue is, when I put a stdout with the boolean variable in it, I found out that it's alternating between true and false every other tick, which is a huge problem, and I can't figure out why it's doing that. TESR TileEntity Block Dummy Block
May 9, 201510 yr Not sure why the boolean value would be switching, your code looks fine, but I've noticed a couple minor issues in your code: 1) When you get your TileEntity using (TEChaliceOfTheVoid)world.getTileEntity(x, y - 1, z) you don't check if the TileEntity returned by World#getTileEntity is actually an instance of TEChaliceOfTheVoid, which could cause ClassCastException(s). Check this using world.getTileEntity(x, y - 1, z) instanceof TEChaliceOfTheVoid and if that's true cast it like so: if (world.getTileEntity(x, y - 1, z) instanceof TEChaliceOfTheVoid) { TEChaliceOfTheVoid chaliceTE = (TEChaliceOfTheVoid)world.getTileEntity(x, y - 1, z); } 2) When you use world.getBlock(x, y - 1, z).setHardness(-1.0f); you not only set the hardness for block at the specified coordinates, you set the hardness for every instance of that block in the game, and I doubt this is the intended behavior. My suggestion is that you add an additional variable to your TileEntity that specifies whether the block can be broken or not and check that variable when someone attempts to break the block. 3) You decrease the stackSize of the ItemStack when you add the pendant to the TE, but you don't check if the stackSize is zero. If the stackSize does happen to be zero, there will be an ItemStack in the player's inventory that contains 0 of your item, this is not how MC works. Immediately after you decrease the stackSize, you should check if it's zero and if so, set the stack to null. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
May 9, 201510 yr Author You should never be able to separate the dummy block and the chalice block, and when one is destroyed, the other is too. If I wanted to be completely safe, I could check that cast, but for now, it doesn't matter. Whoops, missed that, I'll add that to the TE's NBT. MaxStackSize is 1 on the pendant, but if I wanted to be safe, again I guess I could check that, but it doesn't affect anything right now. Edit: but you could pickblock the dummy, so fixed that.
May 9, 201510 yr Author Could it be doing this because I'm using an ISBRH to do the inventory render for it?
May 9, 201510 yr I don't think so, an ISBRH shouldn't be modifying the NBT. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
May 9, 201510 yr Author Turns out that's exactly what it was, it seemed to be switching between the inventory TE/block and world TE/block every other frame, removing the ISBRH fixed it. Now I need to figure out how to draw the model in the inventory...
May 11, 201510 yr Author As an addendum to this, I forgot to check if the TE's worldObj was null, checking that allowed me to use the ISBRH and TESR together with no issues.
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.