Fix drill speed on non-stone blocks. Closes #2225
This commit is contained in:
parent
a4bceb32a8
commit
3a159d7437
2 changed files with 20 additions and 12 deletions
|
@ -30,7 +30,6 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
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.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.*;
|
import net.minecraft.item.*;
|
||||||
import net.minecraft.tag.Tag;
|
import net.minecraft.tag.Tag;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
|
@ -69,10 +68,10 @@ public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabili
|
||||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||||
// Going to remain to use this ol reliable function, the fabric one is funky
|
// Going to remain to use this ol reliable function, the fabric one is funky
|
||||||
|
|
||||||
if(Energy.of(stack).getEnergy() >= cost ) {
|
if (Energy.of(stack).getEnergy() >= cost) {
|
||||||
if (stack.getItem().isEffectiveOn(state)) {
|
if (stack.getItem().isEffectiveOn(state)) {
|
||||||
return poweredSpeed;
|
return poweredSpeed;
|
||||||
}else{
|
} else {
|
||||||
return Math.min(unpoweredSpeed * 10f, poweredSpeed); // Still be faster than unpowered when not effective
|
return Math.min(unpoweredSpeed * 10f, poweredSpeed); // Still be faster than unpowered when not effective
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,6 +79,22 @@ public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabili
|
||||||
return unpoweredSpeed;
|
return unpoweredSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PickaxeItem
|
||||||
|
@Override
|
||||||
|
public boolean isEffectiveOn(BlockState blockIn) {
|
||||||
|
if (Items.DIAMOND_PICKAXE.isEffectiveOn(blockIn)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (Items.DIAMOND_SHOVEL.isEffectiveOn(blockIn)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// More checks to fix #2225
|
||||||
|
if (Items.DIAMOND_SHOVEL.getMiningSpeedMultiplier(null, blockIn) > 1.0f) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return Items.DIAMOND_PICKAXE.getMiningSpeedMultiplier(null, blockIn) > 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// MiningToolItem
|
// MiningToolItem
|
||||||
@Override
|
@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) {
|
||||||
|
@ -116,7 +131,7 @@ public class DrillItem extends PickaxeItem implements EnergyHolder, ItemDurabili
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
|
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
|
||||||
if (tag.equals(FabricToolTags.PICKAXES)) {
|
if (tag.equals(FabricToolTags.PICKAXES) || tag.equals(FabricToolTags.SHOVELS)) {
|
||||||
return miningLevel;
|
return miningLevel;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -33,7 +33,6 @@ import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.item.ToolMaterials;
|
import net.minecraft.item.ToolMaterials;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
|
@ -42,6 +41,7 @@ import net.minecraft.util.TypedActionResult;
|
||||||
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;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import team.reborn.energy.EnergyTier;
|
import team.reborn.energy.EnergyTier;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
|
@ -52,7 +52,6 @@ import techreborn.utils.InitUtils;
|
||||||
import techreborn.utils.MessageIDs;
|
import techreborn.utils.MessageIDs;
|
||||||
import techreborn.utils.ToolsUtil;
|
import techreborn.utils.ToolsUtil;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class IndustrialDrillItem extends DrillItem {
|
public class IndustrialDrillItem extends DrillItem {
|
||||||
|
@ -99,12 +98,6 @@ public class IndustrialDrillItem extends DrillItem {
|
||||||
return super.postMine(stack, worldIn, stateIn, pos, entityLiving);
|
return super.postMine(stack, worldIn, stateIn, pos, entityLiving);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PickaxeItem
|
|
||||||
@Override
|
|
||||||
public boolean isEffectiveOn(BlockState blockIn) {
|
|
||||||
return (Items.DIAMOND_PICKAXE.isEffectiveOn(blockIn) || Items.DIAMOND_SHOVEL.isEffectiveOn(blockIn)) && !Items.DIAMOND_AXE.isEffectiveOn(blockIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Item
|
// Item
|
||||||
@Override
|
@Override
|
||||||
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) {
|
public TypedActionResult<ItemStack> use(final World world, final PlayerEntity player, final Hand hand) {
|
||||||
|
|
Loading…
Reference in a new issue