Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: [CrafTweaker] NullPointerException when trying to read data from a block #291

Closed
Shibva opened this issue Nov 10, 2023 · 7 comments
Closed

Comments

@Shibva
Copy link

Shibva commented Nov 10, 2023

Describe the bug
when using a script (Provided below) will cause a NullPointException to be thrown when it previously dint in
4.11.1.0

To Reproduce
Steps to reproduce the behavior:

  1. Install CraftTweaker and Script Below (configuration will be slightly modified for the sake of reducing mods)
  2. Open a new world in create
  3. place a stargate base block of any kind (except for orlin, this one is not used by the script since its not world-generated :P)
  4. go into survival
  5. mine with anything (for the scrip ill send you it will be set as a iron hoe, golden axe, and diamond shovel as valid breaking tools; this is just for limited mod tested to take place without the need to add additional mods I swear)

Expected behavior
The script itself no longer producing a NullPointerException whenever it ties to mine a block with this script like it did in 4.11.1.0

Screenshots
the erroing portion of the CT log (tip: if you need to access this look inside the logs folder)
image

Mod version
4.11.2.3

Additional context
The Script is made to allow for world-generated stargates to be unmineable unless you have a specific tool(s) that accept it; if you don't have it then it will cancel the onBlockBreaking event that takes place when mining it. This does not happen If a tag isPlayerPlaced: true is present; this is done by using a clever trick by writing it inside of ForgeData when the block is placed by a player. To be real with you it was working before 4.11.2.0 and I was proud of it since it took me a long time to figure out a way for this to work lel.

It also should be noted that the gate base blocks are the only blocks having this issue, as the other blocks do not have this problem.

Script (minor modifications from the actual; changes only what the valid tools are [iron_hoe, gold_axe, diamond_shovel] (place into the slots folder once you run an instance with CT once)
gated_stargate_salvage_protecter_V1.zip

My whole JSG config (as .zip)
jsg.zip

@MineDragonCZ MineDragonCZ added Will not be fixed/added Can not fix this/add this Not possible Not possible or very hard to do it labels Nov 10, 2023
@MineDragonCZ
Copy link
Member

This issue is probably caused by crafttweaker itself. Idk why its in this version and the old one no. Maybe its random...
I can't fi it, because its problem somehow with NBT serialization.

@MineDragonCZ
Copy link
Member

also its duplicate of #290

@Shibva
Copy link
Author

Shibva commented Nov 10, 2023

It could be caused by some change you made to the base block itself

It only does this if you mine it

By guess is that it's updating while it's being mined for some reason

@Shibva
Copy link
Author

Shibva commented Nov 10, 2023

@MineDragonCZ I wonder if it has to do with the recent implementation of being able to wrench a block

Whatever it is; my educated guess is that a change that you made to the baseBlock between those versions cause the behavior of the block to update the entirety of its data while it's being mined; because it essentially all boils down to this for the script: the block data itself briefly does not exist while it's being broken and that's what's causing it to throw a NPE because for that brief moment, it does not exist.

Anyhow, thanks for looking into this, even if it doesn't yield anything

If you like what my script is doing by prohibiting world generated, nonplayer placed gates when feel free to implement it, because essentially this script was supposed to use as a utility

@MR-Spagetty
Copy link
Contributor

also its duplicate of #290

No its not #290 was a different issue shibva saw was similar to their own

@Shibva
Copy link
Author

Shibva commented Nov 11, 2023

It appears to be very similar however @MR-Spagetty

If you look at the line in their crash report it's writing to NBT. It could be because of updates that that crash was happening in #290

In my situation, it was reading it and technically it's not a crash in my situation, but it does prevent the script from working correctly because it's throwing a NPE with that block in particular

@Shibva
Copy link
Author

Shibva commented Nov 11, 2023

While it is two different issues; they're all being caused by the same thing I believe; something that is causing the NBT data to be absent when it's being checked. it's acting like it wiping and then re-writing itself whenever it updates or something

@MineDragonCZ MineDragonCZ reopened this Nov 12, 2023
@MineDragonCZ MineDragonCZ removed Will not be fixed/added Can not fix this/add this Not possible Not possible or very hard to do it labels Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants