Exemple #1
0
  @SuppressWarnings("deprecation")
  @Override
  public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_7_R4.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_7_R4.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
    try {
      Field f = chunk.getClass().getDeclaredField("sections");
      f.setAccessible(true);
      ChunkSection[] sections = (ChunkSection[]) f.get(chunk);
      ChunkSection chunksection = sections[b.getY() >> 4];

      if (chunksection == null) {
        chunksection =
            sections[b.getY() >> 4] =
                new ChunkSection(b.getY() >> 4 << 4, !chunk.world.worldProvider.f);
      }
      net.minecraft.server.v1_7_R4.Block mb = net.minecraft.server.v1_7_R4.Block.getById(blockId);
      chunksection.setTypeId(b.getX() & 15, b.getY() & 15, b.getZ() & 15, mb);
      chunksection.setData(b.getX() & 15, b.getY() & 15, b.getZ() & 15, data);
      if (applyPhysics) {
        w.update(b.getX(), b.getY(), b.getZ(), mb);
      }
    } catch (Exception e) {
      // Bukkit.getLogger().info("Error");
      b.setTypeIdAndData(blockId, data, applyPhysics);
    }
  }
  @Override
  public double[] fetchBounds(final int x, final int y, final int z) {
    final int id = getTypeId(x, y, z);
    final net.minecraft.server.v1_7_R4.Block block = net.minecraft.server.v1_7_R4.Block.getById(id);
    if (block == null) {
      // TODO: Convention for null bounds -> full ?
      return null;
    }
    block.updateShape(this, x, y, z);

    // minX, minY, minZ, maxX, maxY, maxZ
    return new double[] {block.x(), block.z(), block.B(), block.y(), block.A(), block.C()};
  }
Exemple #3
0
 @Override
 public int getBlockLightBlocking(int blockId) {
   return Block.getById(blockId).k();
 }
Exemple #4
0
 @Override
 public int getBlockLightEmission(int blockId) {
   return Block.getById(blockId).m();
 }
Exemple #5
0
 @Override
 public boolean setBlockFast(World world, int x, int y, int z, int blockId, byte data) {
   net.minecraft.server.v1_7_R4.World w = ((CraftWorld) world).getHandle();
   Chunk chunk = w.getChunkAt(x >> 4, z >> 4);
   return chunk.a(x & 0x0f, y, z & 0x0f, Block.getById(blockId), data);
 }