From b03ab446bc4be21b2f002a1e7a89bf5410d6847f Mon Sep 17 00:00:00 2001 From: jshipley Date: Sat, 28 Mar 2026 14:30:50 -0600 Subject: [PATCH 1/2] Use tool for loot to enable silk touch / fortune --- .../item/tools/harvesting/ChainsawItem.java | 2 +- .../tools/harvesting/PromethiumAxeItem.java | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/rearth/oritech/item/tools/harvesting/ChainsawItem.java b/common/src/main/java/rearth/oritech/item/tools/harvesting/ChainsawItem.java index d4bce2db82..b7d77bb85a 100644 --- a/common/src/main/java/rearth/oritech/item/tools/harvesting/ChainsawItem.java +++ b/common/src/main/java/rearth/oritech/item/tools/harvesting/ChainsawItem.java @@ -78,7 +78,7 @@ public boolean mineBlock(ItemStack stack, Level world, BlockState state, BlockPo var startState = world.getBlockState(startPos); if (startState.is(BlockTags.LOGS)) { var treeBlocks = TreefellerBlockEntity.getTreeBlocks(startPos, world); - PromethiumAxeItem.pendingBlocks.addAll(treeBlocks.stream().map(elem -> new Tuple<>(world, elem)).toList()); + PromethiumAxeItem.pendingBlocks.addAll(treeBlocks.stream().map(elem -> new PromethiumAxeItem.PendingBlock(world, elem, stack)).toList()); var extraEnergyUsed = treeBlocks.size() * energyUsageMultiplier / 2; this.tryUseEnergy(stack, (long) extraEnergyUsed, player); diff --git a/common/src/main/java/rearth/oritech/item/tools/harvesting/PromethiumAxeItem.java b/common/src/main/java/rearth/oritech/item/tools/harvesting/PromethiumAxeItem.java index 462a606c11..38c5408c44 100644 --- a/common/src/main/java/rearth/oritech/item/tools/harvesting/PromethiumAxeItem.java +++ b/common/src/main/java/rearth/oritech/item/tools/harvesting/PromethiumAxeItem.java @@ -8,7 +8,6 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundSource; import net.minecraft.tags.BlockTags; -import net.minecraft.util.Tuple; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.AxeItem; @@ -39,7 +38,8 @@ public class PromethiumAxeItem extends AxeItem implements GeoItem { - public static final Deque> pendingBlocks = new ArrayDeque<>(); + public record PendingBlock(Level level, BlockPos pos, ItemStack tool) {}; + public static final Deque pendingBlocks = new ArrayDeque<>(); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); @@ -65,7 +65,7 @@ public boolean mineBlock(ItemStack stack, Level world, BlockState state, BlockPo var startState = world.getBlockState(startPos); if (startState.is(BlockTags.LOGS)) { var treeBlocks = TreefellerBlockEntity.getTreeBlocks(startPos, world); - pendingBlocks.addAll(treeBlocks.stream().map(elem -> new Tuple<>(world, elem)).toList()); + pendingBlocks.addAll(treeBlocks.stream().map(elem -> new PendingBlock(world, elem, stack)).toList()); } } @@ -75,23 +75,24 @@ public boolean mineBlock(ItemStack stack, Level world, BlockState state, BlockPo public static void processPendingBlocks(Level world) { if (pendingBlocks.isEmpty()) return; - var topWorld = pendingBlocks.getFirst().getA(); + var topWorld = pendingBlocks.getFirst().level(); if (topWorld != world) return; for (int i = 0; i < 8 && !pendingBlocks.isEmpty(); i++) { - var candidate = pendingBlocks.pollFirst().getB(); - var candidateState = world.getBlockState(candidate); + var candidate = pendingBlocks.pollFirst(); + var candidatePos = candidate.pos(); + var candidateState = world.getBlockState(candidatePos); if (!candidateState.is(BlockTags.LOGS) && !candidateState.is(BlockTags.LEAVES)) return; - var dropped = Block.getDrops(candidateState, (ServerLevel) world, candidate, null); - world.setBlockAndUpdate(candidate, Blocks.AIR.defaultBlockState()); + var dropped = Block.getDrops(candidateState, (ServerLevel) world, candidatePos, null, null, candidate.tool()); + world.setBlockAndUpdate(candidatePos, Blocks.AIR.defaultBlockState()); - dropped.forEach(elem -> world.addFreshEntity(new ItemEntity(world, candidate.getX(), candidate.getY(), candidate.getZ(), elem))); + dropped.forEach(elem -> world.addFreshEntity(new ItemEntity(world, candidatePos.getX(), candidatePos.getY(), candidatePos.getZ(), elem))); - world.playSound(null, candidate, candidateState.getSoundType().getBreakSound(), SoundSource.BLOCKS, 0.5f, 1f); - world.addDestroyBlockEffect(candidate, candidateState); + world.playSound(null, candidatePos, candidateState.getSoundType().getBreakSound(), SoundSource.BLOCKS, 0.5f, 1f); + world.addDestroyBlockEffect(candidatePos, candidateState); - ParticleContent.BLOCK_DESTROY_EFFECT.spawn(world, Vec3.atLowerCornerOf(candidate), 4); + ParticleContent.BLOCK_DESTROY_EFFECT.spawn(world, Vec3.atLowerCornerOf(candidatePos), 4); if (candidateState.is(BlockTags.LOGS)) break; } From d80c3e9b9f5fb704f85e449cca2117401c514635 Mon Sep 17 00:00:00 2001 From: jshipley Date: Tue, 31 Mar 2026 11:04:38 -0600 Subject: [PATCH 2/2] Fixed merge --- .../rearth/oritech/item/tools/harvesting/PromethiumAxeItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/rearth/oritech/item/tools/harvesting/PromethiumAxeItem.java b/common/src/main/java/rearth/oritech/item/tools/harvesting/PromethiumAxeItem.java index 161a4c3d83..8dbadf3ce6 100644 --- a/common/src/main/java/rearth/oritech/item/tools/harvesting/PromethiumAxeItem.java +++ b/common/src/main/java/rearth/oritech/item/tools/harvesting/PromethiumAxeItem.java @@ -92,7 +92,7 @@ public static void processPendingBlocks(Level world) { world.playSound(null, candidatePos, candidateState.getSoundType().getBreakSound(), SoundSource.BLOCKS, 0.5f, 1f); world.addDestroyBlockEffect(candidatePos, candidateState); - if (world instanceof ServerLevel sl) sl.sendParticles(ParticleTypes.SOUL_FIRE_FLAME, candidate.getX() + 0.5, candidate.getY() + 0.5, candidate.getZ() + 0.5, 4, 0.6, 0.6, 0.6, 0); + if (world instanceof ServerLevel sl) sl.sendParticles(ParticleTypes.SOUL_FIRE_FLAME, candidatePos.getX() + 0.5, candidatePos.getY() + 0.5, candidatePos.getZ() + 0.5, 4, 0.6, 0.6, 0.6, 0); if (candidateState.is(BlockTags.LOGS)) break; }