diff --git a/src/main/java/com/minecolonies/core/entity/citizen/citizenhandlers/CitizenExperienceHandler.java b/src/main/java/com/minecolonies/core/entity/citizen/citizenhandlers/CitizenExperienceHandler.java index fa16ec6130c..53fe86aeba0 100755 --- a/src/main/java/com/minecolonies/core/entity/citizen/citizenhandlers/CitizenExperienceHandler.java +++ b/src/main/java/com/minecolonies/core/entity/citizen/citizenhandlers/CitizenExperienceHandler.java @@ -7,13 +7,13 @@ import com.minecolonies.api.entity.citizen.citizenhandlers.ICitizenExperienceHandler; import com.minecolonies.api.util.CompatibilityUtils; import com.minecolonies.api.util.WorldUtil; +import com.minecolonies.core.colony.buildings.modules.WorkerBuildingModule; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.ExperienceOrb; -import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.world.level.GameRules; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; -import net.minecraft.world.level.GameRules; -import com.minecolonies.core.colony.buildings.modules.WorkerBuildingModule; import org.jetbrains.annotations.NotNull; import static com.minecolonies.api.research.util.ResearchConstants.LEVELING; @@ -100,12 +100,27 @@ public void addExperience(final double xp) final Skill secondary = module.getSecondarySkill(); data.getCitizenSkillHandler().addXpToSkill(primary, localXp, data); - data.getCitizenSkillHandler().addXpToSkill(primary.getComplimentary(), localXp / (100.0 / PRIMARY_DEPENDENCY_SHARE), data); - data.getCitizenSkillHandler().removeXpFromSkill(primary.getAdverse(), localXp / (100.0 / PRIMARY_DEPENDENCY_SHARE), data); + if (primary.getComplimentary() != null) + { + data.getCitizenSkillHandler().addXpToSkill(primary.getComplimentary(), localXp / (100.0 / PRIMARY_DEPENDENCY_SHARE), data); + } + + if (primary.getAdverse() != null) + { + data.getCitizenSkillHandler().removeXpFromSkill(primary.getAdverse(), localXp / (100.0 / PRIMARY_DEPENDENCY_SHARE), data); + } data.getCitizenSkillHandler().addXpToSkill(secondary, localXp / 2.0, data); - data.getCitizenSkillHandler().addXpToSkill(secondary.getComplimentary(), localXp / (100.0 / SECONDARY_DEPENDENCY_SHARE), data); - data.getCitizenSkillHandler().removeXpFromSkill(secondary.getAdverse(), localXp / (100.0 / SECONDARY_DEPENDENCY_SHARE), data); + + if (secondary.getComplimentary() != null) + { + data.getCitizenSkillHandler().addXpToSkill(secondary.getComplimentary(), localXp / (100.0 / SECONDARY_DEPENDENCY_SHARE), data); + } + + if (secondary.getAdverse() != null) + { + data.getCitizenSkillHandler().removeXpFromSkill(secondary.getAdverse(), localXp / (100.0 / SECONDARY_DEPENDENCY_SHARE), data); + } } @Override