示例#1
0
 public static void CreateStairs(World world, int x, int y, int z, int id, int meta, byte m) {
   world.setBlock(x, y, z, TFCBlocks.stoneStairs.blockID, m, 0x2);
   TileEntityPartial te = (TileEntityPartial) world.getBlockTileEntity(x, y, z);
   te.TypeID = (short) id;
   te.MetaID = (byte) meta;
   te.extraData = 0;
   te.setMaterial(world.getBlockMaterial(x, y, z));
   te.validate();
 }
示例#2
0
  public static void CreateSlab(
      World world, int x, int y, int z, int id, int meta, int side, int SlabID) {
    TileEntityPartial te;

    if (world.getBlockId(x, y, z) != SlabID) {
      world.setBlock(x, y, z, SlabID, side, 0x2);

      te = (TileEntityPartial) world.getBlockTileEntity(x, y, z);
      te.TypeID = (short) id;
      te.MetaID = (byte) meta;
      te.setMaterial(world.getBlockMaterial(x, y, z));
    } else {
      te = (TileEntityPartial) world.getBlockTileEntity(x, y, z);
      world.notifyBlockChange(x, y, z, SlabID);
    }

    if (TFCOptions.enableDebugMode) {
      System.out.println(side);
    }

    long extraX = (te.extraData) & 0xf;
    long extraY = (te.extraData >> 4) & 0xf;
    long extraZ = (te.extraData >> 8) & 0xf;
    long extraX2 = (te.extraData >> 12) & 0xf;
    long extraY2 = (te.extraData >> 16) & 0xf;
    long extraZ2 = (te.extraData >> 20) & 0xf;

    if (side == 0) {
      long e = extraY + 1;
      long new1 = (extraY << 4);
      long new2 = (e << 4);
      long old2 = new2 | (te.extraData - new1);

      if (e + BlockSlab.getTopChiselLevel(te.extraData) >= 8) {
        world.setBlock(x, y, z, 0);
      } else {
        te.extraData = old2;
      }
    } else if (side == 1) {
      long e = extraY2 + 1;
      long new1 = (extraY2 << 16);
      long new2 = (e << 16);
      long old2 = new2 | (te.extraData - new1);

      if (e + BlockSlab.getBottomChiselLevel(te.extraData) >= 8) {
        world.setBlock(x, y, z, 0);
      } else {
        te.extraData = old2;
      }
    } else if (side == 2) {
      long e = extraZ + 1;
      long new1 = (extraZ << 8);
      long new2 = (e << 8);
      long old2 = new2 | (te.extraData - new1);

      if (e + BlockSlab.getSouthChiselLevel(te.extraData) >= 8) {
        world.setBlock(x, y, z, 0);
      } else {
        te.extraData = old2;
      }
    } else if (side == 3) {
      long e = extraZ2 + 1;
      long new1 = (extraZ2 << 20);
      long new2 = (e << 20);
      long old2 = new2 | (te.extraData - new1);

      if (e + BlockSlab.getNorthChiselLevel(te.extraData) >= 8) {
        world.setBlock(x, y, z, 0);
      } else {
        te.extraData = old2;
      }
    } else if (side == 4) {
      long e = extraX + 1;
      long new1 = (extraX);
      long new2 = (e);
      long old2 = new2 | (te.extraData - new1);

      if (e + BlockSlab.getEastChiselLevel(te.extraData) >= 8) {
        world.setBlock(x, y, z, 0);
      } else {
        te.extraData = old2;
      }
    } else if (side == 5) {
      long e = extraX2 + 1;
      long new1 = (extraX2 << 12);
      long new2 = (e << 12);
      long old2 = new2 | (te.extraData - new1);

      if (e + BlockSlab.getWestChiselLevel(te.extraData) >= 8) {
        world.setBlock(x, y, z, 0);
      } else {
        te.extraData = old2;
      }
    }

    if (TFCOptions.enableDebugMode) {
      System.out.println("Extra =" + te.extraData);
    }

    te = (TileEntityPartial) world.getBlockTileEntity(x, y, z);
    if (te != null) {
      te.broadcastPacketInRange(te.createUpdatePacket());
    }

    world.notifyBlocksOfNeighborChange(x, y, z, world.getBlockId(x, y, z));
  }