Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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.

Posted

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...

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

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