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]: Cannot invoke "java.lang.Float.floatValue()" because the return value of "java.util.Map.get(Object)" is null #195

Open
Ximu-Luya opened this issue Jun 30, 2024 · 1 comment
Assignees
Labels
status: triage This issue or pull request is awaiting review type: bug Something isn't working

Comments

@Ximu-Luya
Copy link

Minecraft Version

1.20.1

What happened?

The game crashed after I ate an apple

The crash log shows that this mod caused the crash

It is also possible that the crash is not caused by mod code, but my datapack configuration problem, please correct

How do you trigger this bug?

The following is the datapack:

  1. data\diet\diet\groups\vitamin.json
{
  "icon": "minecraft:apple",
  "color": "#36ecd5",
  "order": 4,
  "default_value": 0.35,
  "gain_multiplier": 3.0,
  "decay_multiplier": 1.5,
  "beneficial": true
}
  1. data\diet\tags\items\vitamin.json
{
  "replace":true,
  "values": [
    {
      "id": "minecraft:apple",
      "required": false
    },
    ...
  ]
}

I thought it was configured correctly.

Loader

Forge

Loader Version

Forge 47.3.1

API Version

No response

Mod Version

diet-forge-2.1.1+1.20.1

Relevant Log Outputs

java.lang.NullPointerException: Cannot invoke "java.lang.Float.floatValue()" because the return value of "java.util.Map.get(Object)" is null
	at com.illusivesoulworks.diet.common.capability.PlayerDietTracker.apply(PlayerDietTracker.java:340) ~[%5B均衡饮食%5D%20diet-forge-2.1.1+1.20.1.jar%23306!/:2.1.1+1.20.1] {re:classloading}
	at com.illusivesoulworks.diet.common.capability.PlayerDietTracker.consume(PlayerDietTracker.java:177) ~[%5B均衡饮食%5D%20diet-forge-2.1.1+1.20.1.jar%23306!/:2.1.1+1.20.1] {re:classloading}
	at com.illusivesoulworks.diet.common.capability.DietCapabilityEventsListener.lambda$finishItemUse$2(DietCapabilityEventsListener.java:118) ~[%5B均衡饮食%5D%20diet-forge-2.1.1+1.20.1.jar%23306!/:2.1.1+1.20.1] {re:classloading}
	at net.minecraftforge.common.util.LazyOptional.ifPresent(LazyOptional.java:137) ~[forge-1.20.1-47.3.1-universal.jar%23387!/:?] {re:mixin,re:classloading}
	at com.illusivesoulworks.diet.common.capability.DietCapabilityEventsListener.finishItemUse(DietCapabilityEventsListener.java:118) ~[%5B均衡饮食%5D%20diet-forge-2.1.1+1.20.1.jar%23306!/:2.1.1+1.20.1] {re:classloading}
	at com.illusivesoulworks.diet.common.capability.__DietCapabilityEventsListener_finishItemUse_Finish.invoke(.dynamic) ~[%5B均衡饮食%5D%20diet-forge-2.1.1+1.20.1.jar%23306!/:2.1.1+1.20.1] {re:classloading,pl:eventbus:B}
	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%23137!/:?] {}
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%23137!/:?] {}
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%23137!/:?] {}
	at net.minecraftforge.event.ForgeEventFactory.onItemUseFinish(ForgeEventFactory.java:396) ~[forge-1.20.1-47.3.1-universal.jar%23387!/:?] {re:classloading}
...
@Ximu-Luya Ximu-Luya added status: triage This issue or pull request is awaiting review type: bug Something isn't working labels Jun 30, 2024
@Ximu-Luya
Copy link
Author

I used the exclusion method to think about the difference between before and after the datapack modification.

The exception seems to have occurred after I removed the default food group configuration (e.g. fruit.json, vegetables.json) under the tag/items/ directory.

I added them back and no more crashes.

I can play normally now, but I hope this information will help you troubleshoot the problem, or explain why I can't remove the default configuration e.g. fruit.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: triage This issue or pull request is awaiting review type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants