make speedpowder tools work on mod blocks also
This commit is contained in:
parent
e8607ca419
commit
24f9abfb18
@ -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
|
||||
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -26,6 +28,15 @@ public class ToolSpeedpowderPickaxe extends PickaxeItem implements ToolRangeable
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user