terrestrial big log compatibility

This commit is contained in:
Jörg Henke 2020-09-03 22:11:29 +02:00
parent 73e313b0dc
commit 155b57dd28
6 changed files with 119 additions and 14 deletions

View File

@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.8.8+build.202 loader_version=0.8.8+build.202
# Mod Properties # Mod Properties
mod_version = 1.16.1.11 mod_version = 1.16.1.12
maven_group = de.jottyfan.minecraft maven_group = de.jottyfan.minecraft
archives_base_name = quickiefabric archives_base_name = quickiefabric

View File

@ -9,6 +9,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import de.jottyfan.minecraft.quickiefabric.tools.externalmods.Byg; 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 de.jottyfan.minecraft.quickiefabric.tools.externalmods.Terrestria;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -47,13 +48,24 @@ public interface ToolRangeable {
Blocks.MUSHROOM_STEM), Blocks.MUSHROOM_STEM),
Arrays.asList(Blocks.POTTED_RED_MUSHROOM, Blocks.RED_MUSHROOM_BLOCK, Blocks.RED_MUSHROOM, Blocks.MUSHROOM_STEM)); Arrays.asList(Blocks.POTTED_RED_MUSHROOM, Blocks.RED_MUSHROOM_BLOCK, Blocks.RED_MUSHROOM, Blocks.MUSHROOM_STEM));
public static final Set<Identifier> AXE_EFFECTIVE_ON_EXTERNAL = mergeSets( public static final Set<IdentifierGroup> AXE_EFFECTIVE_ON_EXTERNAL = mergeGroupSets(
Terrestria.createFromStrings("redwood_log", "hemlock_log", "rubber_log", "cypress_log", "willow_log", Terrestria.createFromGroups(new IdentifierGroup("redwood", "log", "quarter_log", "log_bare", "log_top"),
"japanese_maple_log", "rainbow_eucalyptus_log", "sakura_log", "yucca_palm_log"), new IdentifierGroup("hemlock", "log", "quarter_log", "log_bare", "log_top"),
Byg.createFromStrings("aspen_log", "baobab_log", "blue_enchanted_log", "cherry_log", "cika_log", "cypress_log", new IdentifierGroup("rubber", "log", "quarter_log", "log_bare", "log_top"),
"ebony_log", "fir_log", "green_enchanted_log", "holly_log", "jacaranda_log", "mahogany_log", "mangrove_log", new IdentifierGroup("cypress", "log", "quarter_log", "log_bare", "log_top"),
"maple_log", "palo_verde_log", "pine_log", "rainbow_eucalyptus_log", "redwood_log", "skyris_log", new IdentifierGroup("willow", "log", "quarter_log", "log_bare", "log_top"),
"willow_log", "witch_hazel_log", "zelkova_log")); 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<Block> PICKAXE_EFFECTIVE_ON = Sets.newHashSet(new Block[] { Blocks.GLOWSTONE }); public static final Set<Block> PICKAXE_EFFECTIVE_ON = Sets.newHashSet(new Block[] { Blocks.GLOWSTONE });
@ -72,6 +84,21 @@ public interface ToolRangeable {
return result; return result;
} }
/**
* merge all group sets
*
* @param sets the sets
* @return one merged set
*/
@SafeVarargs
public static Set<IdentifierGroup> mergeGroupSets(Set<IdentifierGroup>... sets) {
Set<IdentifierGroup> result = new HashSet<>();
for (Set<IdentifierGroup> set : sets) {
result.addAll(set);
}
return result;
}
/** /**
* @return range of blocks to be harvested * @return range of blocks to be harvested
*/ */

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import de.jottyfan.minecraft.quickiefabric.tools.externalmods.IdentifierGroup;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.item.AxeItem; import net.minecraft.item.AxeItem;
@ -45,10 +46,12 @@ public class ToolRangeableAxe extends AxeItem implements ToolRangeable {
return blockList; return blockList;
} }
} }
for (Identifier externalID : AXE_EFFECTIVE_ON_EXTERNAL) { for (IdentifierGroup externalIDs : AXE_EFFECTIVE_ON_EXTERNAL) {
Block registeredBlock = Registry.BLOCK.get(externalID); // may be null if mods are not available for (Identifier externalID : externalIDs.getIdentifiers()) {
if (registeredBlock != null && registeredBlock.equals(block)) { Block registeredBlock = Registry.BLOCK.get(externalID); // may be null if mods are not available
return Lists.newArrayList(block); if (registeredBlock != null && registeredBlock.equals(block)) {
return Lists.newArrayList(block);
}
} }
} }
return null; return null;

View File

@ -34,4 +34,19 @@ public class Byg extends Identifier {
} }
return set; return set;
} }
/**
* create from groups
*
* @param groups the groups
* @return the list of indentifier groups
*/
public static final Set<IdentifierGroup> createFromGroups(IdentifierGroup... groups) {
Set<IdentifierGroup> set = new HashSet<>();
for (IdentifierGroup group : groups) {
group.setModId("byg");
set.add(group);
}
return set;
}
} }

View File

@ -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<String> 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<Identifier> getIdentifiers(){
Set<Identifier> 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;
}
}

View File

@ -14,6 +14,7 @@ public class Terrestria extends Identifier {
/** /**
* create identifier preluded by terrestria * create identifier preluded by terrestria
*
* @param id the id within terrestria * @param id the id within terrestria
*/ */
public Terrestria(String id) { public Terrestria(String id) {
@ -33,4 +34,19 @@ public class Terrestria extends Identifier {
} }
return set; return set;
} }
/**
* create from groups
*
* @param groups the groups
* @return the list of indentifier groups
*/
public static final Set<IdentifierGroup> createFromGroups(IdentifierGroup... groups) {
Set<IdentifierGroup> set = new HashSet<>();
for (IdentifierGroup group : groups) {
group.setModId("terrestria");
set.add(group);
}
return set;
}
} }