Hammers fix

This commit is contained in:
Aleksey 2020-10-19 09:33:42 +03:00
parent f80ed2d1e8
commit ad1c9d7d7a
4 changed files with 28 additions and 7 deletions

View file

@ -58,7 +58,6 @@ public class BetterEnd implements ModInitializer {
return new Identifier(MOD_ID, path);
}
// For what does this exists? //
public static String getStringId(String id) {
return String.format("%s:%s", MOD_ID, id);
}

View file

@ -1,6 +1,7 @@
package ru.betterend.item;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.AxeItem;
@ -17,6 +18,9 @@ public class EndAxe extends AxeItem implements DynamicAttributeTool {
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(FabricToolTags.AXES)) {
return this.getMaterial().getMiningLevel();
}
return 0;
}
}

View file

@ -8,8 +8,9 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import io.netty.util.internal.ThreadLocalRandom;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.ToolManager;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
@ -28,6 +29,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import ru.betterend.registry.ItemTagRegistry;
public class EndHammer extends MiningToolItem implements DynamicAttributeTool {
public final static UUID ATTACK_KNOCKBACK_MODIFIER_ID = MathHelper.randomUuid(ThreadLocalRandom.current());
@ -46,7 +49,12 @@ public class EndHammer extends MiningToolItem implements DynamicAttributeTool {
@Override
public boolean canMine(BlockState state, World world, BlockPos pos, PlayerEntity miner) {
return !miner.isCreative() || state.getMaterial().equals(Material.STONE) || state.getMaterial().equals(Material.GLASS);
return state.getMaterial().equals(Material.STONE) ||
state.getMaterial().equals(Material.GLASS) ||
state.isOf(Blocks.DIAMOND_BLOCK) ||
state.isOf(Blocks.EMERALD_BLOCK) ||
state.isOf(Blocks.LAPIS_BLOCK) ||
state.isOf(Blocks.REDSTONE_BLOCK);
}
@Override
@ -88,13 +96,19 @@ public class EndHammer extends MiningToolItem implements DynamicAttributeTool {
@Override
public float getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
return ToolManager.handleBreakingSpeed(state, stack, user);
if (tag.equals(ItemTagRegistry.HAMMERS)) {
return this.getMiningSpeedMultiplier(stack, state);
}
return 1.0F;
}
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(ItemTagRegistry.HAMMERS)) {
return this.getMaterial().getMiningLevel();
}
return 0;
}
@Override
public boolean isEffectiveOn(BlockState state) {

View file

@ -1,6 +1,7 @@
package ru.betterend.item;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
@ -17,6 +18,9 @@ public class EndPickaxe extends PickaxeItem implements DynamicAttributeTool {
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(FabricToolTags.PICKAXES)) {
return this.getMaterial().getMiningLevel();
}
return 0;
}
}