Make computer rotatable.
This commit is contained in:
@@ -6,6 +6,7 @@ import li.cil.oc2.common.container.ComputerContainer;
|
||||
import li.cil.oc2.common.tile.ComputerTileEntity;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -14,21 +15,49 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class ComputerBlock extends Block {
|
||||
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
|
||||
|
||||
public ComputerBlock() {
|
||||
super(Properties.create(Material.IRON).sound(SoundType.METAL));
|
||||
setDefaultState(getStateContainer().getBaseState().with(FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(final StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(final BlockItemUseContext context) {
|
||||
return super.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(final BlockState state, final IWorld world, final BlockPos pos, final Rotation direction) {
|
||||
return state.with(FACING, direction.rotate(state.get(FACING)));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public BlockState mirror(final BlockState state, final Mirror mirrorIn) {
|
||||
return state.rotate(mirrorIn.toRotation(state.get(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,11 +82,7 @@ public final class ComputerBlock extends Block {
|
||||
final ComputerTileEntity computer = (ComputerTileEntity) tileEntity;
|
||||
if (player.isSneaking()) {
|
||||
if (!world.isRemote()) {
|
||||
if (computer.isRunning()) {
|
||||
return ActionResultType.CONSUME;
|
||||
} else {
|
||||
computer.start();
|
||||
}
|
||||
computer.start();
|
||||
}
|
||||
} else {
|
||||
final boolean openContainer = false; // TODO
|
||||
|
||||
Reference in New Issue
Block a user