Skip to content

Commit

Permalink
several small fixes (#10558)
Browse files Browse the repository at this point in the history
Fix exception with concrete mixer
Fix exception with colonist removal event
Fix issue with citizens not going to bed
Fix citizens constantly pathing to bed if there is none
  • Loading branch information
Raycoms authored Dec 27, 2024
1 parent 9130458 commit df19121
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ else if (homeBuilding.isInBuilding(citizen.blockPosition()))
*/
private boolean findBed()
{
if (!citizen.getCitizenSleepHandler().isAsleep() || bedTicks < MAX_BED_TICKS)
if (!citizen.getCitizenSleepHandler().isAsleep() && bedTicks < MAX_BED_TICKS)
{
findBedAndTryToSleep();
return false;
Expand Down Expand Up @@ -211,6 +211,10 @@ private void findBedAndTryToSleep()
}
citizen.getCitizenData().getCitizenHappinessHandler().resetModifier(SLEPTTONIGHT);
}
else
{
bedTicks = 0;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.ConcretePowderBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import org.jetbrains.annotations.NotNull;

import java.util.function.Predicate;
Expand Down Expand Up @@ -72,7 +71,7 @@ private IAIState placePowder()
final int slot = getSlotWithPowder();
if (slot == -1)
{
if (InventoryUtils.hasItemInItemHandler(building.getCapability(ForgeCapabilities.ITEM_HANDLER).orElseGet(null), CONCRETE))
if (InventoryUtils.getCountFromBuilding(building, CONCRETE) > 0)
{
needsCurrently = new Tuple<>(CONCRETE, STACKSIZE);
return GATHERING_REQUIRED_MATERIALS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,10 @@ public void die(@NotNull final DamageSource damageSource)
public void remove(final @NotNull RemovalReason reason)
{
super.remove(reason);
IMinecoloniesAPI.getInstance().getEventBus().post(new CitizenRemovedModEvent(citizenData, reason));
if (reason != RemovalReason.DISCARDED && citizenData != null)
{
IMinecoloniesAPI.getInstance().getEventBus().post(new CitizenRemovedModEvent(citizenData, reason));
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public static boolean walkCloseToXNearY(
// 1. Navigation Finished
// 2. Navigation is progressing towards a previous task
// 3. Navigation did not try once
boolean isOnRightTask = (nav.getPathResult() != null
&& PathJobMoveCloseToXNearY.isJobFor(nav.getPathResult().getJob(), desiredPosition, nearbyPosition, distToDesired));
boolean isOnRightTask = nav.getPathResult() != null && PathJobMoveCloseToXNearY.isJobFor(nav.getPathResult().getJob(), desiredPosition, nearbyPosition, 1);

if (nav.isDone() || !isOnRightTask)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static boolean isJobFor(final AbstractPathJob job, final BlockPos desired
{
if (job instanceof PathJobMoveCloseToXNearY pathJob)
{
return pathJob.nearbyPosition.equals(desiredPosition) && pathJob.nearbyPosition.equals(nearbyPosition) && pathJob.distToDesired == distance;
return pathJob.desiredPosition.equals(desiredPosition) && pathJob.nearbyPosition.equals(nearbyPosition) && pathJob.distToDesired == distance;
}

return false;
Expand Down

0 comments on commit df19121

Please sign in to comment.