Skip to content

Commit

Permalink
Fix snow blocks not being breakable by the breaker module
Browse files Browse the repository at this point in the history
Was wrongly checking tool type rather tool tier

Would also affect any block which requires a tool other than a pickaxe
  • Loading branch information
desht committed Aug 11, 2023
1 parent f71adb7 commit f794aa1
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/main/java/me/desht/modularrouters/util/BlockUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.ExperienceOrb;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.*;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
Expand All @@ -21,9 +18,9 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.TierSortingRegistry;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.level.BlockEvent;
Expand Down Expand Up @@ -163,7 +160,8 @@ public static BreakResult tryBreakBlock(ModularRouterBlockEntity router, Level w

FakePlayer fakePlayer = router.getFakePlayer();
fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, pickaxe);
if (ConfigHolder.common.module.breakerHarvestLevelLimit.get() && !ForgeHooks.isCorrectToolForDrops(state, fakePlayer)) {
Tier tier = pickaxe.getItem() instanceof TieredItem t ? t.getTier() : Tiers.STONE;
if (ConfigHolder.common.module.breakerHarvestLevelLimit.get() && !TierSortingRegistry.isCorrectTierForDrops(tier, state)) {
return BreakResult.NOT_BROKEN;
}

Expand Down Expand Up @@ -194,7 +192,6 @@ public static String getBlockName(Level w, BlockPos pos) {
return w == null ? "" : w.getBlockState(pos).getBlock().getDescriptionId();
}

@SuppressWarnings("ClassCanBeRecord")
public static class BreakResult {
static final BreakResult NOT_BROKEN = new BreakResult(false, Collections.emptyMap());

Expand Down

0 comments on commit f794aa1

Please sign in to comment.