diff --git a/gradle.properties b/gradle.properties index 4f924ff..4077c85 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.11 + mod_version = 1.16.1.12 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 6fbac9a..9ce8be1 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java @@ -9,6 +9,7 @@ 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.IdentifierGroup; import de.jottyfan.minecraft.quickiefabric.tools.externalmods.Terrestria; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -47,13 +48,24 @@ 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 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 AXE_EFFECTIVE_ON_EXTERNAL = mergeGroupSets( + Terrestria.createFromGroups(new IdentifierGroup("redwood", "log", "quarter_log", "log_bare", "log_top"), + new IdentifierGroup("hemlock", "log", "quarter_log", "log_bare", "log_top"), + new IdentifierGroup("rubber", "log", "quarter_log", "log_bare", "log_top"), + new IdentifierGroup("cypress", "log", "quarter_log", "log_bare", "log_top"), + new IdentifierGroup("willow", "log", "quarter_log", "log_bare", "log_top"), + new IdentifierGroup("japanese_maple", "log", "quarter_log", "log_bare", "log_top"), + new IdentifierGroup("rainbow_eucalyptus", "log", "quarter_log", "log_bare", "log_top"), + new IdentifierGroup("sakura", "log", "quarter_log", "log_bare", "log_top"), + new IdentifierGroup("yucca_palm", "log", "quarter_log", "log_bare", "log_top")), + Byg.createFromGroups(new IdentifierGroup("aspen", "log", "wood"), new IdentifierGroup("baobab", "log", "wood"), + new IdentifierGroup("blue_enchanted", "log", "wood"), new IdentifierGroup("cherry", "log", "wood"), + new IdentifierGroup("cika", "log", "wood"), new IdentifierGroup("cypress", "log", "wood"), + new IdentifierGroup("ebony", "log", "wood"), new IdentifierGroup("fir", "log", "wood"), + new IdentifierGroup("green_enchanted", "log", "wood"), new IdentifierGroup("holly", "log", "wood"), + new IdentifierGroup("jacaranda", "log", "wood"), new IdentifierGroup("mahogany", "log", "wood"), + new IdentifierGroup("mangrove", "log", "wood"), new IdentifierGroup("willow", "log", "wood"), + new IdentifierGroup("witch_hazel", "log", "wood"), new IdentifierGroup("zelkova", "log", "wood"))); public static final Set PICKAXE_EFFECTIVE_ON = Sets.newHashSet(new Block[] { Blocks.GLOWSTONE }); @@ -72,6 +84,21 @@ public interface ToolRangeable { return result; } + /** + * merge all group sets + * + * @param sets the sets + * @return one merged set + */ + @SafeVarargs + public static Set mergeGroupSets(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 6e496a4..822a6e6 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java @@ -4,6 +4,7 @@ import java.util.List; import com.google.common.collect.Lists; +import de.jottyfan.minecraft.quickiefabric.tools.externalmods.IdentifierGroup; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.AxeItem; @@ -22,7 +23,7 @@ public class ToolRangeableAxe extends AxeItem implements ToolRangeable { protected ToolRangeableAxe(ToolMaterial material, float attachDamage, float attackSpeedIn, Settings settings) { super(material, attachDamage, attackSpeedIn, settings); } - + @Override public HarvestRange getRange() { return null; // no limit @@ -45,10 +46,12 @@ public class ToolRangeableAxe extends AxeItem implements ToolRangeable { return blockList; } } - 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); + for (IdentifierGroup externalIDs : AXE_EFFECTIVE_ON_EXTERNAL) { + for (Identifier externalID : externalIDs.getIdentifiers()) { + Block registeredBlock = Registry.BLOCK.get(externalID); // may be null if mods are not available + if (registeredBlock != null && registeredBlock.equals(block)) { + return Lists.newArrayList(block); + } } } return null; 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 index 605f0a9..b3874be 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Byg.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Byg.java @@ -20,7 +20,7 @@ public class Byg extends Identifier { public Byg(String id) { super("byg", id); } - + /** * create a new set of Byg Identifiers * @@ -34,4 +34,19 @@ public class Byg extends Identifier { } return set; } + + /** + * create from groups + * + * @param groups the groups + * @return the list of indentifier groups + */ + public static final Set createFromGroups(IdentifierGroup... groups) { + Set set = new HashSet<>(); + for (IdentifierGroup group : groups) { + group.setModId("byg"); + set.add(group); + } + return set; + } } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/IdentifierGroup.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/IdentifierGroup.java new file mode 100644 index 0000000..5059416 --- /dev/null +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/IdentifierGroup.java @@ -0,0 +1,44 @@ +package de.jottyfan.minecraft.quickiefabric.tools.externalmods; + +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.util.Identifier; + +/** + * + * @author jotty + * + */ +public class IdentifierGroup { + private final Set names; + private String modId; + + public IdentifierGroup(String prefix, String... suffix) { + this.names = new HashSet<>(); + for (String s : suffix) { + names.add(new StringBuilder(prefix).append("_").append(s).toString()); + } + } + + /** + * get the identifiers for the mod + * + * @return the set of identifiers + */ + public Set getIdentifiers(){ + Set set = new HashSet<>(); + for (String name : names) { + set.add(new Identifier(modId, name)); + } + return set; + } + + public String getModId() { + return modId; + } + + public void setModId(String modId) { + this.modId = modId; + } +} 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 index be92f5b..261b124 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Terrestria.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/externalmods/Terrestria.java @@ -14,6 +14,7 @@ public class Terrestria extends Identifier { /** * create identifier preluded by terrestria + * * @param id the id within terrestria */ public Terrestria(String id) { @@ -33,4 +34,19 @@ public class Terrestria extends Identifier { } return set; } + + /** + * create from groups + * + * @param groups the groups + * @return the list of indentifier groups + */ + public static final Set createFromGroups(IdentifierGroup... groups) { + Set set = new HashSet<>(); + for (IdentifierGroup group : groups) { + group.setModId("terrestria"); + set.add(group); + } + return set; + } }