Skip to content

Commit

Permalink
Softcoding
Browse files Browse the repository at this point in the history
- Fixed deployers not able to harvest honeycomb with modded shears #4570
- Safety check for schedule pointer exceeding the total count #7492
  • Loading branch information
simibubi committed Mar 5, 2025
1 parent b9a1a8d commit cef2b16
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;

import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.ToolActions;
import net.minecraftforge.common.extensions.IForgeBaseRailBlock;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock;
Expand Down Expand Up @@ -427,7 +427,7 @@ protected static InteractionResult safeOnBeehiveUse(BlockState state, Level worl
if (honeyLevel < 5)
return InteractionResult.PASS;

if (prevHeldItem.getItem() == Items.SHEARS) {
if (prevHeldItem.canPerformAction(ToolActions.SHEARS_HARVEST)) {
world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BEEHIVE_SHEAR,
SoundSource.NEUTRAL, 1.0F, 1.0F);
// <> BeehiveBlock#dropHoneycomb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,9 @@ public void tick(Level level) {
ticksInTransit++;
return;
}
if (currentEntry >= schedule.entries.size()) {
currentEntry = 0;
if (!schedule.cyclic) {
paused = true;
completed = true;
}

if (checkEndOfScheduleReached())
return;
}

if (cooldown-- > 0)
return;
if (state == State.IN_TRANSIT)
Expand All @@ -144,6 +138,18 @@ public void tick(Level level) {
}
}

private boolean checkEndOfScheduleReached() {
if (currentEntry < schedule.entries.size())
return false;

currentEntry = 0;
if (!schedule.cyclic) {
paused = true;
completed = true;
}
return true;
}

public void tickConditions(Level level) {
ScheduleEntry entry = schedule.entries.get(currentEntry);
List<List<ScheduleWaitCondition>> conditions = entry.conditions;
Expand Down Expand Up @@ -182,6 +188,9 @@ public void tickConditions(Level level) {
}

public DiscoveredPath startCurrentInstruction(Level level) {
if (checkEndOfScheduleReached())
return null;

ScheduleEntry entry = schedule.entries.get(currentEntry);
ScheduleInstruction instruction = entry.instruction;
return instruction.start(this, level);
Expand Down

0 comments on commit cef2b16

Please sign in to comment.