001/*
002 * Trident - A Multithreaded Server Alternative
003 * Copyright 2014 The TridentSDK Team
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package net.tridentsdk.server.data.block;
018
019import net.tridentsdk.base.Block;
020import net.tridentsdk.base.BlockDirection;
021import net.tridentsdk.base.Substance;
022import net.tridentsdk.meta.block.DirectionMeta;
023import net.tridentsdk.meta.component.Meta;
024import net.tridentsdk.meta.component.MetaCollection;
025
026import static net.tridentsdk.base.Substance.*;
027
028/**
029 * Represents a block direction
030 *
031 * @author The TridentSDK Team
032 */
033public class DirectionMetaImpl implements DirectionMeta {
034    private volatile BlockDirection direction = BlockDirection.SELF;
035
036    @Override
037    public BlockDirection direction() {
038        return direction;
039    }
040
041    @Override
042    public void setDirection(BlockDirection direction) {
043        this.direction = direction;
044    }
045
046    @Override
047    public byte encode() {
048        return 0;
049    }
050
051    @Override
052    public Meta<Block> decode(Block instance, float yaw, byte direction, byte cx, byte cy, byte cz, short damageValue) {
053        return this;
054    }
055
056    @Override
057    public Meta<Block> make() {
058        return new DirectionMetaImpl();
059    }
060
061    @Override
062    public Substance[] applyTo(MetaCollection collection) {
063        collection.putIfAbsent(DirectionMeta.class, this);
064        return new Substance[]{TORCH, REDSTONE_TORCH_ON, REDSTONE_TORCH_OFF, RAILS, ACTIVATOR_RAIL, DETECTOR_RAIL,
065                POWERED_RAIL, ACACIA_STAIRS, BIRCH_WOOD_STAIRS, BRICK_STAIRS, COBBLESTONE_STAIRS, DARK_OAK_STAIRS,
066                JUNGLE_WOOD_STAIRS, NETHER_BRICK_STAIRS, QUARTZ_STAIRS, RED_SANDSTONE_STAIRS, SANDSTONE_STAIRS,
067                SMOOTH_STAIRS, SPRUCE_WOOD_STAIRS, WOOD_STAIRS, LEVER, ACACIA_DOOR, BIRCH_DOOR, DARK_OAK_DOOR,
068                IRON_DOOR, IRON_TRAP_DOOR, JUNGLE_DOOR, SPRUCE_DOOR, SPRUCE_DOOR, TRAP_DOOR, WOOD_DOOR, WOODEN_DOOR,
069                IRON_DOOR_BLOCK, STONE_BUTTON, WOOD_BUTTON, SIGN_POST, SIGN, LADDER, WALL_SIGN, FURNACE,
070                BURNING_FURNACE, CHEST, ENDER_CHEST, TRAPPED_CHEST, /* Double chest */ DISPENSER, DROPPER, HOPPER,
071                PUMPKIN, JACK_O_LANTERN, BED_BLOCK, BED /* ? */, REDSTONE_COMPARATOR, REDSTONE_COMPARATOR_OFF,
072                REDSTONE_COMPARATOR_ON /* ? */ /* Repeater */, PISTON_BASE, PISTON_EXTENSION, PISTON_MOVING_PIECE,
073                PISTON_STICKY_BASE, ENDER_PORTAL_FRAME};
074    }
075}