2023-10-23 14:02:09 +01:00
|
|
|
package com.colen.postea.API;
|
|
|
|
|
|
2023-10-30 01:28:47 +00:00
|
|
|
import akka.japi.Pair;
|
2023-10-23 14:02:09 +01:00
|
|
|
import net.minecraft.block.Block;
|
2023-10-23 15:37:55 +01:00
|
|
|
import net.minecraft.item.Item;
|
2023-10-23 14:02:09 +01:00
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
2023-10-30 01:28:47 +00:00
|
|
|
import java.util.function.Function;
|
2023-10-23 14:02:09 +01:00
|
|
|
|
2023-10-23 15:37:55 +01:00
|
|
|
import static com.colen.postea.API.ItemStackReplacementManager.addItemReplacement;
|
|
|
|
|
|
2023-10-23 14:02:09 +01:00
|
|
|
public class BlockReplacementManager {
|
|
|
|
|
|
2023-10-30 01:28:47 +00:00
|
|
|
private static final Map<BlockKey, Function<BlockKey, Pair<Integer, Integer>>> blockReplacementMap = new HashMap<>();
|
2023-10-23 14:02:09 +01:00
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
2023-10-30 01:28:47 +00:00
|
|
|
public static void addBlockReplacement(String blockNameIn, int metadataIn, Function<BlockKey, Pair<Integer, Integer>> transformer) {
|
|
|
|
|
blockReplacementMap.put(new BlockKey(blockNameIn, metadataIn), transformer);
|
2023-10-23 14:02:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
2023-10-30 01:28:47 +00:00
|
|
|
public static Pair<Integer, Integer> getBlockReplacement(int blockID, int metadataIn) {
|
|
|
|
|
Block block = Block.getBlockById(blockID);
|
|
|
|
|
String blockName = block.getUnlocalizedName();
|
|
|
|
|
|
|
|
|
|
Function<BlockKey, Pair<Integer, Integer>> transformer = blockReplacementMap.getOrDefault(new BlockKey(blockName, metadataIn), null);
|
|
|
|
|
|
|
|
|
|
if (transformer == null) {
|
|
|
|
|
return null;
|
|
|
|
|
} else {
|
|
|
|
|
return transformer.apply(new BlockKey(blockName, metadataIn));
|
|
|
|
|
}
|
2023-10-23 14:02:09 +01:00
|
|
|
}
|
2023-10-30 01:28:47 +00:00
|
|
|
|
2023-10-23 14:02:09 +01:00
|
|
|
}
|