Esempio n. 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);
    }
  }
Esempio n. 2
0
  public static Skeleton spawn(Location location) {

    MinecraftServer server = MinecraftServer.getServer();
    WorldServer world = server.getWorldServer(0);
    for (WorldServer ws : server.worlds) {
      if (ws.getWorld().getName().equals(location.getWorld().getName())) {
        world = ws;
        break;
      }
    }
    World mcWorld = (World) ((CraftWorld) location.getWorld()).getHandle();
    final SkeletonNPC customEntity = new SkeletonNPC(world);
    customEntity.setLocation(
        location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    ((CraftLivingEntity) customEntity.getBukkitEntity()).setRemoveWhenFarAway(false);
    mcWorld.addEntity(customEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
    return (CraftSkeleton) customEntity.getBukkitEntity();
  }
Esempio n. 3
0
 @Override
 public void recalculateBlockLighting(World world, int x, int y, int z) {
   net.minecraft.server.v1_7_R4.World w = ((CraftWorld) world).getHandle();
   w.t(x, y, z);
 }
Esempio n. 4
0
 @Override
 public void forceBlockLightLevel(World world, int x, int y, int z, int level) {
   net.minecraft.server.v1_7_R4.World w = ((CraftWorld) world).getHandle();
   w.b(EnumSkyBlock.BLOCK, x, y, z, level);
 }
Esempio n. 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);
 }