Chainsaw breaks leaves faster. Closes #2860

This commit is contained in:
drcrazy 2022-08-18 17:58:07 +03:00
parent 2f1413dfba
commit b7e131870a
2 changed files with 15 additions and 10 deletions

View file

@ -44,7 +44,7 @@ import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent; import techreborn.init.TRContent;
import techreborn.utils.RecipeUtils; import techreborn.utils.RecipeUtils;
import javax.annotation.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Optional; import java.util.Optional;
public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity implements BuiltScreenHandlerProvider { public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity implements BuiltScreenHandlerProvider {

View file

@ -29,6 +29,7 @@ import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments; import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.item.*; import net.minecraft.item.*;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -58,6 +59,10 @@ public class ChainsawItem extends AxeItem implements RcEnergyItem {
this.referenceTool = referenceTool; this.referenceTool = referenceTool;
} }
public int getCost() {
return cost;
}
// AxeItem // AxeItem
@Override @Override
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
@ -69,6 +74,15 @@ public class ChainsawItem extends AxeItem implements RcEnergyItem {
// MiningToolItem // MiningToolItem
@Override @Override
public boolean isSuitableFor(BlockState state) {
// Fix for #2860
if (state.isIn(BlockTags.LEAVES)){
return true;
}
return referenceTool.isSuitableFor(state);
}
@Override
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) { public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
if (worldIn.getRandom().nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) { if (worldIn.getRandom().nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
tryUseEnergy(stack, cost); tryUseEnergy(stack, cost);
@ -106,11 +120,6 @@ public class ChainsawItem extends AxeItem implements RcEnergyItem {
InitUtils.initPoweredItems(this, stacks); InitUtils.initPoweredItems(this, stacks);
} }
@Override
public boolean isSuitableFor(BlockState state) {
return referenceTool.isSuitableFor(state);
}
@Override @Override
public int getItemBarStep(ItemStack stack) { public int getItemBarStep(ItemStack stack) {
return ItemUtils.getPowerForDurabilityBar(stack); return ItemUtils.getPowerForDurabilityBar(stack);
@ -141,8 +150,4 @@ public class ChainsawItem extends AxeItem implements RcEnergyItem {
public long getEnergyMaxOutput() { public long getEnergyMaxOutput() {
return 0; return 0;
} }
public int getCost() {
return cost;
}
} }