Java 类net.minecraft.block.BlockLever.EnumOrientation 实例源码
项目:minecraft-roguelike
文件:Lever.java
public static void generate(IWorldEditor editor, Cardinal dir, Coord pos, boolean active){
MetaBlock lever = new MetaBlock(Blocks.LEVER);
lever.withProperty(BlockLever.POWERED, active);
if(dir == Cardinal.UP){
lever.withProperty(BlockLever.FACING, EnumOrientation.UP_X);
} else if(dir == Cardinal.DOWN){
lever.withProperty(BlockLever.FACING, EnumOrientation.DOWN_X);
} else {
lever.withProperty(BlockLever.FACING, Cardinal.orientation(Cardinal.reverse(dir)));
}
lever.set(editor, pos);
}
项目:MC-Prefab
文件:BuildBlock.java
private static EnumOrientation getLeverOrientation(StructureConfiguration configuration, Block foundBlock, BuildBlock block, EnumFacing assumedNorth)
{
EnumOrientation leverOrientation = EnumOrientation.NORTH;
if (foundBlock instanceof BlockLever)
{
// Levers have a special facing.
leverOrientation = BlockLever.EnumOrientation.valueOf(block.getProperty("facing").getValue().toUpperCase());
if (leverOrientation.getFacing() == EnumFacing.DOWN
|| leverOrientation.getFacing() == EnumFacing.UP)
{
if (leverOrientation.getFacing() == EnumFacing.DOWN)
{
leverOrientation =
configuration.houseFacing == assumedNorth || configuration.houseFacing == assumedNorth.getOpposite()
? leverOrientation :
leverOrientation == EnumOrientation.DOWN_X
? EnumOrientation.DOWN_Z : EnumOrientation.DOWN_X;
}
else
{
leverOrientation =
configuration.houseFacing == assumedNorth || configuration.houseFacing == assumedNorth.getOpposite()
? leverOrientation :
leverOrientation == EnumOrientation.UP_X
? EnumOrientation.UP_Z : EnumOrientation.UP_X;
}
}
else
{
EnumFacing facing = leverOrientation.getFacing();
if (configuration.houseFacing.rotateY() == assumedNorth)
{
facing = facing.rotateY();
}
else if (configuration.houseFacing.getOpposite() == assumedNorth)
{
}
else if (configuration.houseFacing.rotateYCCW() == assumedNorth)
{
facing = facing.rotateYCCW();
}
else
{
facing = facing.getOpposite();
}
for (EnumOrientation tempOrientation : EnumOrientation.values())
{
if (tempOrientation.getFacing() == facing)
{
leverOrientation = tempOrientation;
break;
}
}
}
}
return leverOrientation;
}
项目:MineChess
文件:WorldGeneratorMineChess.java
private void generateChessPuzzle(World world, Random rand, int baseX, int baseY, int baseZ){
fillWithMetadataBlocks(world, baseX - 1, baseY + 1, baseZ - 1, baseX + 8, baseY + 4, baseZ + 8, Blocks.air.getDefaultState());
fillWithMossyStone(world, baseX - 1, baseY, baseZ - 1, baseX + 8, baseY, baseZ + 8, rand);// floor, which mostly will be overwritten by the chessboard
fillWithMossyStone(world, baseX - 2, baseY, baseZ - 2, baseX + 9, baseY + 4, baseZ - 2, rand);// -Z wall
fillWithMossyStone(world, baseX - 2, baseY, baseZ + 9, baseX + 9, baseY + 4, baseZ + 9, rand);// +Z wall
fillWithMossyStone(world, baseX - 2, baseY, baseZ - 2, baseX - 2, baseY + 4, baseZ + 9, rand);// -X wall
fillWithMossyStone(world, baseX + 9, baseY, baseZ - 2, baseX + 9, baseY + 4, baseZ + 9, rand);// +X wall
fillWithMossyStone(world, baseX - 2, baseY + 5, baseZ - 2, baseX + 9, baseY + 5, baseZ + 9, rand);// roof
world.setBlockState(new BlockPos(baseX + 2, baseY + 5, baseZ + 2), Blocks.redstone_lamp.getDefaultState());
world.setBlockState(new BlockPos(baseX + 5, baseY + 5, baseZ + 2), Blocks.redstone_lamp.getDefaultState());
world.setBlockState(new BlockPos(baseX + 5, baseY + 5, baseZ + 5), Blocks.redstone_lamp.getDefaultState());
world.setBlockState(new BlockPos(baseX + 2, baseY + 5, baseZ + 5), Blocks.redstone_lamp.getDefaultState());
world.setBlockState(new BlockPos(baseX + 2, baseY + 6, baseZ + 2), Blocks.lever.getDefaultState().withProperty(BlockLever.FACING, EnumOrientation.UP_X).withProperty(BlockLever.POWERED, true));
world.setBlockState(new BlockPos(baseX + 5, baseY + 6, baseZ + 2), Blocks.lever.getDefaultState().withProperty(BlockLever.FACING, EnumOrientation.UP_X).withProperty(BlockLever.POWERED, true));
world.setBlockState(new BlockPos(baseX + 5, baseY + 6, baseZ + 5), Blocks.lever.getDefaultState().withProperty(BlockLever.FACING, EnumOrientation.UP_X).withProperty(BlockLever.POWERED, true));
world.setBlockState(new BlockPos(baseX + 2, baseY + 6, baseZ + 5), Blocks.lever.getDefaultState().withProperty(BlockLever.FACING, EnumOrientation.UP_X).withProperty(BlockLever.POWERED, true));
MineChessUtils.generateChessBoard(world, baseX, baseY, baseZ);
int randomPuzzle = rand.nextInt(2);
for(int i = 0; i < 8; i++) {
for(int j = 0; j < 8; j++) {
String pieceString = boards[randomPuzzle][7 - j][7 - i];
if(!pieceString.equals(" ")) {
EntityBaseChessPiece chessPiece;
switch(pieceString.charAt(1)){
case 'K':
chessPiece = new EntityKing(world);
break;
case 'Q':
chessPiece = new EntityQueen(world);
break;
case 'N':
chessPiece = new EntityKnight(world);
break;
case 'B':
chessPiece = new EntityBishop(world);
break;
case 'R':
chessPiece = new EntityRook(world);
break;
case 'P':
chessPiece = new EntityPawn(world);
break;
default:
continue;
}
chessPiece.setIsBlack(pieceString.charAt(0) == 'b');
chessPiece.computerPiece = pieceString.charAt(0) == 'b' == isComputerBlack[randomPuzzle];
chessPiece.isBlackTurn = !isComputerBlack[randomPuzzle];
chessPiece.setPosition((double)i + (double)baseX + 0.5D, baseY + 1.0D, (double)j + (double)baseZ + 0.5D);
chessPiece.setTargetPosition(i, j);
chessPiece.xOffset = baseX;
chessPiece.zOffset = baseZ;
chessPiece.mateInTimes = mateInTimes[randomPuzzle];
world.spawnEntityInWorld(chessPiece);
}
}
}
}