mirror of
https://github.com/GTNewHorizons/Postea.git
synced 2026-11-12 16:37:38 +00:00
Some progress for block -> block
This commit is contained in:
1 parent
d112fd627f
commit
4399159661
4 files changed
+57
-37
No files matched your search
@@ -1,25 +1,36 @@
|
||||
package com.colen.postea.API;
|
||||
|
||||
import akka.japi.Pair;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static com.colen.postea.API.ItemStackReplacementManager.addItemReplacement;
|
||||
|
||||
public class BlockReplacementManager {
|
||||
|
||||
private static final Map<BlockKey, BlockKey> blockReplacementMap = new HashMap<>();
|
||||
private static final Map<BlockKey, Function<BlockKey, Pair<Integer, Integer>>> blockReplacementMap = new HashMap<>();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static void addBlockReplacement(Block blockIn, int metadataIn, Block blockOut, int metadataOut) {
|
||||
blockReplacementMap.put(new BlockKey(blockIn, metadataIn), new BlockKey(blockOut, metadataOut));
|
||||
addItemReplacement(Item.getItemFromBlock(blockIn), metadataIn, Item.getItemFromBlock(blockOut), metadataOut);
|
||||
public static void addBlockReplacement(String blockNameIn, int metadataIn, Function<BlockKey, Pair<Integer, Integer>> transformer) {
|
||||
blockReplacementMap.put(new BlockKey(blockNameIn, metadataIn), transformer);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static BlockKey getBlockReplacement(Block blockIn, int metadataIn) {
|
||||
return blockReplacementMap.getOrDefault(new BlockKey(blockIn, metadataIn), null);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user