make speedpowder tools work on mod blocks also

This commit is contained in:
Jörg Henke 2021-09-03 18:03:06 +02:00
parent e8607ca419
commit 24f9abfb18
3 changed files with 29 additions and 4 deletions

View File

@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.11.6
# Mod Properties
mod_version = 1.17.1.4
mod_version = 1.17.1.5
maven_group = de.jottyfan.minecraft
archives_base_name = quickiefabric

View File

@ -34,7 +34,7 @@ public interface ToolRangeable {
public static final Set<Block> HOE_EFFECTIVE_ON = Sets.newHashSet(new Block[] { Blocks.BAMBOO, Blocks.BAMBOO_SAPLING,
Blocks.ATTACHED_MELON_STEM, Blocks.ATTACHED_PUMPKIN_STEM, Blocks.SUNFLOWER, Blocks.CORNFLOWER, Blocks.SEAGRASS,
Blocks.TALL_GRASS, Blocks.TALL_SEAGRASS, Blocks.GRASS, Blocks.KELP_PLANT, Blocks.KELP});
Blocks.TALL_GRASS, Blocks.TALL_SEAGRASS, Blocks.GRASS, Blocks.KELP_PLANT, Blocks.KELP });
public static final Set<Identifier> HOE_EXTERNAL_EFFECTIVE_ON = mergeSets();
@ -66,6 +66,10 @@ public interface ToolRangeable {
.newHashSet(new Block[] { Blocks.GLOWSTONE, QuickieBlocks.ORE_NETHER_SULPHOR, QuickieBlocks.ORE_SALPETER,
QuickieBlocks.ORE_SAND_SALPETER, QuickieBlocks.ORE_SULPHOR });
public static final Set<Identifier> PICKAXE_EXTERNAL_EFFECTIVE_ON = mergeSets(
Byg.createFromStrings("soapstone", "black_sandstone", "dacite", "rocky_stone", "red_rock", "pink_sandstone",
"purple_sandstone", "scoria_stone", "scoria_cobblestone"));
/**
* merge all sets
*

View File

@ -12,6 +12,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.PickaxeItem;
import net.minecraft.item.ToolMaterials;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
/**
*
@ -25,7 +27,16 @@ public class ToolSpeedpowderPickaxe extends PickaxeItem implements ToolRangeable
public ToolSpeedpowderPickaxe() {
super(ToolMaterials.DIAMOND, 4, 2.0f, new Item.Settings().group(RegistryManager.QUICKIEFABRIC_GROUP));
}
/**
* seems not to work
*/
@Override
public boolean isSuitableFor(BlockState state) {
return PICKAXE_EFFECTIVE_ON.contains(state.getBlock()) || checkExternalBlock(state.getBlock())
|| super.isSuitableFor(state);
}
@Override
public HarvestRange getRange(ItemStack stack) {
NbtCompound tag = stack.getNbt();
@ -39,7 +50,17 @@ public class ToolSpeedpowderPickaxe extends PickaxeItem implements ToolRangeable
@Override
public boolean canBreakNeighbors(BlockState blockIn) {
return super.isSuitableFor(blockIn) || PICKAXE_EFFECTIVE_ON.contains(blockIn.getBlock());
return super.isSuitableFor(blockIn) || PICKAXE_EFFECTIVE_ON.contains(blockIn.getBlock())
|| checkExternalBlock(blockIn.getBlock());
}
private boolean checkExternalBlock(Block block) {
boolean result = false;
for (Identifier externalID : PICKAXE_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;
}
@Override