package org.terasology.model.blocks; import org.terasology.math.Side; import org.terasology.teraspout.TeraBlock; import java.util.EnumMap; /** * Block group for blocks that can be oriented around the vertical axis. * * @author Immortius <immortius@gmail.com> */ public class HorizontalBlockFamily implements BlockFamily { String _name; EnumMap<Side, TeraBlock> _blocks = new EnumMap<Side, TeraBlock>(Side.class); /** * @param name The name for the block group. * @param blocks The set of blocks that make up the group. Front, Back, Left and Right must be provided - the rest is ignored. */ public HorizontalBlockFamily(String name, EnumMap<Side, TeraBlock> blocks) { _name = name; for (Side side : Side.horizontalSides()) { TeraBlock block = blocks.get(side); if (block == null) { throw new IllegalArgumentException("Missing block for side: " + side.toString()); } _blocks.put(side, block); block.withBlockFamily(this); } } public String getTitle() { return _name; } public short getBlockIdFor(Side attachmentSide, Side direction) { return getBlockFor(attachmentSide, direction).getId(); } public TeraBlock getBlockFor(Side attachmentSide, Side direction) { if (attachmentSide.isHorizontal()) { return _blocks.get(attachmentSide); } return _blocks.get(direction); } public TeraBlock getArchetypeBlock() { return _blocks.get(Side.FRONT); } }