[1.20.1-2.0.36.1199] NPE Crash in AI with Twilight Cloak and Hoglins
TigerWalts opened this issue ยท 2 comments
Having the Twilight Cloak near Hoglins may result in a crash. This has been observed in ATM9 0.0.45. It can also be reproduced with just Reliquary.
- Forge 1.20.1 47.1.0
- Reliquary 1.20.1-2.0.36.1199
- Create a world with cheats on
- Change your gamemode to
creative
and give yourself theTwilight Cloak
- Go somewhere dark enough for the cloak to give you the invisibility effect
- Give yourself a
Hoglin spawn egg
and use it to spawn a hoglin - Change the gamemode to
survival
- Drop the cloak and pick it up
Repeat until the game crashes - Reloading into the game will likely immediately crash if your saved state is to be near the hoglin in survival mode with the cloak
java.lang.NullPointerException: Ticking entity
at java.util.Objects.requireNonNull(Objects.java:208) ~[?:?] {}
at java.util.Optional.of(Optional.java:113) ~[?:?] {}
at net.minecraft.world.entity.ai.behavior.declarative.MemoryAccessor.m_257512_(MemoryAccessor.java:30) ~[client-1.20.1-20230612.114412-srg.jar%23158!/:?] {re:classloading}
at net.minecraft.world.entity.ai.behavior.StartAttacking.m_257271_(StartAttacking.java:37) ~[client-1.20.1-20230612.114412-srg.jar%23158!/:?] {re:classloading}
at net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder$1.m_257808_(BehaviorBuilder.java:53) ~[client-1.20.1-20230612.114412-srg.jar%23158!/:?] {re:classloading}
at net.minecraft.world.entity.ai.behavior.OneShot.m_22554_(OneShot.java:20) ~[client-1.20.1-20230612.114412-srg.jar%23158!/:?] {re:classloading}
at net.minecraft.world.entity.ai.Brain.m_21957_(Brain.java:533) ~[client-1.20.1-20230612.114412-srg.jar%23158!/:?] {re:classloading}
at net.minecraft.world.entity.ai.Brain.m_21865_(Brain.java:492) ~[client-1.20.1-20230612.114412-srg.jar%23158!/:?] {re:classloading}
at net.minecraft.world.entity.monster.hoglin.Hoglin.m_8024_(Hoglin.java:124) ~[client-1.20.1-20230612.114412-srg.jar%23158!/:?] {re:classloading}
...
at net.minecraft.world.level.entity.EntityTickList.m_156910_(EntityTickList.java:54) ~[client-1.20.1-20230612.114412-srg.jar%23158!/:?] {re:classloading}
I checked the hoglin's save data between a crashing state and a normal state and their 'brain` tags are the same, containing an empty memories collection.
Because it didn't crash each time the invisibility effect was applied there may be a race involved.
The MobHelper.resetTarget()
call may need to be run as a task at another point in the tick cycle, even though I can't see why it could cause this crash as it doesn't appear to remove any memories and sets them to Empty.
Reliquary/src/main/java/reliquary/util/MobHelper.java
Lines 19 to 39 in 32deb62
This affects the twilight cloak and the mob charm items.
The problem is that both use event.setNewTarget(null);
in the LivingChangeTargetEvent
when they should be simply cancelling the event via event.setCanceled(true);
For those running into this problem and need a fix, you can disable the item in the player's Curios inventory as follows:
- Open the player's save data in an NBT editor:
- Locate the Cloak or Charm in the Curios inventory
- The tag path to the inventory is:
ForgeCaps
>curios:inventory
>Curios
- Inside each
Curios
inventory you'll find the items in the tag pathStacksHandler
>Stacks
>Items
- Once you have found the item, open the
tag
tag and set theenabled
tag inside it to0
If the item is in the main Inventory
tag and is passively enabled, you may have to resort to deleting it.