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
|
loader_version=0.11.6
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.17.1.4
|
mod_version = 1.17.1.5
|
||||||
maven_group = de.jottyfan.minecraft
|
maven_group = de.jottyfan.minecraft
|
||||||
archives_base_name = quickiefabric
|
archives_base_name = quickiefabric
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public interface ToolRangeable {
|
|||||||
|
|
||||||
public static final Set<Block> HOE_EFFECTIVE_ON = Sets.newHashSet(new Block[] { Blocks.BAMBOO, Blocks.BAMBOO_SAPLING,
|
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.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();
|
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,
|
.newHashSet(new Block[] { Blocks.GLOWSTONE, QuickieBlocks.ORE_NETHER_SULPHOR, QuickieBlocks.ORE_SALPETER,
|
||||||
QuickieBlocks.ORE_SAND_SALPETER, QuickieBlocks.ORE_SULPHOR });
|
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
|
* merge all sets
|
||||||
*
|
*
|
||||||
|
@ -12,6 +12,8 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.item.PickaxeItem;
|
import net.minecraft.item.PickaxeItem;
|
||||||
import net.minecraft.item.ToolMaterials;
|
import net.minecraft.item.ToolMaterials;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
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));
|
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
|
@Override
|
||||||
public HarvestRange getRange(ItemStack stack) {
|
public HarvestRange getRange(ItemStack stack) {
|
||||||
NbtCompound tag = stack.getNbt();
|
NbtCompound tag = stack.getNbt();
|
||||||
@ -39,7 +50,17 @@ public class ToolSpeedpowderPickaxe extends PickaxeItem implements ToolRangeable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBreakNeighbors(BlockState blockIn) {
|
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
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user