diff --git a/src/main/java/com/minecolonies/api/entity/citizen/AbstractEntityCitizen.java b/src/main/java/com/minecolonies/api/entity/citizen/AbstractEntityCitizen.java index df01cb05499..784a91b9988 100755 --- a/src/main/java/com/minecolonies/api/entity/citizen/AbstractEntityCitizen.java +++ b/src/main/java/com/minecolonies/api/entity/citizen/AbstractEntityCitizen.java @@ -623,13 +623,6 @@ public boolean checkCanDropLoot() */ public abstract ICitizenExperienceHandler getCitizenExperienceHandler(); - /** - * The Handler for all item related methods. - * - * @return the instance of the handler. - */ - public abstract ICitizenItemHandler getCitizenItemHandler(); - /** * The Handler for all inventory related methods. * @@ -672,8 +665,6 @@ public boolean checkCanDropLoot() public abstract void setCitizenJobHandler(ICitizenJobHandler citizenJobHandler); - public abstract void setCitizenItemHandler(ICitizenItemHandler citizenItemHandler); - public abstract void setCitizenExperienceHandler(ICitizenExperienceHandler citizenExperienceHandler); /** diff --git a/src/main/java/com/minecolonies/api/entity/citizen/citizenhandlers/ICitizenItemHandler.java b/src/main/java/com/minecolonies/api/entity/citizen/citizenhandlers/ICitizenItemHandler.java deleted file mode 100755 index c39aeb9dd05..00000000000 --- a/src/main/java/com/minecolonies/api/entity/citizen/citizenhandlers/ICitizenItemHandler.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.minecolonies.api.entity.citizen.citizenhandlers; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.item.ItemStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public interface ICitizenItemHandler -{ - /** - * Citizen will try to pick up a certain item. - * - * @param ItemEntity the item he wants to pickup. - */ - void tryPickupItemEntity(@NotNull ItemEntity ItemEntity); - - /** - * Removes the currently held item. - */ - void removeHeldItem(); - - /** - * Sets the currently held item. - * - * @param hand what hand we're setting - * @param slot from the inventory slot. - */ - void setHeldItem(InteractionHand hand, int slot); - - /** - * Sets the currently held for mainHand item. - * - * @param slot from the inventory slot. - */ - void setMainHeldItem(int slot); - - /** - * Swing entity arm, create sound and particle effects. - *
- * Will not break the block. - * - * @param blockPos Block position. - */ - void hitBlockWithToolInHand(@Nullable BlockPos blockPos); - - /** - * Swing entity arm, create sound and particle effects. - *
- * If breakBlock is true then it will break the block (different sound and particles), and damage the tool in the citizens hand. - * - * @param blockPos Block position. - * @param breakBlock if we want to break this block. - */ - void hitBlockWithToolInHand(@Nullable BlockPos blockPos, boolean breakBlock); - - /** - * Damage the current held item. - * - * @param hand hand the item is in. - * @param damage amount of damage. - */ - void damageItemInHand(InteractionHand hand, int damage); - - /** - * Pick up all items in a range around the citizen. - */ - void pickupItems(); - - /** - * Swing entity arm, create sound and particle effects. - *
- * This will break the block (different sound and particles), and damage the tool in the citizens hand.
- *
- * @param blockPos Block position.
- */
- void breakBlockWithToolInHand(@Nullable BlockPos blockPos);
-
- /**
- * Handles the dropping of items from the entity.
- *
- * @param itemstack to drop.
- * @return the dropped item.
- */
- ItemEntity entityDropItem(@NotNull ItemStack itemstack);
-
- /**
- * Updates the armour damage after being hit.
- *
- * @param damage damage dealt.
- */
- void updateArmorDamage(double damage);
-
- /**
- * Apply mending to the armour.
- *
- * @param localXp the xp to add.
- * @return the remaining xp.
- */
- double applyMending(final double localXp);
-}
diff --git a/src/main/java/com/minecolonies/core/colony/jobs/JobKnight.java b/src/main/java/com/minecolonies/core/colony/jobs/JobKnight.java
index 7ccbe0e30b0..5b52bbda689 100755
--- a/src/main/java/com/minecolonies/core/colony/jobs/JobKnight.java
+++ b/src/main/java/com/minecolonies/core/colony/jobs/JobKnight.java
@@ -1,5 +1,6 @@
package com.minecolonies.core.colony.jobs;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import net.minecraft.core.component.DataComponents;
import net.minecraft.resources.ResourceLocation;
import com.minecolonies.api.client.render.modeltype.ModModelTypes;
@@ -83,7 +84,7 @@ public boolean ignoresDamage(@NotNull final DamageSource damageSource)
return true;
}
final AbstractEntityCitizen worker = this.getCitizen().getEntity().get();
- worker.getCitizenItemHandler().setHeldItem(InteractionHand.OFF_HAND, InventoryUtils.findFirstSlotInItemHandlerWith(this.getCitizen().getInventory(), Items.SHIELD));
+ CitizenItemUtils.setHeldItem(worker, InteractionHand.OFF_HAND, InventoryUtils.findFirstSlotInItemHandlerWith(this.getCitizen().getInventory(), Items.SHIELD));
worker.startUsingItem(InteractionHand.OFF_HAND);
ItemStack shieldStack = worker.getInventoryCitizen().getHeldItem(InteractionHand.OFF_HAND);
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIBasic.java b/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIBasic.java
index eba5a152338..e1ed002e1fe 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIBasic.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIBasic.java
@@ -35,6 +35,7 @@
import com.minecolonies.core.colony.jobs.AbstractJob;
import com.minecolonies.core.colony.jobs.JobDeliveryman;
import com.minecolonies.core.colony.requestsystem.resolvers.StationRequestResolver;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.core.entity.pathfinding.proxy.EntityCitizenWalkToProxy;
import com.minecolonies.core.tileentities.TileEntityRack;
import com.minecolonies.core.util.WorkerUtil;
@@ -520,7 +521,7 @@ private boolean waitingForSomething()
currentWorkingLocation.getZ(),
DEFAULT_RANGE_FOR_DELAY))
{
- worker.getCitizenItemHandler().hitBlockWithToolInHand(currentWorkingLocation);
+ CitizenItemUtils.hitBlockWithToolInHand(worker, currentWorkingLocation);
}
delay -= getTickRate();
if (delay <= 0)
@@ -1278,13 +1279,13 @@ public final boolean holdEfficientTool(@NotNull final BlockState target, final B
if (bestSlot >= 0)
{
worker.getCitizenData().setIdleAtJob(false);
- worker.getCitizenItemHandler().setHeldItem(InteractionHand.MAIN_HAND, bestSlot);
+ CitizenItemUtils.setHeldItem(worker, InteractionHand.MAIN_HAND, bestSlot);
return true;
}
else if (bestSlot == NO_TOOL)
{
worker.getCitizenData().setIdleAtJob(false);
- worker.getCitizenItemHandler().removeHeldItem();
+ CitizenItemUtils.removeHeldItem(worker);
return true;
}
requestTool(target, pos);
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIInteract.java b/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIInteract.java
index 49bdfc66bf7..21dd5f88b0e 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIInteract.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIInteract.java
@@ -5,6 +5,7 @@
import com.minecolonies.core.MineColonies;
import com.minecolonies.core.colony.buildings.AbstractBuilding;
import com.minecolonies.core.colony.jobs.AbstractJob;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.core.entity.pathfinding.pathresults.PathResult;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.item.ItemEntity;
@@ -217,7 +218,7 @@ protected final boolean mineBlock(
if (blockBreakAction == null)
{
//Break the block
- worker.getCitizenItemHandler().breakBlockWithToolInHand(blockToMine);
+ CitizenItemUtils.breakBlockWithToolInHand(worker, blockToMine);
}
else
{
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/AbstractEntityAICrafting.java b/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/AbstractEntityAICrafting.java
index aa9ee490594..093c2b3ab7e 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/AbstractEntityAICrafting.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/AbstractEntityAICrafting.java
@@ -23,6 +23,7 @@
import com.minecolonies.core.colony.jobs.AbstractJobCrafter;
import com.minecolonies.core.entity.ai.workers.AbstractEntityAIInteract;
import com.minecolonies.core.entity.citizen.EntityCitizen;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.core.network.messages.client.BlockParticleEffectMessage;
import com.minecolonies.core.network.messages.client.LocalizedParticleEffectMessage;
import net.minecraft.core.BlockPos;
@@ -34,7 +35,6 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootParams;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
-import net.neoforged.neoforge.network.PacketDistributor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -449,7 +449,7 @@ protected IAIState craft()
job.setCraftCounter(job.getCraftCounter() + 1);
if (toolSlot != -1)
{
- worker.getCitizenItemHandler().damageItemInHand(InteractionHand.MAIN_HAND, 1);
+ CitizenItemUtils.damageItemInHand(worker, InteractionHand.MAIN_HAND, 1);
}
if (job.getCraftCounter() >= job.getMaxCraftingCount())
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/AbstractEntityAIRequestSmelter.java b/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/AbstractEntityAIRequestSmelter.java
index 4230ab292ae..6946a4cebc4 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/AbstractEntityAIRequestSmelter.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/AbstractEntityAIRequestSmelter.java
@@ -24,6 +24,7 @@
import com.minecolonies.core.colony.interactionhandling.StandardInteraction;
import com.minecolonies.core.colony.jobs.AbstractJobCrafter;
import com.minecolonies.core.entity.ai.workers.AbstractEntityAIBasic;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
@@ -740,7 +741,7 @@ private IAIState fillUpFurnace()
{
return getState();
}
- worker.getCitizenItemHandler().hitBlockWithToolInHand(walkTo);
+ CitizenItemUtils.hitBlockWithToolInHand(worker, walkTo);
InventoryUtils.transferXInItemHandlerIntoSlotInItemHandler(
worker.getInventoryCitizen(),
smeltable,
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/EntityAIWorkAlchemist.java b/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/EntityAIWorkAlchemist.java
index 54f53f07bf6..b1c20691774 100644
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/EntityAIWorkAlchemist.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/EntityAIWorkAlchemist.java
@@ -19,6 +19,7 @@
import com.minecolonies.core.colony.buildings.workerbuildings.BuildingAlchemist;
import com.minecolonies.core.colony.interactionhandling.StandardInteraction;
import com.minecolonies.core.colony.jobs.JobAlchemist;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.core.network.messages.client.BlockParticleEffectMessage;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
@@ -247,7 +248,7 @@ private IAIState harvestMistleToe()
final int slot =
InventoryUtils.getFirstSlotOfItemHandlerContainingEquipment(worker.getInventoryCitizen(), ModEquipmentTypes.shears.get(), TOOL_LEVEL_WOOD_OR_GOLD, building.getMaxEquipmentLevel());
- worker.getCitizenItemHandler().setHeldItem(InteractionHand.MAIN_HAND, slot);
+ CitizenItemUtils.setHeldItem(worker, InteractionHand.MAIN_HAND, slot);
worker.swing(InteractionHand.MAIN_HAND);
world.playSound(null,
@@ -262,7 +263,7 @@ private IAIState harvestMistleToe()
worker.decreaseSaturationForContinuousAction();
InventoryUtils.addItemStackToItemHandler(worker.getInventoryCitizen(), new ItemStack(ModItems.mistletoe, 1));
walkTo = null;
- worker.getCitizenItemHandler().damageItemInHand(InteractionHand.MAIN_HAND, 1);
+ CitizenItemUtils.damageItemInHand(worker, InteractionHand.MAIN_HAND, 1);
return INVENTORY_FULL;
}
}
@@ -929,7 +930,7 @@ private IAIState fillUpBrewingStand()
{
return getState();
}
- worker.getCitizenItemHandler().hitBlockWithToolInHand(walkTo);
+ CitizenItemUtils.hitBlockWithToolInHand(worker, walkTo);
InventoryUtils.transferXInItemHandlerIntoSlotInItemHandler(
worker.getInventoryCitizen(),
potion,
@@ -988,7 +989,7 @@ else if (isEmpty(((BrewingStandBlockEntity) entity).getItem(INGREDIENT_SLOT)))
{
return getState();
}
- worker.getCitizenItemHandler().hitBlockWithToolInHand(walkTo);
+ CitizenItemUtils.hitBlockWithToolInHand(worker, walkTo);
InventoryUtils.transferXInItemHandlerIntoSlotInItemHandler(
worker.getInventoryCitizen(),
ingredient,
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/EntityAIWorkCrusher.java b/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/EntityAIWorkCrusher.java
index 9594a0d0944..cc8ef9364a9 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/EntityAIWorkCrusher.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/crafting/EntityAIWorkCrusher.java
@@ -6,7 +6,7 @@
import com.minecolonies.api.entity.ai.statemachine.AITarget;
import com.minecolonies.api.entity.ai.statemachine.states.IAIState;
import com.minecolonies.api.entity.citizen.VisibleCitizenStatus;
-import com.minecolonies.core.entity.pathfinding.navigation.AbstractAdvancedPathNavigate;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.api.util.SoundUtils;
import com.minecolonies.api.util.constant.Constants;
import com.minecolonies.core.colony.buildings.workerbuildings.BuildingCrusher;
@@ -218,7 +218,7 @@ protected IAIState craft()
worker.setItemInHand(InteractionHand.MAIN_HAND,
currentRecipeStorage.getCleanedInput().get(worker.getRandom().nextInt(currentRecipeStorage.getCleanedInput().size())).getItemStack().copy());
worker.setItemInHand(InteractionHand.OFF_HAND, currentRecipeStorage.getPrimaryOutput().copy());
- worker.getCitizenItemHandler().hitBlockWithToolInHand(building.getPosition());
+ CitizenItemUtils.hitBlockWithToolInHand(worker, building.getPosition());
currentRequest = job.getCurrentTask();
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/guard/AbstractEntityAIFight.java b/src/main/java/com/minecolonies/core/entity/ai/workers/guard/AbstractEntityAIFight.java
index 8f66ef18067..44438aa6b84 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/guard/AbstractEntityAIFight.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/guard/AbstractEntityAIFight.java
@@ -12,6 +12,7 @@
import com.minecolonies.core.colony.buildings.AbstractBuildingGuards;
import com.minecolonies.core.colony.jobs.AbstractJobGuard;
import com.minecolonies.core.entity.ai.workers.AbstractEntityAIInteract;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ArmorItem;
@@ -125,7 +126,7 @@ private IAIState prepare()
stack -> !ItemStackUtils.isEmpty(stack)
&& ItemStackUtils.doesItemServeAsWeapon(stack)
&& ItemStackUtils.hasEquipmentLevel(stack, tool, 0, building.getMaxEquipmentLevel()),
- itemStack -> worker.getCitizenItemHandler().setMainHeldItem(itemStack));
+ itemStack -> CitizenItemUtils.setMainHeldItem(worker, itemStack));
}
equipInventoryArmor();
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/guard/KnightCombatAI.java b/src/main/java/com/minecolonies/core/entity/ai/workers/guard/KnightCombatAI.java
index 02e1357ebc1..4efb9fea24d 100644
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/guard/KnightCombatAI.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/guard/KnightCombatAI.java
@@ -11,6 +11,7 @@
import com.minecolonies.api.equipment.ModEquipmentTypes;
import com.minecolonies.api.util.*;
import com.minecolonies.api.util.constant.ColonyConstants;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.core.entity.pathfinding.pathresults.PathResult;
import com.minecolonies.api.util.constant.Constants;
import com.minecolonies.core.MineColonies;
@@ -108,7 +109,7 @@ protected IAIState attackProtect()
if (shieldSlot != -1 && target != null && target.isAlive() && nextAttackTime - user.level().getGameTime() >= MIN_TIME_TO_ATTACK &&
user.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(SHIELD_USAGE) > 0)
{
- user.getCitizenItemHandler().setHeldItem(InteractionHand.OFF_HAND, shieldSlot);
+ CitizenItemUtils.setHeldItem(user, InteractionHand.OFF_HAND, shieldSlot);
user.startUsingItem(InteractionHand.OFF_HAND);
// Apply the colony Flag to the shield
@@ -133,7 +134,7 @@ public boolean canAttack()
if (weaponSlot != -1)
{
- user.getCitizenItemHandler().setHeldItem(InteractionHand.MAIN_HAND, weaponSlot);
+ CitizenItemUtils.setHeldItem(user, InteractionHand.MAIN_HAND, weaponSlot);
return true;
}
@@ -184,7 +185,7 @@ protected void doAttack(final LivingEntity target)
user.stopUsingItem();
user.decreaseSaturationForContinuousAction();
user.getCitizenData().setVisibleStatus(KNIGHT_COMBAT);
- user.getCitizenItemHandler().damageItemInHand(InteractionHand.MAIN_HAND, 1);
+ CitizenItemUtils.damageItemInHand(user, InteractionHand.MAIN_HAND, 1);
}
/**
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/guard/RangerCombatAI.java b/src/main/java/com/minecolonies/core/entity/ai/workers/guard/RangerCombatAI.java
index c0ccc72991b..f6e5b146480 100644
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/guard/RangerCombatAI.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/guard/RangerCombatAI.java
@@ -6,6 +6,7 @@
import com.minecolonies.api.equipment.ModEquipmentTypes;
import com.minecolonies.api.util.*;
import com.minecolonies.api.util.constant.ColonyConstants;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.core.entity.pathfinding.PathfindingUtils;
import com.minecolonies.core.entity.pathfinding.pathresults.PathResult;
import com.minecolonies.core.entity.pathfinding.PathingOptions;
@@ -18,11 +19,8 @@
import com.minecolonies.core.entity.ai.combat.CombatUtils;
import com.minecolonies.core.entity.citizen.EntityCitizen;
import com.minecolonies.core.entity.other.CustomArrowEntity;
-import com.minecolonies.core.entity.pathfinding.PathfindingUtils;
-import com.minecolonies.core.entity.pathfinding.PathingOptions;
import com.minecolonies.core.entity.pathfinding.navigation.MinecoloniesAdvancedPathNavigate;
import com.minecolonies.core.entity.pathfinding.pathjobs.*;
-import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
@@ -35,7 +33,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
-import net.neoforged.neoforge.registries.DeferredRegister;
import static com.minecolonies.api.research.util.ResearchConstants.*;
import static com.minecolonies.api.util.constant.GuardConstants.*;
@@ -111,7 +108,7 @@ public boolean canAttack()
if (weaponSlot != -1)
{
- user.getCitizenItemHandler().setHeldItem(InteractionHand.MAIN_HAND, weaponSlot);
+ CitizenItemUtils.setHeldItem(user, InteractionHand.MAIN_HAND, weaponSlot);
if (nextAttackTime - BOW_HOLDING_DELAY >= user.level().getGameTime() && !user.isUsingItem())
{
user.startUsingItem(InteractionHand.MAIN_HAND);
@@ -190,7 +187,7 @@ protected void doAttack(final LivingEntity target)
}
target.setLastHurtByMob(user);
- user.getCitizenItemHandler().damageItemInHand(InteractionHand.MAIN_HAND, 1);
+ CitizenItemUtils.damageItemInHand(user, InteractionHand.MAIN_HAND, 1);
user.stopUsingItem();
user.decreaseSaturationForContinuousAction();
}
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/guard/training/EntityAIArcherTraining.java b/src/main/java/com/minecolonies/core/entity/ai/workers/guard/training/EntityAIArcherTraining.java
index 4053dd26eff..d3eebf27b7e 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/guard/training/EntityAIArcherTraining.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/guard/training/EntityAIArcherTraining.java
@@ -11,6 +11,7 @@
import com.minecolonies.api.util.constant.Constants;
import com.minecolonies.core.colony.buildings.workerbuildings.BuildingArchery;
import com.minecolonies.core.colony.jobs.JobArcherTraining;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.core.util.WorkerUtil;
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.projectile.Arrow;
@@ -187,7 +188,7 @@ protected IAIState shoot()
if (worker.getRandom().nextBoolean())
{
- worker.getCitizenItemHandler().damageItemInHand(InteractionHand.MAIN_HAND, 1);
+ CitizenItemUtils.damageItemInHand(worker, InteractionHand.MAIN_HAND, 1);
}
worker.stopUsingItem();
this.incrementActionsDoneAndDecSaturation();
@@ -232,7 +233,7 @@ protected boolean isSetup()
}
final int bowSlot = InventoryUtils.getFirstSlotOfItemHandlerContainingEquipment(getInventory(), ModEquipmentTypes.bow.get(), 0, building.getMaxEquipmentLevel());
- worker.getCitizenItemHandler().setHeldItem(InteractionHand.MAIN_HAND, bowSlot);
+ CitizenItemUtils.setHeldItem(worker, InteractionHand.MAIN_HAND, bowSlot);
return true;
}
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/guard/training/EntityAICombatTraining.java b/src/main/java/com/minecolonies/core/entity/ai/workers/guard/training/EntityAICombatTraining.java
index b93382dee90..4e98efbe600 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/guard/training/EntityAICombatTraining.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/guard/training/EntityAICombatTraining.java
@@ -10,6 +10,7 @@
import com.minecolonies.api.util.SoundUtils;
import com.minecolonies.core.colony.buildings.workerbuildings.BuildingCombatAcademy;
import com.minecolonies.core.colony.jobs.JobCombatTraining;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.core.util.WorkerUtil;
import net.minecraft.world.item.Items;
import net.minecraft.world.InteractionHand;
@@ -185,7 +186,7 @@ private IAIState attack()
if (shieldSlot != -1)
{
worker.playSound(SoundEvents.SHIELD_BLOCK, (float) BASIC_VOLUME, (float) SoundUtils.getRandomPitch(worker.getRandom()));
- worker.getCitizenItemHandler().setHeldItem(InteractionHand.OFF_HAND, shieldSlot);
+ CitizenItemUtils.setHeldItem(worker, InteractionHand.OFF_HAND, shieldSlot);
worker.startUsingItem(InteractionHand.OFF_HAND);
worker.getLookControl().setLookAt(trainingPartner, (float) TURN_AROUND, (float) TURN_AROUND);
}
@@ -195,7 +196,7 @@ private IAIState attack()
worker.swing(InteractionHand.MAIN_HAND);
worker.playSound(SoundEvents.PLAYER_ATTACK_SWEEP, (float) BASIC_VOLUME, (float) SoundUtils.getRandomPitch(worker.getRandom()));
trainingPartner.hurt(world.damageSources().source(DamageSourceKeys.TRAINING, worker), 0.0F);
- worker.getCitizenItemHandler().damageItemInHand(InteractionHand.MAIN_HAND, 1);
+ CitizenItemUtils.damageItemInHand(worker, InteractionHand.MAIN_HAND, 1);
}
worker.getNavigation().moveAwayFromXYZ(trainingPartner.blockPosition(), 4.0, 1.0, true);
targetCounter++;
@@ -278,7 +279,7 @@ private IAIState attackDummy()
if (shieldSlot != -1)
{
worker.playSound(SoundEvents.SHIELD_BLOCK, (float) BASIC_VOLUME, (float) SoundUtils.getRandomPitch(worker.getRandom()));
- worker.getCitizenItemHandler().setHeldItem(InteractionHand.OFF_HAND, shieldSlot);
+ CitizenItemUtils.setHeldItem(worker, InteractionHand.OFF_HAND, shieldSlot);
worker.startUsingItem(InteractionHand.OFF_HAND);
}
}
@@ -286,7 +287,7 @@ private IAIState attackDummy()
{
worker.swing(InteractionHand.MAIN_HAND);
worker.playSound(SoundEvents.PLAYER_ATTACK_SWEEP, (float) BASIC_VOLUME, (float) SoundUtils.getRandomPitch(worker.getRandom()));
- worker.getCitizenItemHandler().damageItemInHand(InteractionHand.MAIN_HAND, 1);
+ CitizenItemUtils.damageItemInHand(worker, InteractionHand.MAIN_HAND, 1);
}
currentAttackDelay = RANGED_ATTACK_DELAY_BASE;
@@ -316,7 +317,7 @@ protected boolean isSetup()
final int weaponSlot = InventoryUtils.getFirstSlotOfItemHandlerContainingEquipment(getInventory(), ModEquipmentTypes.sword.get(), 0, building.getMaxEquipmentLevel());
if (weaponSlot != -1)
{
- worker.getCitizenItemHandler().setHeldItem(InteractionHand.MAIN_HAND, weaponSlot);
+ CitizenItemUtils.setHeldItem(worker, InteractionHand.MAIN_HAND, weaponSlot);
}
return true;
}
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/production/EntityAIWorkLumberjack.java b/src/main/java/com/minecolonies/core/entity/ai/workers/production/EntityAIWorkLumberjack.java
index 1fa0bf9ddf1..038afe821a7 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/production/EntityAIWorkLumberjack.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/production/EntityAIWorkLumberjack.java
@@ -17,6 +17,7 @@
import com.minecolonies.core.colony.jobs.JobLumberjack;
import com.minecolonies.core.entity.ai.workers.crafting.AbstractEntityAICrafting;
import com.minecolonies.core.entity.ai.workers.util.Tree;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.core.entity.pathfinding.PathfindingUtils;
import com.minecolonies.core.entity.pathfinding.navigation.MinecoloniesAdvancedPathNavigate;
import com.minecolonies.core.entity.pathfinding.pathjobs.PathJobMoveToWithPassable;
@@ -39,7 +40,6 @@
import net.minecraft.world.level.pathfinder.Node;
import net.minecraft.world.level.pathfinder.Path;
import net.minecraft.world.phys.AABB;
-import net.neoforged.neoforge.common.SpecialPlantable;
import net.neoforged.neoforge.common.Tags;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -823,7 +823,7 @@ private boolean plantSapling(@NotNull final BlockPos location)
if (saplingSlot != -1)
{
final ItemStack stack = getInventory().getStackInSlot(saplingSlot);
- worker.getCitizenItemHandler().setHeldItem(InteractionHand.MAIN_HAND, saplingSlot);
+ CitizenItemUtils.setHeldItem(worker, InteractionHand.MAIN_HAND, saplingSlot);
if (job.getTree().isDynamicTree() && Compatibility.isDynamicTreeSapling(stack))
{
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/production/EntityAIWorkNether.java b/src/main/java/com/minecolonies/core/entity/ai/workers/production/EntityAIWorkNether.java
index 797708473af..c9409b2b50b 100644
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/production/EntityAIWorkNether.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/production/EntityAIWorkNether.java
@@ -23,6 +23,7 @@
import com.minecolonies.core.colony.buildings.workerbuildings.BuildingNetherWorker;
import com.minecolonies.core.colony.jobs.JobNetherWorker;
import com.minecolonies.core.entity.ai.workers.crafting.AbstractEntityAICrafting;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.core.items.ItemAdventureToken;
import com.minecolonies.core.util.TeleportHelper;
import net.minecraft.core.BlockPos;
@@ -60,8 +61,6 @@
import static com.minecolonies.api.util.constant.CitizenConstants.*;
import static com.minecolonies.api.util.constant.EquipmentLevelConstants.*;
import static com.minecolonies.api.util.constant.GuardConstants.*;
-import static com.minecolonies.api.util.constant.NbtTagConstants.*;
-import static com.minecolonies.core.colony.buildings.modules.BuildingModules.NETHERMINER_MENU;
import static com.minecolonies.core.colony.buildings.modules.BuildingModules.NETHERMINER_MENU;
import static com.minecolonies.core.entity.ai.workers.production.EntityAIStructureMiner.*;
@@ -551,7 +550,7 @@ protected IAIState stayInNether()
equipArmor(false);
}
- worker.getCitizenExperienceHandler().addExperience(worker.getCitizenItemHandler().applyMending(component.xp()));
+ worker.getCitizenExperienceHandler().addExperience(CitizenItemUtils.applyMending(worker, component.xp()));
}
}
else if (!currStack.isEmpty())
@@ -582,7 +581,7 @@ else if (!currStack.isEmpty())
tool = findTool(block.defaultBlockState(), worker.blockPosition());
worker.setItemSlot(EquipmentSlot.MAINHAND, tool);
}
- worker.getCitizenExperienceHandler().addExperience(worker.getCitizenItemHandler().applyMending(xpOnDrop(block)));
+ worker.getCitizenExperienceHandler().addExperience(CitizenItemUtils.applyMending(worker, xpOnDrop(block)));
itemDelay += TICK_DELAY;
}
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkBeekeeper.java b/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkBeekeeper.java
index 42e9d2e5f0d..bb8acd292de 100644
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkBeekeeper.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkBeekeeper.java
@@ -16,6 +16,7 @@
import com.minecolonies.core.colony.interactionhandling.StandardInteraction;
import com.minecolonies.core.colony.jobs.JobBeekeeper;
import com.minecolonies.core.entity.ai.workers.AbstractEntityAIInteract;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.tags.BlockTags;
@@ -357,7 +358,7 @@ private IAIState harvestHoney()
final ItemStack itemStack = worker.getMainHandItem();
if (!building.getHarvestTypes().equals(BuildingBeekeeper.HONEY) && ModEquipmentTypes.shears.get().checkIsEquipment(itemStack))
{
- worker.getCitizenItemHandler().damageItemInHand(InteractionHand.MAIN_HAND, 1);
+ CitizenItemUtils.damageItemInHand(worker, InteractionHand.MAIN_HAND, 1);
for (ItemStack stackItem : Compatibility.getCombsFromHive(hive, world, getHoneycombsPerHarvest()))
{
@@ -492,7 +493,7 @@ public boolean equipTool(final InteractionHand hand, final EquipmentTypeEntry to
{
if (getToolSlot(toolType) != -1)
{
- worker.getCitizenItemHandler().setHeldItem(hand, getToolSlot(toolType));
+ CitizenItemUtils.setHeldItem(worker, hand, getToolSlot(toolType));
return true;
}
return false;
@@ -527,7 +528,7 @@ public boolean equipItem(final InteractionHand hand, final ItemStack itemStack)
{
if (checkIfRequestForItemExistOrCreateAsync(itemStack))
{
- worker.getCitizenItemHandler().setHeldItem(hand, getItemSlot(itemStack.getItem()));
+ CitizenItemUtils.setHeldItem(worker, hand, getItemSlot(itemStack.getItem()));
return true;
}
return false;
@@ -544,8 +545,8 @@ public boolean equipBreedItem(final InteractionHand hand)
if (checkIfRequestForTagExistOrCreateAsync(ItemTags.FLOWERS, NUM_OF_FLOWERS_TO_BREED))
{
ItemListModule flowersModule = building.getModuleMatching(ItemListModule.class, m -> m.getId().equals(BUILDING_FLOWER_LIST));
- worker.getCitizenItemHandler()
- .setHeldItem(hand, InventoryUtils.findFirstSlotInItemHandlerWith(getInventory(), stack -> flowersModule.isItemInList(new ItemStorage(stack))));
+ CitizenItemUtils
+ .setHeldItem(worker, hand, InventoryUtils.findFirstSlotInItemHandlerWith(getInventory(), stack -> flowersModule.isItemInList(new ItemStorage(stack))));
return true;
}
return false;
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkComposter.java b/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkComposter.java
index b1f0554c3ec..a682e335406 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkComposter.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkComposter.java
@@ -17,6 +17,7 @@
import com.minecolonies.core.colony.buildings.workerbuildings.BuildingComposter;
import com.minecolonies.core.colony.jobs.JobComposter;
import com.minecolonies.core.entity.ai.workers.AbstractEntityAIInteract;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.core.tileentities.TileEntityBarrel;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
@@ -274,7 +275,7 @@ private IAIState fillBarrels()
final TileEntityBarrel barrel = (TileEntityBarrel) world.getBlockEntity(currentTarget);
- worker.getCitizenItemHandler().hitBlockWithToolInHand(currentTarget);
+ CitizenItemUtils.hitBlockWithToolInHand(worker, currentTarget);
barrel.addItem(worker.getItemInHand(InteractionHand.MAIN_HAND));
worker.getCitizenExperienceHandler().addExperience(BASE_XP_GAIN);
this.incrementActionsDoneAndDecSaturation();
@@ -302,7 +303,7 @@ private IAIState harvestBarrels()
if (world.getBlockEntity(currentTarget) instanceof TileEntityBarrel)
{
- worker.getCitizenItemHandler().hitBlockWithToolInHand(currentTarget);
+ CitizenItemUtils.hitBlockWithToolInHand(worker, currentTarget);
final TileEntityBarrel te = (TileEntityBarrel) world.getBlockEntity(currentTarget);
final ItemStack compost = te.retrieveCompost(getLootMultiplier(worker.getRandom()));
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkFarmer.java b/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkFarmer.java
index 113e59d4e7e..8d697967c2f 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkFarmer.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkFarmer.java
@@ -28,6 +28,7 @@
import com.minecolonies.core.colony.interactionhandling.StandardInteraction;
import com.minecolonies.core.colony.jobs.JobFarmer;
import com.minecolonies.core.entity.ai.workers.crafting.AbstractEntityAICrafting;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.core.items.ItemCrop;
import com.minecolonies.core.network.messages.client.CompostParticleMessage;
import com.minecolonies.core.util.AdvancementUtils;
@@ -51,7 +52,6 @@
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.common.ItemAbilities;
-import net.neoforged.neoforge.network.PacketDistributor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -588,7 +588,7 @@ private boolean hoeIfAble(BlockPos position, final FarmField farmField)
equipHoe();
worker.swing(worker.getUsedItemHand());
createCorrectFarmlandForSeed(farmField.getSeed(), position);
- worker.getCitizenItemHandler().damageItemInHand(InteractionHand.MAIN_HAND, 1);
+ CitizenItemUtils.damageItemInHand(worker, InteractionHand.MAIN_HAND, 1);
worker.decreaseSaturationForContinuousAction();
worker.getCitizenColonyHandler().getColonyOrRegister().getStatisticsManager().increment(LAND_TILLED, worker.getCitizenColonyHandler().getColonyOrRegister().getDay());
@@ -700,7 +700,7 @@ private boolean tryToPlant(final FarmField farmField, BlockPos position)
*/
private void equipHoe()
{
- worker.getCitizenItemHandler().setHeldItem(InteractionHand.MAIN_HAND, getHoeSlot());
+ CitizenItemUtils.setHeldItem(worker, InteractionHand.MAIN_HAND, getHoeSlot());
}
/**
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkFisherman.java b/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkFisherman.java
index 108e429c63d..3214079b48e 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkFisherman.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkFisherman.java
@@ -14,7 +14,7 @@
import com.minecolonies.core.colony.interactionhandling.StandardInteraction;
import com.minecolonies.core.colony.jobs.JobFisherman;
import com.minecolonies.core.entity.ai.workers.AbstractEntityAISkill;
-import com.minecolonies.core.entity.citizen.EntityCitizen;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import com.minecolonies.core.entity.other.NewBobberEntity;
import com.minecolonies.core.entity.pathfinding.Pathfinding;
import com.minecolonies.core.entity.pathfinding.PathfindingUtils;
@@ -28,7 +28,6 @@
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.InteractionHand;
-import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.ExperienceOrb;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
@@ -607,7 +606,7 @@ private IAIState isReadyToFish()
*/
private void equipRod()
{
- worker.getCitizenItemHandler().setHeldItem(InteractionHand.MAIN_HAND, getRodSlot());
+ CitizenItemUtils.setHeldItem(worker, InteractionHand.MAIN_HAND, getRodSlot());
}
/**
@@ -658,7 +657,7 @@ private void retrieveRod()
worker.swing(worker.getUsedItemHand());
final int i = entityFishHook.retrieve(worker.getMainHandItem());
generateBonusLoot();
- worker.getCitizenItemHandler().damageItemInHand(InteractionHand.MAIN_HAND, i);
+ CitizenItemUtils.damageItemInHand(worker, InteractionHand.MAIN_HAND, i);
entityFishHook = null;
}
}
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkPlanter.java b/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkPlanter.java
index 1f8aa545506..ca15bff21b8 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkPlanter.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/production/agriculture/EntityAIWorkPlanter.java
@@ -23,6 +23,7 @@
import com.minecolonies.core.colony.interactionhandling.StandardInteraction;
import com.minecolonies.core.colony.jobs.JobPlanter;
import com.minecolonies.core.entity.ai.workers.crafting.AbstractEntityAICrafting;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
@@ -223,7 +224,7 @@ private IAIState workField()
if (handlerResult.equals(ActionHandlerResult.FINISHED))
{
- worker.getCitizenItemHandler().removeHeldItem();
+ CitizenItemUtils.removeHeldItem(worker);
if (activeModuleResult.getAction().increasesActionCount())
{
@@ -311,13 +312,13 @@ private ActionHandlerResult handlePlantingAction()
}
final int slot = InventoryUtils.findFirstSlotInItemHandlerWith(worker.getItemHandlerCitizen(), currentStack.getItem());
- worker.getCitizenItemHandler().setMainHeldItem(slot);
+ CitizenItemUtils.setMainHeldItem(worker, slot);
BlockState blockState = planterModule.getPlantingBlockState(world, activeModuleResult.getWorkingPosition(), BlockUtils.getBlockStateFromStack(currentStack));
if (world.setBlockAndUpdate(activeModuleResult.getActionPosition(), blockState))
{
InventoryUtils.reduceStackInItemHandler(worker.getItemHandlerCitizen(), currentStack);
- worker.getCitizenItemHandler().removeHeldItem();
+ CitizenItemUtils.removeHeldItem(worker);
return ActionHandlerResult.FINISHED;
}
@@ -371,7 +372,7 @@ private ActionHandlerResult handleMiningAction(boolean isHarvest)
boolean mineResult = mineBlock(activeModuleResult.getActionPosition());
if (mineResult)
{
- worker.getCitizenItemHandler().pickupItems();
+ CitizenItemUtils.pickupItems(worker);
if (isHarvest)
{
diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/production/herders/AbstractEntityAIHerder.java b/src/main/java/com/minecolonies/core/entity/ai/workers/production/herders/AbstractEntityAIHerder.java
index 45cca44b1e3..666fb9303f9 100755
--- a/src/main/java/com/minecolonies/core/entity/ai/workers/production/herders/AbstractEntityAIHerder.java
+++ b/src/main/java/com/minecolonies/core/entity/ai/workers/production/herders/AbstractEntityAIHerder.java
@@ -13,6 +13,7 @@
import com.minecolonies.core.colony.buildings.modules.AnimalHerdingModule;
import com.minecolonies.core.colony.jobs.AbstractJob;
import com.minecolonies.core.entity.ai.workers.AbstractEntityAIInteract;
+import com.minecolonies.core.util.citizenutils.CitizenItemUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.InteractionHand;
@@ -410,7 +411,7 @@ protected IAIState breedAnimals()
{
if (current_module == null)
{
- worker.getCitizenItemHandler().removeHeldItem();
+ CitizenItemUtils.removeHeldItem(worker);
return DECIDE;
}
@@ -424,7 +425,7 @@ protected IAIState breedAnimals()
if (breedables.size() < 2)
{
- worker.getCitizenItemHandler().removeHeldItem();
+ CitizenItemUtils.removeHeldItem(worker);
breedTimeOut = TICKS_SECOND * 60;
return DECIDE;
}
@@ -448,14 +449,14 @@ protected IAIState breedAnimals()
if (animalTwo == null)
{
- worker.getCitizenItemHandler().removeHeldItem();
+ CitizenItemUtils.removeHeldItem(worker);
breedTimeOut = TICKS_SECOND * 20;
return DECIDE;
}
if (!equipItem(InteractionHand.MAIN_HAND, current_module.getBreedingItems()))
{
- worker.getCitizenItemHandler().removeHeldItem();
+ CitizenItemUtils.removeHeldItem(worker);
return START_WORKING;
}
@@ -469,7 +470,7 @@ protected IAIState breedAnimals()
}
breedTimeOut = TICKS_SECOND * 60;
- worker.getCitizenItemHandler().removeHeldItem();
+ CitizenItemUtils.removeHeldItem(worker);
return IDLE;
}
@@ -547,7 +548,7 @@ protected IAIState feedAnimal()
worker.getCitizenExperienceHandler().addExperience(XP_PER_ACTION);
worker.level().broadcastEntityEvent(toFeed, (byte) 18);
toFeed.playSound(SoundEvents.GENERIC_EAT, 1.0F, 1.0F);
- worker.getCitizenItemHandler().removeHeldItem();
+ CitizenItemUtils.removeHeldItem(worker);
fedRecently.put(toFeed.getUUID(), worker.level().getGameTime());
return DECIDE;
@@ -694,7 +695,7 @@ public boolean equipTool(final InteractionHand hand, final EquipmentTypeEntry to
{
if (getToolSlot(toolType) != -1)
{
- worker.getCitizenItemHandler().setHeldItem(hand, getToolSlot(toolType));
+ CitizenItemUtils.setHeldItem(worker, hand, getToolSlot(toolType));
return true;
}
return false;
@@ -731,7 +732,7 @@ public boolean equipItem(final InteractionHand hand, final List