use of it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap in project Railcraft by Railcraft.
the class TileRockCrusher method placeRockCrusher.
public static void placeRockCrusher(World world, BlockPos pos, int patternIndex, @Nullable List<ItemStack> input, @Nullable List<ItemStack> output) {
StructurePattern pattern = TileRockCrusher.patterns.get(patternIndex);
Char2ObjectMap<IBlockState> blockMapping = new Char2ObjectOpenHashMap<>();
IBlockState state = RailcraftBlocks.ROCK_CRUSHER.getState(null);
blockMapping.put('B', state);
blockMapping.put('D', state);
blockMapping.put('a', state);
blockMapping.put('b', state);
blockMapping.put('c', state);
blockMapping.put('d', state);
blockMapping.put('e', state);
blockMapping.put('f', state);
blockMapping.put('h', state);
Optional<TileLogic> tile = pattern.placeStructure(world, pos, blockMapping);
tile.flatMap(t -> t.getLogic(StructureLogic.class)).ifPresent(structure -> {
structure.getFunctionalLogic(InventoryLogic.class).ifPresent(logic -> {
for (int slot = 0; slot < 9; slot++) {
if (input != null && slot < input.size())
logic.setInventorySlotContents(RockCrusherLogic.SLOT_INPUT + slot, input.get(slot));
if (output != null && slot < output.size())
logic.setInventorySlotContents(RockCrusherLogic.SLOT_OUTPUT + slot, output.get(slot));
}
});
});
}
Aggregations