bugfix on external ids
This commit is contained in:
parent
a7352e84a2
commit
988a867099
@ -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
|
||||
|
||||
|
@ -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<String> 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<Identifier> 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<List<Block>> 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<String> 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<Identifier> 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<Block> PICKAXE_EFFECTIVE_ON = Sets.newHashSet(new Block[] { Blocks.GLOWSTONE });
|
||||
|
||||
/**
|
||||
* merge all sets
|
||||
*
|
||||
* @param sets the sets
|
||||
* @return one merged set
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static Set<Identifier> mergeSets(Set<Identifier>... sets) {
|
||||
Set<Identifier> result = new HashSet<>();
|
||||
for (Set<Identifier> set : sets) {
|
||||
result.addAll(set);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return range of blocks to be harvested
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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<Identifier> createFromStrings(String... names) {
|
||||
Set<Identifier> set = new HashSet<>();
|
||||
for (String name : names) {
|
||||
set.add(new Byg(name));
|
||||
}
|
||||
return set;
|
||||
}
|
||||
}
|
@ -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<Identifier> createFromStrings(String... names) {
|
||||
Set<Identifier> set = new HashSet<>();
|
||||
for (String name : names) {
|
||||
set.add(new Terrestria(name));
|
||||
}
|
||||
return set;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user