From 988a867099d529c59fd12f3b5da8d038d4525fdc Mon Sep 17 00:00:00 2001 From: jottyfan Date: Sun, 16 Aug 2020 16:40:37 +0200 Subject: [PATCH] bugfix on external ids --- gradle.properties | 2 +- .../quickiefabric/tools/ToolRangeable.java | 38 ++++++++++++++----- .../quickiefabric/tools/ToolRangeableAxe.java | 5 +-- .../tools/ToolSpeedpowderShovel.java | 9 +++-- .../quickiefabric/tools/externalmods/Byg.java | 37 ++++++++++++++++++ .../tools/externalmods/Terrestria.java | 36 ++++++++++++++++++ 6 files changed, 110 insertions(+), 17 deletions(-) create mode 100644 src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Byg.java create mode 100644 src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Terrestria.java diff --git a/gradle.properties b/gradle.properties index 2ea7cb6..42296a5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.8.8+build.202 # Mod Properties - mod_version = 1.16.1.6 + mod_version = 1.16.1.7 maven_group = de.jottyfan.minecraft archives_base_name = quickiefabric 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 bf60a02..6fbac9a 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java @@ -1,15 +1,19 @@ package de.jottyfan.minecraft.quickiefabric.tools; import java.util.Arrays; +import java.util.HashSet; import java.util.List; import java.util.Set; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import de.jottyfan.minecraft.quickiefabric.tools.externalmods.Byg; +import de.jottyfan.minecraft.quickiefabric.tools.externalmods.Terrestria; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.util.Identifier; /** * @@ -21,8 +25,9 @@ public interface ToolRangeable { .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 Set SHOVEL_EXTERNAL_EFFECTIVE_ON = Sets.newHashSet("byg:black_sand", "byg:white_sand", - "byg:peat", "byg:meadow_dirt", "byg:mud_block", "byg:blue_sand", "byg:purple_sand", "terrestria:basalt_sand"); + public static final Set SHOVEL_EXTERNAL_EFFECTIVE_ON = mergeSets( + Byg.createFromStrings("black_sand", "white_sand", "peat", "meadow_dirt", "mud_block", "blue_sand", "purple_sand"), + Terrestria.createFromStrings("basalt_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), @@ -42,16 +47,31 @@ public interface ToolRangeable { 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_log", - "terrestia:hemlock_log", "terrestia:rubber_log", "terrestia:cypress_log", "terrestia:willow_log", "terrestia:japanese_maple_log", - "terrestia:rainbow_eucalyptus_log", "terrestia:sakura_log", "terrestia:yucca_palm:_log", "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 AXE_EFFECTIVE_ON_EXTERNAL = mergeSets( + Terrestria.createFromStrings("redwood_log", "hemlock_log", "rubber_log", "cypress_log", "willow_log", + "japanese_maple_log", "rainbow_eucalyptus_log", "sakura_log", "yucca_palm_log"), + Byg.createFromStrings("aspen_log", "baobab_log", "blue_enchanted_log", "cherry_log", "cika_log", "cypress_log", + "ebony_log", "fir_log", "green_enchanted_log", "holly_log", "jacaranda_log", "mahogany_log", "mangrove_log", + "maple_log", "palo_verde_log", "pine_log", "rainbow_eucalyptus_log", "redwood_log", "skyris_log", + "willow_log", "witch_hazel_log", "zelkova_log")); public static final Set PICKAXE_EFFECTIVE_ON = Sets.newHashSet(new Block[] { Blocks.GLOWSTONE }); + /** + * merge all sets + * + * @param sets the sets + * @return one merged set + */ + @SafeVarargs + public static Set mergeSets(Set... sets) { + Set result = new HashSet<>(); + for (Set set : sets) { + result.addAll(set); + } + return result; + } + /** * @return range of blocks to be harvested */ diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java index 4bbb588..6e496a4 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java @@ -45,9 +45,8 @@ public class ToolRangeableAxe extends AxeItem implements ToolRangeable { return blockList; } } - for (String externalBlockName : AXE_EFFECTIVE_ON_EXTERNAL) { - Identifier id = new Identifier(externalBlockName); - Block registeredBlock = Registry.BLOCK.get(id); // may be null if mods are not available + for (Identifier externalID : AXE_EFFECTIVE_ON_EXTERNAL) { + Block registeredBlock = Registry.BLOCK.get(externalID); // may be null if mods are not available if (registeredBlock != null && registeredBlock.equals(block)) { return Lists.newArrayList(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 e301719..2162ea7 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderShovel.java @@ -39,16 +39,17 @@ public class ToolSpeedpowderShovel extends ShovelItem implements ToolRangeable { public boolean canBreakNeigbbors(BlockState blockState) { boolean result = SHOVEL_EFFECTIVE_ON.contains(blockState.getBlock()) || checkExternalBlock(blockState.getBlock()); if (!result) { - LOGGER.info("cannot break block {} with that speedpoweder shovel", Registry.BLOCK.getId(blockState.getBlock())); + if (!blockState.isAir()) { + LOGGER.debug("cannot break block {} with that speedpowder shovel", Registry.BLOCK.getId(blockState.getBlock())); + } } return result; } private boolean checkExternalBlock(Block block) { boolean result = false; - 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 + for (Identifier externalID : SHOVEL_EXTERNAL_EFFECTIVE_ON) { + Block registeredBlock = Registry.BLOCK.get(externalID); // may be null if mods are not available result = result || (registeredBlock != null && registeredBlock.equals(block)); } return result; diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Byg.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Byg.java new file mode 100644 index 0000000..605f0a9 --- /dev/null +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Byg.java @@ -0,0 +1,37 @@ +package de.jottyfan.minecraft.quickiefabric.tools.externalmods; + +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.util.Identifier; + +/** + * + * @author jotty + * + */ +public class Byg extends Identifier { + + /** + * create identifier preluded by byg (for biomes you'll go) + * + * @param id the id within byg + */ + public Byg(String id) { + super("byg", id); + } + + /** + * create a new set of Byg Identifiers + * + * @param names the names + * @return a set of identifiers + */ + public static final Set createFromStrings(String... names) { + Set set = new HashSet<>(); + for (String name : names) { + set.add(new Byg(name)); + } + return set; + } +} diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Terrestria.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Terrestria.java new file mode 100644 index 0000000..be92f5b --- /dev/null +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Terrestria.java @@ -0,0 +1,36 @@ +package de.jottyfan.minecraft.quickiefabric.tools.externalmods; + +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.util.Identifier; + +/** + * + * @author jotty + * + */ +public class Terrestria extends Identifier { + + /** + * create identifier preluded by terrestria + * @param id the id within terrestria + */ + public Terrestria(String id) { + super("terrestria", id); + } + + /** + * create a new set of Terrestria Identifiers + * + * @param names the names + * @return a set of identifiers + */ + public static final Set createFromStrings(String... names) { + Set set = new HashSet<>(); + for (String name : names) { + set.add(new Terrestria(name)); + } + return set; + } +}