Skip to content

[BUG-Report] NullPointerException when Entity attacks while weapon has no material#90

Open
queria wants to merge 1 commit into
rossturner:masterfrom
queria:crash-npe-attack-no-weapon-attribute
Open

[BUG-Report] NullPointerException when Entity attacks while weapon has no material#90
queria wants to merge 1 commit into
rossturner:masterfrom
queria:crash-npe-attack-no-weapon-attribute

Conversation

@queria

@queria queria commented Aug 9, 2025

Copy link
Copy Markdown

// Please consider this currently as bug report ... since there are no Issues open on this repo ... currently I have no clue yet what caused it and how it could be prevented/fixed.

After Orcs Invaded settlement (still in the camping phase), something started fight and game crashed.

Currently do not know what happened yet,
so attempt to get more details logged.
(Based on code i suspect it may be for example case of UNARMED weapon,
as set at start of CreatureCombat constructor while not setting
equippedWeaponQuality so would be left as null.)

ERROR: java.lang.NullPointerException: Cannot invoke "technology.rocketjump.mountaincore.entities.model.physical.item.ItemEntityAttributes.getPrimaryMaterial()" because the return value of "technology.rocketjump.mountaincore.entities.ai.combat.CreatureCombat.getEquippedWeaponAttributes()" is null
at technology.rocketjump.mountaincore.entities.ai.combat.AttackCreatureCombatAction.triggerAttack(AttackCreatureCombatAction.java:125)
at technology.rocketjump.mountaincore.entities.ai.combat.AttackCreatureCombatAction.update(AttackCreatureCombatAction.java:75)
at technology.rocketjump.mountaincore.entities.behaviour.creature.CombatBehaviour.update(CombatBehaviour.java:140)
at technology.rocketjump.mountaincore.entities.behaviour.creature.CreatureBehaviour.update(CreatureBehaviour.java:127)
at technology.rocketjump.mountaincore.entities.model.Entity.update(Entity.java:232)
at technology.rocketjump.mountaincore.entities.EntityUpdater.update(EntityUpdater.java:32)
at technology.rocketjump.mountaincore.gamecontext.GameUpdateRegister.update(GameUpdateRegister.java:32)

@queria

queria commented Aug 10, 2025

Copy link
Copy Markdown
Author

Seems not just orcs - issued command to military group to hunt down one elephant, seems others wanted to defend/awange it ... game crashes (and yes, need to log more info about the weapon type):

ERROR: Entity Entity{id=6068, type=CREATURE, physical=CreatureEntityAttributes{race=Elephant, gender=FEMALE, bodyShape=AVERAGE, consciousness=AWAKE}} unable to attack Entity{id=1419628, type=CREATURE, physical=CreatureEntityAttributes{race=Dwarf, gender=MALE, bodyShape=STRONG, consciousness=AWAKE}} with technology.rocketjump.mountaincore.entities.model.physical.combat.WeaponInfo@12876dd0
ERROR: java.lang.NullPointerException: Cannot invoke "technology.rocketjump.mountaincore.entities.model.physical.item.ItemEntityAttributes.getPrimaryMaterial()" because the return value of "technology.rocketjump.mountaincore.entities.ai.combat.CreatureCombat.getEquippedWeaponAttributes()" is null
        at technology.rocketjump.mountaincore.entities.ai.combat.AttackCreatureCombatAction.triggerAttack(AttackCreatureCombatAction.java:127)
        at technology.rocketjump.mountaincore.entities.ai.combat.AttackCreatureCombatAction.update(AttackCreatureCombatAction.java:76)
        at technology.rocketjump.mountaincore.entities.behaviour.creature.CombatBehaviour.update(CombatBehaviour.java:140)
        at technology.rocketjump.mountaincore.entities.behaviour.creature.CreatureBehaviour.update(CreatureBehaviour.java:127)
        at technology.rocketjump.mountaincore.entities.model.Entity.update(Entity.java:232)
        at technology.rocketjump.mountaincore.entities.EntityUpdater.update(EntityUpdater.java:32)
        at technology.rocketjump.mountaincore.gamecontext.GameUpdateRegister.update(GameUpdateRegister.java:32)

After Orcs Invaded settlement (still in the camping phase),
something started fight and game crashed.

Currently do not know what happened yet,
so attempt to get more details logged.
(Based on code i suspect it may be for example case of UNARMED weapon,
 as set at start of CreatureCombat constructor while not setting
 equippedWeaponQuality so would be left as null.)

ERROR: java.lang.NullPointerException: Cannot invoke "technology.rocketjump.mountaincore.entities.model.physical.item.ItemEntityAttributes.getPrimaryMaterial()" because the return value of "technology.rocketjump.mountaincore.entities.ai.combat.CreatureCombat.getEquippedWeaponAttributes()" is null
        at technology.rocketjump.mountaincore.entities.ai.combat.AttackCreatureCombatAction.triggerAttack(AttackCreatureCombatAction.java:125)
        at technology.rocketjump.mountaincore.entities.ai.combat.AttackCreatureCombatAction.update(AttackCreatureCombatAction.java:75)
        at technology.rocketjump.mountaincore.entities.behaviour.creature.CombatBehaviour.update(CombatBehaviour.java:140)
        at technology.rocketjump.mountaincore.entities.behaviour.creature.CreatureBehaviour.update(CreatureBehaviour.java:127)
        at technology.rocketjump.mountaincore.entities.model.Entity.update(Entity.java:232)
        at technology.rocketjump.mountaincore.entities.EntityUpdater.update(EntityUpdater.java:32)
        at technology.rocketjump.mountaincore.gamecontext.GameUpdateRegister.update(GameUpdateRegister.java:32)
@queria
queria force-pushed the crash-npe-attack-no-weapon-attribute branch from 21f55eb to b24b0ee Compare August 10, 2025 18:36
@queria

queria commented Aug 11, 2025

Copy link
Copy Markdown
Author

This can happen also when Dwarf freshly switched to military attempts to start training, and at least in that case it IS NOT? the case of UNARMED weapon:

ERROR: Entity Entity{id=4306180, type=CREATURE, physical=CreatureEntityAttributes{race=Dwarf, gender=FEMALE, bodyShape=AVERAGE, consciousness=AWAKE}} unable to attack Entity{id=2239215, type=FURNITURE, physical=FurnitureEntityAttributes{furnitureType=TRAINING_DUMMY, primaryMaterialType=Wood, currentLayout=1x1 with N workspace}} with technology.rocketjump.mountaincore.entities.model.physical.combat.WeaponInfo@708b746d (unarmed: false, sprite: Weapon slash, damageType: CRUSHING))
ERROR: java.lang.NullPointerException: Cannot invoke "technology.rocketjump.mountaincore.entities.model.physical.item.ItemEntityAttributes.getPrimaryMaterial()" because the return value of "technology.rocketjump.mountaincore.entities.ai.combat.CreatureCombat.getEquippedWeaponAttributes()" is null
        at technology.rocketjump.mountaincore.entities.ai.combat.AttackCreatureCombatAction.triggerAttack(AttackCreatureCombatAction.java:127)
        at technology.rocketjump.mountaincore.entities.ai.combat.AttackCreatureCombatAction.update(AttackCreatureCombatAction.java:76)
        at technology.rocketjump.mountaincore.entities.ai.goap.actions.military.AttackTrainingFurnitureAction.update(AttackTrainingFurnitureAction.java:50)
        at technology.rocketjump.mountaincore.entities.ai.goap.AssignedGoal.checkForActionCompletionOrElseUpdate(AssignedGoal.java:169)
        at technology.rocketjump.mountaincore.entities.ai.goap.AssignedGoal.update(AssignedGoal.java:144)
        at technology.rocketjump.mountaincore.entities.behaviour.creature.CreatureBehaviour.update(CreatureBehaviour.java:149)
        at technology.rocketjump.mountaincore.entities.model.Entity.update(Entity.java:232)
        at technology.rocketjump.mountaincore.entities.EntityUpdater.update(EntityUpdater.java:32)
        at technology.rocketjump.mountaincore.gamecontext.GameUpdateRegister.update(GameUpdateRegister.java:32)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant