Search in sources :

Example 1 with Char2ObjectMap

use of it.unimi.dsi.fastutil.chars.Char2ObjectMap 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));
            }
        });
    });
}
Also used : Blocks(net.minecraft.init.Blocks) EntitySearcher(mods.railcraft.common.util.entity.EntitySearcher) ArrayList(java.util.ArrayList) ICON(mods.railcraft.common.blocks.structures.BlockRockCrusher.ICON) EnumGui(mods.railcraft.common.gui.EnumGui) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d) ClientEffects(mods.railcraft.client.util.effects.ClientEffects) InvTools(mods.railcraft.common.util.inventory.InvTools) EntityItem(net.minecraft.entity.item.EntityItem) mods.railcraft.common.blocks.logic(mods.railcraft.common.blocks.logic) World(net.minecraft.world.World) RailcraftDamageSource(mods.railcraft.common.util.entity.RailcraftDamageSource) Game(mods.railcraft.common.util.misc.Game) BlockPos(net.minecraft.util.math.BlockPos) RailcraftBlocks(mods.railcraft.common.blocks.RailcraftBlocks) Char2ObjectOpenHashMap(it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap) WorldPlugin(mods.railcraft.common.plugins.forge.WorldPlugin) Char2ObjectMap(it.unimi.dsi.fastutil.chars.Char2ObjectMap) IBlockState(net.minecraft.block.state.IBlockState) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) TileLogic(mods.railcraft.common.blocks.TileLogic) MiscTools(mods.railcraft.common.util.misc.MiscTools) Optional(java.util.Optional) RCEntitySelectors(mods.railcraft.common.util.entity.RCEntitySelectors) TileCrafter(mods.railcraft.common.blocks.TileCrafter) IBlockState(net.minecraft.block.state.IBlockState) Char2ObjectOpenHashMap(it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap) TileLogic(mods.railcraft.common.blocks.TileLogic)

Aggregations

Char2ObjectMap (it.unimi.dsi.fastutil.chars.Char2ObjectMap)1 Char2ObjectOpenHashMap (it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 ClientEffects (mods.railcraft.client.util.effects.ClientEffects)1 RailcraftBlocks (mods.railcraft.common.blocks.RailcraftBlocks)1 TileCrafter (mods.railcraft.common.blocks.TileCrafter)1 TileLogic (mods.railcraft.common.blocks.TileLogic)1 mods.railcraft.common.blocks.logic (mods.railcraft.common.blocks.logic)1 ICON (mods.railcraft.common.blocks.structures.BlockRockCrusher.ICON)1 EnumGui (mods.railcraft.common.gui.EnumGui)1 WorldPlugin (mods.railcraft.common.plugins.forge.WorldPlugin)1 EntitySearcher (mods.railcraft.common.util.entity.EntitySearcher)1 RCEntitySelectors (mods.railcraft.common.util.entity.RCEntitySelectors)1 RailcraftDamageSource (mods.railcraft.common.util.entity.RailcraftDamageSource)1 InvTools (mods.railcraft.common.util.inventory.InvTools)1 Game (mods.railcraft.common.util.misc.Game)1 MiscTools (mods.railcraft.common.util.misc.MiscTools)1 IBlockState (net.minecraft.block.state.IBlockState)1