Validate stripping recipe before adding

This commit is contained in:
Leo40Git
2021-08-11 15:51:32 +03:00
parent 32a44239ea
commit c8f7904481

View File

@@ -3,6 +3,7 @@ package dev.architectury.hooks.item.tool;
import com.google.common.collect.ImmutableMap;
import net.minecraft.world.item.AxeItem;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RotatedPillarBlock;
import java.util.HashMap;
@@ -11,6 +12,10 @@ public final class AxeItemHooks {
}
public static void addStrippingRecipe(Block src, Block dst) {
if (!src.defaultBlockState().hasProperty(RotatedPillarBlock.AXIS))
throw new IllegalArgumentException("Source block is missing required 'AXIS' property!");
if (!dst.defaultBlockState().hasProperty(RotatedPillarBlock.AXIS))
throw new IllegalArgumentException("Destination block is missing required 'AXIS' property!");
if (AxeItem.STRIPPABLES instanceof ImmutableMap) {
AxeItem.STRIPPABLES = new HashMap<>(AxeItem.STRIPPABLES);
}