mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-06-16 18:19:55 +00:00
60 lines
2.1 KiB
Java
60 lines
2.1 KiB
Java
/*
|
|
* This file is part of ComputerCraft - http://www.computercraft.info
|
|
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
|
* Send enquiries to dratcliffe@gmail.com
|
|
*/
|
|
|
|
package dan200.computercraft.shared.computer.blocks;
|
|
|
|
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
|
import dan200.computercraft.shared.computer.core.ComputerState;
|
|
import dan200.computercraft.shared.computer.items.ComputerItemFactory;
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.BlockState;
|
|
import net.minecraft.block.entity.BlockEntityType;
|
|
import net.minecraft.item.ItemPlacementContext;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.state.StateFactory;
|
|
import net.minecraft.state.property.DirectionProperty;
|
|
import net.minecraft.state.property.EnumProperty;
|
|
import net.minecraft.state.property.Properties;
|
|
import net.minecraft.util.math.Direction;
|
|
|
|
import javax.annotation.Nonnull;
|
|
import javax.annotation.Nullable;
|
|
|
|
public class BlockComputer extends BlockComputerBase<TileComputer>
|
|
{
|
|
public static final EnumProperty<ComputerState> STATE = EnumProperty.create( "state", ComputerState.class );
|
|
public static final DirectionProperty FACING = Properties.FACING_HORIZONTAL;
|
|
|
|
public BlockComputer( Settings settings, ComputerFamily family, BlockEntityType<? extends TileComputer> type )
|
|
{
|
|
super( settings, family, type );
|
|
setDefaultState( getDefaultState()
|
|
.with( FACING, Direction.NORTH )
|
|
.with( STATE, ComputerState.OFF )
|
|
);
|
|
}
|
|
|
|
@Override
|
|
protected void appendProperties( StateFactory.Builder<Block, BlockState> builder )
|
|
{
|
|
builder.with( FACING, STATE );
|
|
}
|
|
|
|
@Nullable
|
|
@Override
|
|
public BlockState getPlacementState( ItemPlacementContext placement )
|
|
{
|
|
return getDefaultState().with( FACING, placement.getPlayerHorizontalFacing().getOpposite() );
|
|
}
|
|
|
|
@Nonnull
|
|
@Override
|
|
protected ItemStack getItem( TileComputerBase tile )
|
|
{
|
|
return tile instanceof TileComputer ? ComputerItemFactory.create( (TileComputer) tile ) : ItemStack.EMPTY;
|
|
}
|
|
}
|