diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/CommonToolCode.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/CommonToolCode.java deleted file mode 100644 index 6b68f1d..0000000 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/CommonToolCode.java +++ /dev/null @@ -1,58 +0,0 @@ -package de.jottyfan.minecraft.quickiefabric.tools; - -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * - * @author jotty - * - */ -public class CommonToolCode { -// public static final void onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { -// CompoundNBT nbt = playerIn.getHeldItem(handIn).getTag(); -// if (nbt != null) { -// int level = nbt.getInt("level"); -// if (playerIn.isSneaking()) { -// // drop all enhancements into the players inventory if possible -// ItemStack stack = new ItemStack(QuickieItems.ITEM_LEVELUP, level); -// boolean unlevelingerror = false; -// if (!worldIn.isRemote) { -// if (playerIn.addItemStackToInventory(stack)) { -// level = 0; -// } else { -// unlevelingerror = true; -// } -// } -// if (worldIn.isRemote && unlevelingerror) { -// playerIn.sendMessage(new TranslationTextComponent("error.unleveling.inventory.full"), PlayerEntity.getUUID(playerIn.getGameProfile())); -// } -// } else { -// // add all enhancements in players inventory -// if (!worldIn.isRemote) { -// NonNullList main = playerIn.inventory.mainInventory; -// for (ItemStack stack : main) { -// if (stack.getItem().equals(RegistryManager.ITEM_LEVELUP)) { -// level += stack.getCount(); -// stack.setCount(0); -// } -// } -// } -// } -// nbt.putInt("level", level); -// } -// } -// -// public static final void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { -// if (tooltip != null) { -// CompoundNBT nbt = stack.getTag(); -// if (nbt != null) { -// tooltip.add(new StringTextComponent("level " + nbt.getInt("level"))); -// } else { -// tooltip.add(new StringTextComponent("level 0")); -// } -// } -// } -} diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java index d086768..1b0562a 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java @@ -18,24 +18,36 @@ import net.minecraft.block.Blocks; */ public interface ToolRangeable { public static final Set SHOVEL_EFFECTIVE_ON = Sets - .newHashSet(new Block[] { Blocks.GRAVEL, Blocks.SAND, Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.CLAY, Blocks.FARMLAND, Blocks.GRASS_PATH, Blocks.RED_SAND, Blocks.SOUL_SAND }); + .newHashSet(new Block[] { Blocks.GRAVEL, Blocks.SAND, Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.CLAY, + Blocks.FARMLAND, Blocks.GRASS_PATH, Blocks.RED_SAND, Blocks.SOUL_SAND }); - public static final List> AXE_EFFECTIVE_ON = Lists.newArrayList(Arrays.asList(Blocks.ACACIA_LOG, Blocks.STRIPPED_ACACIA_LOG, Blocks.ACACIA_WOOD, Blocks.STRIPPED_ACACIA_WOOD), + public static final Set SHOVEL_EXTERNAL_EFFECTIVE_ON = Sets.newHashSet("byg:black_sand", "byg:white_sand"); + + public static final List> AXE_EFFECTIVE_ON = Lists.newArrayList( + Arrays.asList(Blocks.ACACIA_LOG, Blocks.STRIPPED_ACACIA_LOG, Blocks.ACACIA_WOOD, Blocks.STRIPPED_ACACIA_WOOD), Arrays.asList(Blocks.BIRCH_LOG, Blocks.STRIPPED_BIRCH_LOG, Blocks.BIRCH_WOOD, Blocks.STRIPPED_BIRCH_WOOD), - Arrays.asList(Blocks.DARK_OAK_LOG, Blocks.STRIPPED_DARK_OAK_LOG, Blocks.DARK_OAK_WOOD, Blocks.STRIPPED_DARK_OAK_WOOD), + Arrays.asList(Blocks.DARK_OAK_LOG, Blocks.STRIPPED_DARK_OAK_LOG, Blocks.DARK_OAK_WOOD, + Blocks.STRIPPED_DARK_OAK_WOOD), Arrays.asList(Blocks.JUNGLE_LOG, Blocks.STRIPPED_JUNGLE_LOG, Blocks.JUNGLE_WOOD, Blocks.STRIPPED_JUNGLE_WOOD), Arrays.asList(Blocks.OAK_LOG, Blocks.STRIPPED_OAK_LOG, Blocks.OAK_WOOD, Blocks.STRIPPED_OAK_WOOD), - Arrays.asList(Blocks.SPRUCE_LOG, Blocks.STRIPPED_SPRUCE_LOG, Blocks.SPRUCE_WOOD, Blocks.STRIPPED_SPRUCE_WOOD), Arrays.asList(Blocks.ACACIA_PLANKS), Arrays.asList(Blocks.BIRCH_PLANKS), - Arrays.asList(Blocks.DARK_OAK_PLANKS), Arrays.asList(Blocks.JUNGLE_PLANKS), Arrays.asList(Blocks.OAK_PLANKS), Arrays.asList(Blocks.SPRUCE_PLANKS), Arrays.asList(Blocks.ACACIA_SLAB), - Arrays.asList(Blocks.BIRCH_SLAB), Arrays.asList(Blocks.DARK_OAK_SLAB), Arrays.asList(Blocks.JUNGLE_SLAB), Arrays.asList(Blocks.OAK_SLAB), Arrays.asList(Blocks.SPRUCE_SLAB), - Arrays.asList(Blocks.ACACIA_STAIRS), Arrays.asList(Blocks.BIRCH_STAIRS), Arrays.asList(Blocks.DARK_OAK_STAIRS), Arrays.asList(Blocks.JUNGLE_STAIRS), Arrays.asList(Blocks.OAK_STAIRS), - Arrays.asList(Blocks.SPRUCE_STAIRS), Arrays.asList(Blocks.POTTED_BROWN_MUSHROOM, Blocks.BROWN_MUSHROOM_BLOCK, Blocks.BROWN_MUSHROOM, Blocks.MUSHROOM_STEM), + Arrays.asList(Blocks.SPRUCE_LOG, Blocks.STRIPPED_SPRUCE_LOG, Blocks.SPRUCE_WOOD, Blocks.STRIPPED_SPRUCE_WOOD), + Arrays.asList(Blocks.ACACIA_PLANKS), Arrays.asList(Blocks.BIRCH_PLANKS), Arrays.asList(Blocks.DARK_OAK_PLANKS), + Arrays.asList(Blocks.JUNGLE_PLANKS), Arrays.asList(Blocks.OAK_PLANKS), Arrays.asList(Blocks.SPRUCE_PLANKS), + Arrays.asList(Blocks.ACACIA_SLAB), Arrays.asList(Blocks.BIRCH_SLAB), Arrays.asList(Blocks.DARK_OAK_SLAB), + Arrays.asList(Blocks.JUNGLE_SLAB), Arrays.asList(Blocks.OAK_SLAB), Arrays.asList(Blocks.SPRUCE_SLAB), + Arrays.asList(Blocks.ACACIA_STAIRS), Arrays.asList(Blocks.BIRCH_STAIRS), Arrays.asList(Blocks.DARK_OAK_STAIRS), + Arrays.asList(Blocks.JUNGLE_STAIRS), Arrays.asList(Blocks.OAK_STAIRS), Arrays.asList(Blocks.SPRUCE_STAIRS), + Arrays.asList(Blocks.POTTED_BROWN_MUSHROOM, Blocks.BROWN_MUSHROOM_BLOCK, Blocks.BROWN_MUSHROOM, + Blocks.MUSHROOM_STEM), Arrays.asList(Blocks.POTTED_RED_MUSHROOM, Blocks.RED_MUSHROOM_BLOCK, Blocks.RED_MUSHROOM, Blocks.MUSHROOM_STEM)); - public static final List AXE_EFFECTIVE_ON_EXTERNAL = Lists.newArrayList("terrestia:redwood", "terrestia:hemlock", "terrestia:rubber", "terrestia:cypress", "terrestia:willow", - "terrestia:japanese_maple", "terrestia:rainbow_eucalyptus", "terrestia:sakura", "terrestia:yucca_palm", "byg:aspen_log", "byg:baobab_log", "byg:blue_enchanted_log", "byg:cherry_log", - "byg:cika_log", "byg:cypress_log", "byg:ebony_log", "byg:fir_log", "byg:green_enchanted_log", "byg:holly_log", "byg:jacaranda_log", "byg:mahogany_log", "byg:mangrove_log", "byg:maple_log", - "byg:palo_verde_log", "byg:pine_log", "byg:rainbow_eucalyptus_log", "byg:redwood_log", "byg:skyris_log", "byg:willow_log", "byg:witch_hazel_log", "byg:zelkova_log"); + public static final List AXE_EFFECTIVE_ON_EXTERNAL = Lists.newArrayList("terrestia:redwood", + "terrestia:hemlock", "terrestia:rubber", "terrestia:cypress", "terrestia:willow", "terrestia:japanese_maple", + "terrestia:rainbow_eucalyptus", "terrestia:sakura", "terrestia:yucca_palm", "byg:aspen_log", "byg:baobab_log", + "byg:blue_enchanted_log", "byg:cherry_log", "byg:cika_log", "byg:cypress_log", "byg:ebony_log", "byg:fir_log", + "byg:green_enchanted_log", "byg:holly_log", "byg:jacaranda_log", "byg:mahogany_log", "byg:mangrove_log", + "byg:maple_log", "byg:palo_verde_log", "byg:pine_log", "byg:rainbow_eucalyptus_log", "byg:redwood_log", + "byg:skyris_log", "byg:willow_log", "byg:witch_hazel_log", "byg:zelkova_log"); public static final Set PICKAXE_EFFECTIVE_ON = Sets.newHashSet(new Block[] { Blocks.GLOWSTONE }); @@ -45,10 +57,10 @@ public interface ToolRangeable { public HarvestRange getRange(); /** - * check if this block state is one that affects the neighbor blocks to break also if they are from the same type + * check if this block state is one that affects the neighbor blocks to break + * also if they are from the same type * - * @param blockState - * the block state of the current block + * @param blockState the block state of the current block * @return true or false */ public boolean canBreakNeigbbors(BlockState blockState); @@ -56,8 +68,7 @@ public interface ToolRangeable { /** * get list of blocks that belong together * - * @param block - * of the set + * @param block of the set * @return the list of blocks or null if not found */ public List getBlockList(Block block); diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java index 828980d..473160e 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java @@ -10,6 +10,8 @@ import net.minecraft.block.BlockState; import net.minecraft.item.Item; import net.minecraft.item.ShovelItem; import net.minecraft.item.ToolMaterials; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; /** * @@ -32,7 +34,16 @@ public class ToolSpeedpowderShovel extends ShovelItem implements ToolRangeable { @Override public boolean canBreakNeigbbors(BlockState blockIn) { - return SHOVEL_EFFECTIVE_ON.contains(blockIn.getBlock()); + return isEffectiveOn(blockIn) || SHOVEL_EFFECTIVE_ON.contains(blockIn.getBlock()) || checkExternalBlock(blockIn.getBlock()); + } + + private boolean checkExternalBlock(Block block) { + for (String externalBlockName : SHOVEL_EXTERNAL_EFFECTIVE_ON) { + Identifier id = new Identifier(externalBlockName); + Block registeredBlock = Registry.BLOCK.get(id); // may be null if mods are not available + return registeredBlock != null && registeredBlock.equals(block); + } + return false; } @Override