Skip to content

Commit

Permalink
fixed tools not properly checking isCorrectToolForDrops
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Dec 12, 2023
1 parent 4e6c358 commit ade52a8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.HitResult;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -155,7 +154,7 @@ default Tier getTier(ItemStack stack) {
return tier.orElseGet(() -> resolveTierTag(dataTag));
}

default boolean isCorrectToolForDrops(ItemStack stack, BlockState state) {
default boolean genericIsCorrectToolForDrops(ItemStack stack, BlockState state) {
AntimatterToolType type = this.getAntimatterToolType();
if (type.getEffectiveMaterials().contains(state.getMaterial())) {
return true;
Expand Down
10 changes: 7 additions & 3 deletions common/src/main/java/muramasa/antimatter/tool/MaterialSword.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import muramasa.antimatter.capability.energy.ItemEnergyHandler;
import muramasa.antimatter.item.IContainerItem;
import muramasa.antimatter.material.Material;
import muramasa.antimatter.util.Utils;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
Expand All @@ -31,7 +30,6 @@
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -157,7 +155,7 @@ public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity atta

@Override
public float getDestroySpeed(ItemStack stack, BlockState state) {
float destroySpeed = isCorrectToolForDrops(stack, state) ? getDefaultMiningSpeed(stack) : 1.0F;
float destroySpeed = genericIsCorrectToolForDrops(stack, state) ? getDefaultMiningSpeed(stack) : 1.0F;
if (type.isPowered() && getCurrentEnergy(stack) == 0){
destroySpeed = 0.0f;
}
Expand All @@ -173,7 +171,13 @@ public float getDestroySpeed(ItemStack stack, BlockState state) {
return destroySpeed;
}

public boolean isSuitableFor(ItemStack stack, BlockState state) {
return this.genericIsCorrectToolForDrops(stack, state);
}

public boolean isCorrectToolForDrops(ItemStack stack, BlockState state){
return genericIsCorrectToolForDrops(stack, state);
}

@Override
public boolean mineBlock(ItemStack stack, Level world, BlockState state, BlockPos pos, LivingEntity entity) {
Expand Down
12 changes: 6 additions & 6 deletions common/src/main/java/muramasa/antimatter/tool/MaterialTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import muramasa.antimatter.AntimatterAPI;
import muramasa.antimatter.Ref;
import muramasa.antimatter.behaviour.IBehaviour;
import muramasa.antimatter.behaviour.IBlockDestroyed;
import muramasa.antimatter.behaviour.IDestroySpeed;
import muramasa.antimatter.capability.energy.ItemEnergyHandler;
import muramasa.antimatter.data.AntimatterDefaultTools;
Expand All @@ -22,7 +21,6 @@
import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
Expand All @@ -39,8 +37,6 @@
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.HitResult;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -138,7 +134,11 @@ public boolean doesSneakBypassUse(ItemStack stack, LevelReader world, BlockPos p

//fabric method
public boolean isSuitableFor(ItemStack stack, BlockState state) {
return this.isCorrectToolForDrops(stack, state);
return this.genericIsCorrectToolForDrops(stack, state);
}

public boolean isCorrectToolForDrops(ItemStack stack, BlockState state){
return genericIsCorrectToolForDrops(stack, state);
}

@Override
Expand Down Expand Up @@ -201,7 +201,7 @@ public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity atta

@Override
public float getDestroySpeed(ItemStack stack, BlockState state) {
float destroySpeed = isCorrectToolForDrops(stack, state) ? getDefaultMiningSpeed(stack) : 1.0F;
float destroySpeed = genericIsCorrectToolForDrops(stack, state) ? getDefaultMiningSpeed(stack) : 1.0F;
if (type.isPowered() && getCurrentEnergy(stack) == 0){
destroySpeed = 0.0f;
}
Expand Down

0 comments on commit ade52a8

Please sign in to comment.