2011-02-07 06:56:07 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.TreeSet;
|
|
|
|
|
2011-02-07 10:43:50 +01:00
|
|
|
// CraftBukkit start
|
2011-06-17 04:06:45 +02:00
|
|
|
import org.bukkit.Bukkit;
|
2011-06-06 22:38:35 +02:00
|
|
|
import org.bukkit.Location;
|
2011-06-17 04:06:45 +02:00
|
|
|
import org.bukkit.World.Environment;
|
2011-06-06 15:52:02 +02:00
|
|
|
import org.bukkit.generator.ChunkGenerator;
|
2011-04-26 01:47:25 +02:00
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
2011-02-07 10:43:50 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftWorld;
|
2011-03-20 21:18:38 +01:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2011-02-07 10:43:50 +01:00
|
|
|
import org.bukkit.event.block.BlockCanBuildEvent;
|
|
|
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
2011-05-02 07:48:08 +02:00
|
|
|
import org.bukkit.event.block.SnowFormEvent;
|
2011-06-17 20:48:20 +02:00
|
|
|
import org.bukkit.event.block.BlockFormEvent;
|
2011-02-17 04:42:41 +01:00
|
|
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
2011-06-11 08:00:05 +02:00
|
|
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
2011-04-26 01:47:25 +02:00
|
|
|
import org.bukkit.event.weather.WeatherChangeEvent;
|
|
|
|
import org.bukkit.event.weather.ThunderChangeEvent;
|
2011-06-17 20:48:20 +02:00
|
|
|
import org.bukkit.block.BlockState;
|
|
|
|
import org.bukkit.craftbukkit.block.CraftBlockState;
|
2011-02-07 10:43:50 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
public class World implements IBlockAccess {
|
|
|
|
|
|
|
|
public boolean a = false;
|
2011-05-26 14:48:22 +02:00
|
|
|
private List C = new ArrayList();
|
2011-04-20 19:05:14 +02:00
|
|
|
public List entityList = new ArrayList();
|
2011-05-26 14:48:22 +02:00
|
|
|
private List D = new ArrayList();
|
|
|
|
private TreeSet E = new TreeSet();
|
|
|
|
private Set F = new HashSet();
|
2011-02-07 06:56:07 +01:00
|
|
|
public List c = new ArrayList();
|
2011-04-20 19:05:14 +02:00
|
|
|
public List players = new ArrayList();
|
2011-04-20 22:47:26 +02:00
|
|
|
public List e = new ArrayList();
|
2011-05-26 14:48:22 +02:00
|
|
|
private long G = 16777215L;
|
2011-04-20 22:47:26 +02:00
|
|
|
public int f = 0;
|
|
|
|
protected int g = (new Random()).nextInt();
|
|
|
|
protected int h = 1013904223;
|
2011-05-26 14:48:22 +02:00
|
|
|
protected float i;
|
|
|
|
protected float j;
|
|
|
|
protected float k;
|
|
|
|
protected float l;
|
|
|
|
protected int m = 0;
|
|
|
|
public int n = 0;
|
|
|
|
public boolean o = false;
|
|
|
|
private long H = System.currentTimeMillis();
|
|
|
|
protected int p = 40;
|
2011-04-20 19:05:14 +02:00
|
|
|
public int spawnMonsters;
|
|
|
|
public Random random = new Random();
|
2011-05-26 14:48:22 +02:00
|
|
|
public boolean s = false;
|
2011-06-12 00:02:58 +02:00
|
|
|
public WorldProvider worldProvider; // CraftBukkit - remove final
|
2011-05-26 14:48:22 +02:00
|
|
|
protected List u = new ArrayList();
|
2011-05-14 16:29:42 +02:00
|
|
|
public IChunkProvider chunkProvider; // CraftBukkit - protected -> public
|
2011-05-26 14:48:22 +02:00
|
|
|
protected final IDataManager w;
|
2011-05-14 16:29:42 +02:00
|
|
|
public WorldData worldData; // CraftBukkit - protected -> public
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isLoading;
|
2011-05-26 14:48:22 +02:00
|
|
|
private boolean I;
|
|
|
|
public WorldMapCollection z;
|
|
|
|
private ArrayList J = new ArrayList();
|
|
|
|
private int K = 0;
|
2011-05-14 16:29:42 +02:00
|
|
|
public boolean allowMonsters = true; // CraftBukkit - private -> public
|
|
|
|
public boolean allowAnimals = true; // CraftBukkit - private -> public
|
2011-05-26 14:48:22 +02:00
|
|
|
static int A = 0;
|
|
|
|
private Set N = new HashSet();
|
|
|
|
private int O;
|
|
|
|
private List P;
|
2011-02-07 06:56:07 +01:00
|
|
|
public boolean isStatic;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public WorldChunkManager getWorldChunkManager() {
|
|
|
|
return this.worldProvider.b;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-06-12 00:02:58 +02:00
|
|
|
// CraftBukkit start
|
2011-06-17 04:06:45 +02:00
|
|
|
private final CraftWorld world;
|
2011-06-12 00:02:58 +02:00
|
|
|
public boolean pvpMode;
|
|
|
|
public ChunkGenerator generator;
|
|
|
|
Chunk lastChunkAccessed;
|
|
|
|
int lastXAccessed = Integer.MIN_VALUE;
|
|
|
|
int lastZAccessed = Integer.MIN_VALUE;
|
|
|
|
final Object chunkLock = new Object();
|
|
|
|
|
|
|
|
private boolean canSpawn(int x, int z) {
|
|
|
|
if (generator != null) {
|
|
|
|
return this.generator.canSpawn(((WorldServer) this).getWorld(), x, z);
|
|
|
|
} else {
|
|
|
|
return this.worldProvider.a(x, z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-17 04:06:45 +02:00
|
|
|
public CraftWorld getWorld() {
|
|
|
|
return world;
|
|
|
|
}
|
|
|
|
|
|
|
|
public CraftServer getServer() {
|
|
|
|
return (CraftServer)Bukkit.getServer();
|
|
|
|
}
|
|
|
|
|
2011-06-12 00:02:58 +02:00
|
|
|
// CraftBukkit - changed signature
|
2011-06-17 04:06:45 +02:00
|
|
|
public World(IDataManager idatamanager, String s, long i, WorldProvider worldprovider, ChunkGenerator gen, Environment env) {
|
2011-06-06 15:52:02 +02:00
|
|
|
this.generator = gen;
|
2011-06-17 04:06:45 +02:00
|
|
|
this.world = new CraftWorld((WorldServer)this, gen, env);
|
2011-06-12 00:02:58 +02:00
|
|
|
// CraftBukkit end
|
2011-06-06 15:52:02 +02:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.O = this.random.nextInt(12000);
|
|
|
|
this.P = new ArrayList();
|
2011-02-07 06:56:07 +01:00
|
|
|
this.isStatic = false;
|
2011-05-26 14:48:22 +02:00
|
|
|
this.w = idatamanager;
|
|
|
|
this.z = new WorldMapCollection(idatamanager);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.worldData = idatamanager.c();
|
2011-05-26 14:48:22 +02:00
|
|
|
this.s = this.worldData == null;
|
2011-02-07 06:56:07 +01:00
|
|
|
if (worldprovider != null) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.worldProvider = worldprovider;
|
|
|
|
} else if (this.worldData != null && this.worldData.h() == -1) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.worldProvider = WorldProvider.a(-1);
|
2011-02-23 03:37:56 +01:00
|
|
|
} else {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.worldProvider = WorldProvider.a(0);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
boolean flag = false;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.worldData == null) {
|
|
|
|
this.worldData = new WorldData(i, s);
|
2011-02-07 06:56:07 +01:00
|
|
|
flag = true;
|
2011-02-23 03:37:56 +01:00
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.worldData.a(s);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.worldProvider.a(this);
|
|
|
|
this.chunkProvider = this.b();
|
2011-02-07 06:56:07 +01:00
|
|
|
if (flag) {
|
2011-03-31 22:40:00 +02:00
|
|
|
this.c();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
this.g();
|
2011-04-20 22:47:26 +02:00
|
|
|
this.x();
|
2011-06-17 04:06:45 +02:00
|
|
|
|
|
|
|
getServer().addWorld(world);// Craftbukkit
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
protected IChunkProvider b() {
|
2011-05-26 14:48:22 +02:00
|
|
|
IChunkLoader ichunkloader = this.w.a(this.worldProvider);
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
return new ChunkProviderLoadOrGenerate(this, ichunkloader, this.worldProvider.b());
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
protected void c() {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.isLoading = true;
|
2011-03-31 22:40:00 +02:00
|
|
|
int i = 0;
|
|
|
|
byte b0 = 64;
|
|
|
|
|
|
|
|
int j;
|
|
|
|
|
2011-06-12 00:02:58 +02:00
|
|
|
// CraftBukkit start
|
2011-06-06 22:38:35 +02:00
|
|
|
if (generator != null) {
|
|
|
|
Random rand = new Random(getSeed());
|
2011-06-12 00:02:58 +02:00
|
|
|
Location spawn = generator.getFixedSpawnLocation(((WorldServer) this).getWorld(), rand);
|
|
|
|
|
2011-06-06 22:38:35 +02:00
|
|
|
if (spawn != null) {
|
2011-06-12 00:02:58 +02:00
|
|
|
if (spawn.getWorld() != ((WorldServer) this).getWorld()) {
|
2011-06-06 22:38:35 +02:00
|
|
|
throw new IllegalStateException("Cannot set spawn point for " + worldData.name + " to be in another world (" + spawn.getWorld().getName() + ")");
|
|
|
|
} else {
|
|
|
|
worldData.setSpawn(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
|
|
|
|
isLoading = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-06 15:52:02 +02:00
|
|
|
for (j = 0; !canSpawn(i, j); j += this.random.nextInt(64) - this.random.nextInt(64)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
i += this.random.nextInt(64) - this.random.nextInt(64);
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
2011-06-12 00:02:58 +02:00
|
|
|
// CraftBukkit end
|
2011-03-31 22:40:00 +02:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.worldData.setSpawn(i, b0, j);
|
|
|
|
this.isLoading = false;
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
public int a(int i, int j) {
|
|
|
|
int k;
|
|
|
|
|
|
|
|
for (k = 63; !this.isEmpty(i, k + 1, j); ++k) {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.getTypeId(i, k, j);
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void save(boolean flag, IProgressUpdate iprogressupdate) {
|
|
|
|
if (this.chunkProvider.b()) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (iprogressupdate != null) {
|
|
|
|
iprogressupdate.a("Saving level");
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
this.w();
|
2011-02-07 06:56:07 +01:00
|
|
|
if (iprogressupdate != null) {
|
|
|
|
iprogressupdate.b("Saving chunks");
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.chunkProvider.saveChunks(flag, iprogressupdate);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
private void w() {
|
|
|
|
this.k();
|
2011-05-26 14:48:22 +02:00
|
|
|
this.w.a(this.worldData, this.players);
|
|
|
|
this.z.a();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getTypeId(int i, int j, int k) {
|
2011-04-20 19:05:14 +02:00
|
|
|
return i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000 ? (j < 0 ? 0 : (j >= 128 ? 0 : this.getChunkAt(i >> 4, k >> 4).getTypeId(i & 15, j, k & 15))) : 0;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isEmpty(int i, int j, int k) {
|
|
|
|
return this.getTypeId(i, j, k) == 0;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isLoaded(int i, int j, int k) {
|
|
|
|
return j >= 0 && j < 128 ? this.isChunkLoaded(i >> 4, k >> 4) : false;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(int i, int j, int k, int l) {
|
|
|
|
return this.a(i - l, j - l, k - l, i + l, j + l, k + l);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(int i, int j, int k, int l, int i1, int j1) {
|
|
|
|
if (i1 >= 0 && j < 128) {
|
|
|
|
i >>= 4;
|
|
|
|
j >>= 4;
|
|
|
|
k >>= 4;
|
|
|
|
l >>= 4;
|
|
|
|
i1 >>= 4;
|
|
|
|
j1 >>= 4;
|
|
|
|
|
|
|
|
for (int k1 = i; k1 <= l; ++k1) {
|
|
|
|
for (int l1 = k; l1 <= j1; ++l1) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!this.isChunkLoaded(k1, l1)) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
private boolean isChunkLoaded(int i, int j) {
|
|
|
|
return this.chunkProvider.isChunkLoaded(i, j);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Chunk b(int i, int j) {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.getChunkAt(i >> 4, j >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-02-07 09:43:51 +01:00
|
|
|
// CraftBukkit start
|
2011-04-20 19:05:14 +02:00
|
|
|
public Chunk getChunkAt(int i, int j) {
|
2011-02-10 12:56:30 +01:00
|
|
|
Chunk result = null;
|
|
|
|
synchronized (chunkLock) {
|
|
|
|
if (lastChunkAccessed == null || lastXAccessed != i || lastZAccessed != j) {
|
|
|
|
lastXAccessed = i;
|
|
|
|
lastZAccessed = j;
|
2011-04-20 19:05:14 +02:00
|
|
|
lastChunkAccessed = this.chunkProvider.getOrCreateChunk(i, j);
|
2011-02-10 12:56:30 +01:00
|
|
|
}
|
|
|
|
result = lastChunkAccessed;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
2011-02-10 12:56:30 +01:00
|
|
|
return result;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
2011-02-07 09:43:51 +01:00
|
|
|
// CraftBukkit end
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean setRawTypeIdAndData(int i, int j, int k, int l, int i1) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) {
|
|
|
|
if (j < 0) {
|
|
|
|
return false;
|
|
|
|
} else if (j >= 128) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
return chunk.a(i & 15, j, k & 15, l, i1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean setRawTypeId(int i, int j, int k, int l) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) {
|
|
|
|
if (j < 0) {
|
|
|
|
return false;
|
|
|
|
} else if (j >= 128) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
return chunk.a(i & 15, j, k & 15, l);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Material getMaterial(int i, int j, int k) {
|
|
|
|
int l = this.getTypeId(i, j, k);
|
|
|
|
|
|
|
|
return l == 0 ? Material.AIR : Block.byId[l].material;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getData(int i, int j, int k) {
|
|
|
|
if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) {
|
|
|
|
if (j < 0) {
|
|
|
|
return 0;
|
|
|
|
} else if (j >= 128) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
i &= 15;
|
|
|
|
k &= 15;
|
2011-04-20 19:05:14 +02:00
|
|
|
return chunk.getData(i, j, k);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void setData(int i, int j, int k, int l) {
|
|
|
|
if (this.setRawData(i, j, k, l)) {
|
2011-05-26 14:48:22 +02:00
|
|
|
int i1 = this.getTypeId(i, j, k);
|
|
|
|
|
2011-05-28 22:50:08 +02:00
|
|
|
if (Block.t[i1 & 255]) {
|
|
|
|
this.update(i, j, k, i1);
|
|
|
|
} else {
|
|
|
|
this.applyPhysics(i, j, k, i1);
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean setRawData(int i, int j, int k, int l) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) {
|
|
|
|
if (j < 0) {
|
|
|
|
return false;
|
|
|
|
} else if (j >= 128) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
i &= 15;
|
|
|
|
k &= 15;
|
|
|
|
chunk.b(i, j, k, l);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean setTypeId(int i, int j, int k, int l) {
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit start
|
2011-03-14 05:47:41 +01:00
|
|
|
int old = this.getTypeId(i, j, k);
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.setRawTypeId(i, j, k, l)) {
|
|
|
|
this.update(i, j, k, l == 0 ? old : l);
|
2011-02-07 06:56:07 +01:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit end
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean setTypeIdAndData(int i, int j, int k, int l, int i1) {
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit start
|
2011-03-14 05:47:41 +01:00
|
|
|
int old = this.getTypeId(i, j, k);
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.setRawTypeIdAndData(i, j, k, l, i1)) {
|
|
|
|
this.update(i, j, k, l == 0 ? old : l);
|
2011-02-07 06:56:07 +01:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit end
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void notify(int i, int j, int k) {
|
2011-05-26 14:48:22 +02:00
|
|
|
for (int l = 0; l < this.u.size(); ++l) {
|
|
|
|
((IWorldAccess) this.u.get(l)).a(i, j, k);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
protected void update(int i, int j, int k, int l) {
|
|
|
|
this.notify(i, j, k);
|
|
|
|
this.applyPhysics(i, j, k, l);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void g(int i, int j, int k, int l) {
|
|
|
|
if (k > l) {
|
|
|
|
int i1 = l;
|
|
|
|
|
|
|
|
l = k;
|
|
|
|
k = i1;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.b(i, k, j, i, l, j);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void h(int i, int j, int k) {
|
2011-05-26 14:48:22 +02:00
|
|
|
for (int l = 0; l < this.u.size(); ++l) {
|
|
|
|
((IWorldAccess) this.u.get(l)).a(i, j, k, i, j, k);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(int i, int j, int k, int l, int i1, int j1) {
|
2011-05-26 14:48:22 +02:00
|
|
|
for (int k1 = 0; k1 < this.u.size(); ++k1) {
|
|
|
|
((IWorldAccess) this.u.get(k1)).a(i, j, k, l, i1, j1);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void applyPhysics(int i, int j, int k, int l) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.k(i - 1, j, k, l);
|
|
|
|
this.k(i + 1, j, k, l);
|
|
|
|
this.k(i, j - 1, k, l);
|
|
|
|
this.k(i, j + 1, k, l);
|
|
|
|
this.k(i, j, k - 1, l);
|
|
|
|
this.k(i, j, k + 1, l);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
private void k(int i, int j, int k, int l) {
|
2011-05-26 14:48:22 +02:00
|
|
|
if (!this.o && !this.isStatic) {
|
2011-02-07 06:56:07 +01:00
|
|
|
Block block = Block.byId[this.getTypeId(i, j, k)];
|
|
|
|
|
|
|
|
if (block != null) {
|
2011-02-07 10:26:12 +01:00
|
|
|
// CraftBukkit start
|
2011-02-07 10:43:50 +01:00
|
|
|
CraftWorld world = ((WorldServer) this).getWorld();
|
2011-02-07 10:26:12 +01:00
|
|
|
if (world != null) {
|
2011-03-26 22:32:56 +01:00
|
|
|
BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(i, j, k), l);
|
2011-06-17 04:06:45 +02:00
|
|
|
getServer().getPluginManager().callEvent(event);
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-02-07 10:26:12 +01:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit end
|
2011-02-07 10:26:12 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
block.doPhysics(this, i, j, k, l);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isChunkLoaded(int i, int j, int k) {
|
|
|
|
return this.getChunkAt(i >> 4, k >> 4).c(i & 15, j, k & 15);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public int j(int i, int j, int k) {
|
|
|
|
if (j < 0) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
if (j >= 128) {
|
|
|
|
j = 127;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.getChunkAt(i >> 4, k >> 4).c(i & 15, j, k & 15, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public int getLightLevel(int i, int j, int k) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return this.a(i, j, k, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a(int i, int j, int k, boolean flag) {
|
|
|
|
if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) {
|
|
|
|
if (flag) {
|
2011-05-26 14:48:22 +02:00
|
|
|
int l = this.getTypeId(i, j, k);
|
|
|
|
|
|
|
|
if (l == Block.STEP.id || l == Block.SOIL.id || l == Block.COBBLESTONE_STAIRS.id || l == Block.WOOD_STAIRS.id) {
|
2011-02-07 06:56:07 +01:00
|
|
|
int i1 = this.a(i, j + 1, k, false);
|
|
|
|
int j1 = this.a(i + 1, j, k, false);
|
|
|
|
int k1 = this.a(i - 1, j, k, false);
|
|
|
|
int l1 = this.a(i, j, k + 1, false);
|
|
|
|
int i2 = this.a(i, j, k - 1, false);
|
|
|
|
|
|
|
|
if (j1 > i1) {
|
|
|
|
i1 = j1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (k1 > i1) {
|
|
|
|
i1 = k1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l1 > i1) {
|
|
|
|
i1 = l1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i2 > i1) {
|
|
|
|
i1 = i2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j < 0) {
|
|
|
|
return 0;
|
2011-05-26 14:48:22 +02:00
|
|
|
} else {
|
|
|
|
if (j >= 128) {
|
|
|
|
j = 127;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
i &= 15;
|
|
|
|
k &= 15;
|
2011-04-20 22:47:26 +02:00
|
|
|
return chunk.c(i, j, k, this.f);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return 15;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public boolean l(int i, int j, int k) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) {
|
|
|
|
if (j < 0) {
|
|
|
|
return false;
|
|
|
|
} else if (j >= 128) {
|
|
|
|
return true;
|
2011-04-20 19:05:14 +02:00
|
|
|
} else if (!this.isChunkLoaded(i >> 4, k >> 4)) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
i &= 15;
|
|
|
|
k &= 15;
|
|
|
|
return chunk.c(i, j, k);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public int getHighestBlockYAt(int i, int j) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (i >= -32000000 && j >= -32000000 && i < 32000000 && j <= 32000000) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!this.isChunkLoaded(i >> 4, j >> 4)) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return 0;
|
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, j >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
return chunk.b(i & 15, j & 15);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!this.worldProvider.e || enumskyblock != EnumSkyBlock.SKY) {
|
|
|
|
if (this.isLoaded(i, j, k)) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (enumskyblock == EnumSkyBlock.SKY) {
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.l(i, j, k)) {
|
2011-02-07 06:56:07 +01:00
|
|
|
l = 15;
|
|
|
|
}
|
|
|
|
} else if (enumskyblock == EnumSkyBlock.BLOCK) {
|
|
|
|
int i1 = this.getTypeId(i, j, k);
|
|
|
|
|
|
|
|
if (Block.s[i1] > l) {
|
|
|
|
l = Block.s[i1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.a(enumskyblock, i, j, k) != l) {
|
|
|
|
this.a(enumskyblock, i, j, k, i, j, k);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a(EnumSkyBlock enumskyblock, int i, int j, int k) {
|
2011-05-26 14:48:22 +02:00
|
|
|
if (j < 0) {
|
|
|
|
j = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j >= 128) {
|
|
|
|
j = 127;
|
|
|
|
}
|
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
if (j >= 0 && j < 128 && i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) {
|
|
|
|
int l = i >> 4;
|
|
|
|
int i1 = k >> 4;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!this.isChunkLoaded(l, i1)) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return 0;
|
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(l, i1);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
return chunk.a(enumskyblock, i & 15, j, k & 15);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return enumskyblock.c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(EnumSkyBlock enumskyblock, int i, int j, int k, int l) {
|
|
|
|
if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) {
|
|
|
|
if (j >= 0) {
|
|
|
|
if (j < 128) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.isChunkLoaded(i >> 4, k >> 4)) {
|
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
chunk.a(enumskyblock, i & 15, j, k & 15, l);
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
for (int i1 = 0; i1 < this.u.size(); ++i1) {
|
|
|
|
((IWorldAccess) this.u.get(i1)).a(i, j, k);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public float m(int i, int j, int k) {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.worldProvider.f[this.getLightLevel(i, j, k)];
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public boolean d() {
|
2011-04-20 22:47:26 +02:00
|
|
|
return this.f < 4;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public MovingObjectPosition a(Vec3D vec3d, Vec3D vec3d1) {
|
2011-05-26 14:48:22 +02:00
|
|
|
return this.rayTrace(vec3d, vec3d1, false, false);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public MovingObjectPosition rayTrace(Vec3D vec3d, Vec3D vec3d1, boolean flag) {
|
2011-05-26 14:48:22 +02:00
|
|
|
return this.rayTrace(vec3d, vec3d1, flag, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public MovingObjectPosition rayTrace(Vec3D vec3d, Vec3D vec3d1, boolean flag, boolean flag1) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (!Double.isNaN(vec3d.a) && !Double.isNaN(vec3d.b) && !Double.isNaN(vec3d.c)) {
|
|
|
|
if (!Double.isNaN(vec3d1.a) && !Double.isNaN(vec3d1.b) && !Double.isNaN(vec3d1.c)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(vec3d1.a);
|
|
|
|
int j = MathHelper.floor(vec3d1.b);
|
|
|
|
int k = MathHelper.floor(vec3d1.c);
|
|
|
|
int l = MathHelper.floor(vec3d.a);
|
|
|
|
int i1 = MathHelper.floor(vec3d.b);
|
|
|
|
int j1 = MathHelper.floor(vec3d.c);
|
2011-05-26 14:48:22 +02:00
|
|
|
int k1 = this.getTypeId(l, i1, j1);
|
|
|
|
int l1 = this.getData(l, i1, j1);
|
|
|
|
Block block = Block.byId[k1];
|
|
|
|
|
|
|
|
if ((!flag1 || block == null || block.d(this, l, i1, j1) != null) && k1 > 0 && block.a(l1, flag)) {
|
|
|
|
MovingObjectPosition movingobjectposition = block.a(this, l, i1, j1, vec3d, vec3d1);
|
|
|
|
|
|
|
|
if (movingobjectposition != null) {
|
|
|
|
return movingobjectposition;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
k1 = 200;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
while (k1-- >= 0) {
|
|
|
|
if (Double.isNaN(vec3d.a) || Double.isNaN(vec3d.b) || Double.isNaN(vec3d.c)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == i && i1 == j && j1 == k) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
boolean flag2 = true;
|
|
|
|
boolean flag3 = true;
|
|
|
|
boolean flag4 = true;
|
2011-02-07 06:56:07 +01:00
|
|
|
double d0 = 999.0D;
|
|
|
|
double d1 = 999.0D;
|
|
|
|
double d2 = 999.0D;
|
|
|
|
|
|
|
|
if (i > l) {
|
|
|
|
d0 = (double) l + 1.0D;
|
2011-05-26 14:48:22 +02:00
|
|
|
} else if (i < l) {
|
2011-02-07 06:56:07 +01:00
|
|
|
d0 = (double) l + 0.0D;
|
2011-05-26 14:48:22 +02:00
|
|
|
} else {
|
|
|
|
flag2 = false;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (j > i1) {
|
|
|
|
d1 = (double) i1 + 1.0D;
|
2011-05-26 14:48:22 +02:00
|
|
|
} else if (j < i1) {
|
2011-02-07 06:56:07 +01:00
|
|
|
d1 = (double) i1 + 0.0D;
|
2011-05-26 14:48:22 +02:00
|
|
|
} else {
|
|
|
|
flag3 = false;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (k > j1) {
|
|
|
|
d2 = (double) j1 + 1.0D;
|
2011-05-26 14:48:22 +02:00
|
|
|
} else if (k < j1) {
|
2011-02-07 06:56:07 +01:00
|
|
|
d2 = (double) j1 + 0.0D;
|
2011-05-26 14:48:22 +02:00
|
|
|
} else {
|
|
|
|
flag4 = false;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
double d3 = 999.0D;
|
|
|
|
double d4 = 999.0D;
|
|
|
|
double d5 = 999.0D;
|
|
|
|
double d6 = vec3d1.a - vec3d.a;
|
|
|
|
double d7 = vec3d1.b - vec3d.b;
|
|
|
|
double d8 = vec3d1.c - vec3d.c;
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (flag2) {
|
2011-02-07 06:56:07 +01:00
|
|
|
d3 = (d0 - vec3d.a) / d6;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (flag3) {
|
2011-02-07 06:56:07 +01:00
|
|
|
d4 = (d1 - vec3d.b) / d7;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (flag4) {
|
2011-02-07 06:56:07 +01:00
|
|
|
d5 = (d2 - vec3d.c) / d8;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
boolean flag5 = false;
|
2011-02-07 06:56:07 +01:00
|
|
|
byte b0;
|
|
|
|
|
|
|
|
if (d3 < d4 && d3 < d5) {
|
|
|
|
if (i > l) {
|
|
|
|
b0 = 4;
|
|
|
|
} else {
|
|
|
|
b0 = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3d.a = d0;
|
|
|
|
vec3d.b += d7 * d3;
|
|
|
|
vec3d.c += d8 * d3;
|
|
|
|
} else if (d4 < d5) {
|
|
|
|
if (j > i1) {
|
|
|
|
b0 = 0;
|
|
|
|
} else {
|
|
|
|
b0 = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3d.a += d6 * d4;
|
|
|
|
vec3d.b = d1;
|
|
|
|
vec3d.c += d8 * d4;
|
|
|
|
} else {
|
|
|
|
if (k > j1) {
|
|
|
|
b0 = 2;
|
|
|
|
} else {
|
|
|
|
b0 = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3d.a += d6 * d5;
|
|
|
|
vec3d.b += d7 * d5;
|
|
|
|
vec3d.c = d2;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
Vec3D vec3d2 = Vec3D.create(vec3d.a, vec3d.b, vec3d.c);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
l = (int) (vec3d2.a = (double) MathHelper.floor(vec3d.a));
|
2011-02-07 06:56:07 +01:00
|
|
|
if (b0 == 5) {
|
|
|
|
--l;
|
|
|
|
++vec3d2.a;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
i1 = (int) (vec3d2.b = (double) MathHelper.floor(vec3d.b));
|
2011-02-07 06:56:07 +01:00
|
|
|
if (b0 == 1) {
|
|
|
|
--i1;
|
|
|
|
++vec3d2.b;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
j1 = (int) (vec3d2.c = (double) MathHelper.floor(vec3d.c));
|
2011-02-07 06:56:07 +01:00
|
|
|
if (b0 == 3) {
|
|
|
|
--j1;
|
|
|
|
++vec3d2.c;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
int i2 = this.getTypeId(l, i1, j1);
|
|
|
|
int j2 = this.getData(l, i1, j1);
|
|
|
|
Block block1 = Block.byId[i2];
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if ((!flag1 || block1 == null || block1.d(this, l, i1, j1) != null) && i2 > 0 && block1.a(j2, flag)) {
|
|
|
|
MovingObjectPosition movingobjectposition1 = block1.a(this, l, i1, j1, vec3d, vec3d1);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (movingobjectposition1 != null) {
|
|
|
|
return movingobjectposition1;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void makeSound(Entity entity, String s, float f, float f1) {
|
2011-05-26 14:48:22 +02:00
|
|
|
for (int i = 0; i < this.u.size(); ++i) {
|
|
|
|
((IWorldAccess) this.u.get(i)).a(s, entity.locX, entity.locY - (double) entity.height, entity.locZ, f, f1);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void makeSound(double d0, double d1, double d2, String s, float f, float f1) {
|
2011-05-26 14:48:22 +02:00
|
|
|
for (int i = 0; i < this.u.size(); ++i) {
|
|
|
|
((IWorldAccess) this.u.get(i)).a(s, d0, d1, d2, f, f1);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(String s, int i, int j, int k) {
|
2011-05-26 14:48:22 +02:00
|
|
|
for (int l = 0; l < this.u.size(); ++l) {
|
|
|
|
((IWorldAccess) this.u.get(l)).a(s, i, j, k);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(String s, double d0, double d1, double d2, double d3, double d4, double d5) {
|
2011-05-26 14:48:22 +02:00
|
|
|
for (int i = 0; i < this.u.size(); ++i) {
|
|
|
|
((IWorldAccess) this.u.get(i)).a(s, d0, d1, d2, d3, d4, d5);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public boolean a(Entity entity) {
|
|
|
|
this.e.add(entity);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean addEntity(Entity entity) {
|
|
|
|
int i = MathHelper.floor(entity.locX / 16.0D);
|
|
|
|
int j = MathHelper.floor(entity.locZ / 16.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
boolean flag = false;
|
|
|
|
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
flag = true;
|
|
|
|
}
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start
|
2011-04-01 09:15:48 +02:00
|
|
|
if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
|
2011-03-20 21:18:38 +01:00
|
|
|
CreatureSpawnEvent event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity);
|
2011-06-12 00:02:58 +02:00
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-06-11 08:00:05 +02:00
|
|
|
} else if (entity instanceof EntityItem) {
|
|
|
|
ItemSpawnEvent event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
|
2011-03-20 21:18:38 +01:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
return false;
|
2011-02-17 04:42:41 +01:00
|
|
|
}
|
|
|
|
}
|
2011-06-09 23:05:56 +02:00
|
|
|
|
|
|
|
if (entity instanceof EntityLiving && entity instanceof EntityWaterAnimal && !this.allowAnimals) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
// CraftBukkit end
|
2011-02-17 04:42:41 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!flag && !this.isChunkLoaded(i, j)) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) entity;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.players.add(entityhuman);
|
|
|
|
this.everyoneSleeping();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.getChunkAt(i, j).a(entity);
|
|
|
|
this.entityList.add(entity);
|
2011-04-20 22:47:26 +02:00
|
|
|
this.c(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected void c(Entity entity) {
|
2011-05-26 14:48:22 +02:00
|
|
|
for (int i = 0; i < this.u.size(); ++i) {
|
|
|
|
((IWorldAccess) this.u.get(i)).a(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected void d(Entity entity) {
|
2011-05-26 14:48:22 +02:00
|
|
|
for (int i = 0; i < this.u.size(); ++i) {
|
|
|
|
((IWorldAccess) this.u.get(i)).b(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void kill(Entity entity) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (entity.passenger != null) {
|
2011-04-20 19:05:14 +02:00
|
|
|
entity.passenger.mount((Entity) null);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (entity.vehicle != null) {
|
2011-04-20 19:05:14 +02:00
|
|
|
entity.mount((Entity) null);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
entity.die();
|
2011-02-07 06:56:07 +01:00
|
|
|
if (entity instanceof EntityHuman) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.players.remove((EntityHuman) entity);
|
|
|
|
this.everyoneSleeping();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void removeEntity(Entity entity) {
|
|
|
|
entity.die();
|
2011-02-07 06:56:07 +01:00
|
|
|
if (entity instanceof EntityHuman) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.players.remove((EntityHuman) entity);
|
|
|
|
this.everyoneSleeping();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-05-28 22:50:08 +02:00
|
|
|
int i = entity.bG;
|
|
|
|
int j = entity.bI;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-05-28 22:50:08 +02:00
|
|
|
if (entity.bF && this.isChunkLoaded(i, j)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.getChunkAt(i, j).b(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.entityList.remove(entity);
|
2011-04-20 22:47:26 +02:00
|
|
|
this.d(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void addIWorldAccess(IWorldAccess iworldaccess) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.u.add(iworldaccess);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public List getEntities(Entity entity, AxisAlignedBB axisalignedbb) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.J.clear();
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
for (int k1 = i; k1 < j; ++k1) {
|
|
|
|
for (int l1 = i1; l1 < j1; ++l1) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.isLoaded(k1, 64, l1)) {
|
2011-02-07 06:56:07 +01:00
|
|
|
for (int i2 = k - 1; i2 < l; ++i2) {
|
|
|
|
Block block = Block.byId[this.getTypeId(k1, i2, l1)];
|
|
|
|
|
|
|
|
if (block != null) {
|
2011-05-26 14:48:22 +02:00
|
|
|
block.a(this, k1, i2, l1, axisalignedbb, this.J);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double d0 = 0.25D;
|
|
|
|
List list = this.b(entity, axisalignedbb.b(d0, d0, d0));
|
|
|
|
|
|
|
|
for (int j2 = 0; j2 < list.size(); ++j2) {
|
2011-04-20 22:47:26 +02:00
|
|
|
AxisAlignedBB axisalignedbb1 = ((Entity) list.get(j2)).e_();
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.J.add(axisalignedbb1);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
axisalignedbb1 = entity.a_((Entity) list.get(j2));
|
2011-02-07 06:56:07 +01:00
|
|
|
if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.J.add(axisalignedbb1);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
return this.J;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int a(float f) {
|
|
|
|
float f1 = this.b(f);
|
2011-04-20 19:05:14 +02:00
|
|
|
float f2 = 1.0F - (MathHelper.cos(f1 * 3.1415927F * 2.0F) * 2.0F + 0.5F);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
if (f2 < 0.0F) {
|
|
|
|
f2 = 0.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (f2 > 1.0F) {
|
|
|
|
f2 = 1.0F;
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
f2 = 1.0F - f2;
|
|
|
|
f2 = (float) ((double) f2 * (1.0D - (double) (this.d(f) * 5.0F) / 16.0D));
|
|
|
|
f2 = (float) ((double) f2 * (1.0D - (double) (this.c(f) * 5.0F) / 16.0D));
|
|
|
|
f2 = 1.0F - f2;
|
2011-02-07 06:56:07 +01:00
|
|
|
return (int) (f2 * 11.0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
public float b(float f) {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.worldProvider.a(this.worldData.f(), f);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int e(int i, int j) {
|
|
|
|
Chunk chunk = this.b(i, j);
|
2011-04-20 22:47:26 +02:00
|
|
|
int k = 127;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
i &= 15;
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
for (j &= 15; k > 0; --k) {
|
|
|
|
int l = chunk.getTypeId(i, k, j);
|
|
|
|
Material material = l == 0 ? Material.AIR : Block.byId[l].material;
|
|
|
|
|
|
|
|
if (material.isSolid() || material.isLiquid()) {
|
|
|
|
return k + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int f(int i, int j) {
|
|
|
|
Chunk chunk = this.b(i, j);
|
|
|
|
int k = 127;
|
|
|
|
|
|
|
|
i &= 15;
|
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
for (j &= 15; k > 0; --k) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int l = chunk.getTypeId(i, k, j);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (l != 0 && Block.byId[l].material.isSolid()) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return k + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void c(int i, int j, int k, int l, int i1) {
|
2011-02-07 06:56:07 +01:00
|
|
|
NextTickListEntry nextticklistentry = new NextTickListEntry(i, j, k, l);
|
|
|
|
byte b0 = 8;
|
|
|
|
|
|
|
|
if (this.a) {
|
|
|
|
if (this.a(nextticklistentry.a - b0, nextticklistentry.b - b0, nextticklistentry.c - b0, nextticklistentry.a + b0, nextticklistentry.b + b0, nextticklistentry.c + b0)) {
|
2011-02-23 03:37:56 +01:00
|
|
|
int j1 = this.getTypeId(nextticklistentry.a, nextticklistentry.b, nextticklistentry.c);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (j1 == nextticklistentry.d && j1 > 0) {
|
2011-04-20 19:05:14 +02:00
|
|
|
Block.byId[j1].a(this, nextticklistentry.a, nextticklistentry.b, nextticklistentry.c, this.random);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (this.a(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) {
|
|
|
|
if (l > 0) {
|
2011-04-20 19:05:14 +02:00
|
|
|
nextticklistentry.a((long) i1 + this.worldData.f());
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (!this.F.contains(nextticklistentry)) {
|
|
|
|
this.F.add(nextticklistentry);
|
|
|
|
this.E.add(nextticklistentry);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void cleanUp() {
|
2011-02-07 06:56:07 +01:00
|
|
|
int i;
|
|
|
|
Entity entity;
|
2011-04-20 22:47:26 +02:00
|
|
|
|
|
|
|
for (i = 0; i < this.e.size(); ++i) {
|
|
|
|
entity = (Entity) this.e.get(i);
|
2011-06-18 05:36:35 +02:00
|
|
|
// CraftBukkit start - fixed an NPE
|
|
|
|
if (entity == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-05-28 22:50:08 +02:00
|
|
|
entity.o_();
|
2011-04-20 22:47:26 +02:00
|
|
|
if (entity.dead) {
|
|
|
|
this.e.remove(i--);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.entityList.removeAll(this.D);
|
2011-04-20 22:47:26 +02:00
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
int j;
|
|
|
|
int k;
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
for (i = 0; i < this.D.size(); ++i) {
|
|
|
|
entity = (Entity) this.D.get(i);
|
2011-05-28 22:50:08 +02:00
|
|
|
j = entity.bG;
|
|
|
|
k = entity.bI;
|
|
|
|
if (entity.bF && this.isChunkLoaded(j, k)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.getChunkAt(j, k).b(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
for (i = 0; i < this.D.size(); ++i) {
|
|
|
|
this.d((Entity) this.D.get(i));
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.D.clear();
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
for (i = 0; i < this.entityList.size(); ++i) {
|
|
|
|
entity = (Entity) this.entityList.get(i);
|
2011-02-07 06:56:07 +01:00
|
|
|
if (entity.vehicle != null) {
|
|
|
|
if (!entity.vehicle.dead && entity.vehicle.passenger == entity) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
entity.vehicle.passenger = null;
|
|
|
|
entity.vehicle = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!entity.dead) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.playerJoinedWorld(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (entity.dead) {
|
2011-05-28 22:50:08 +02:00
|
|
|
j = entity.bG;
|
|
|
|
k = entity.bI;
|
|
|
|
if (entity.bF && this.isChunkLoaded(j, k)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.getChunkAt(j, k).b(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.entityList.remove(i--);
|
2011-04-20 22:47:26 +02:00
|
|
|
this.d(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < this.c.size(); ++i) {
|
|
|
|
TileEntity tileentity = (TileEntity) this.c.get(i);
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
tileentity.g_();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void playerJoinedWorld(Entity entity) {
|
|
|
|
this.entityJoinedWorld(entity, true);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void entityJoinedWorld(Entity entity, boolean flag) {
|
|
|
|
int i = MathHelper.floor(entity.locX);
|
|
|
|
int j = MathHelper.floor(entity.locZ);
|
2011-02-07 06:56:07 +01:00
|
|
|
byte b0 = 32;
|
|
|
|
|
|
|
|
if (!flag || this.a(i - b0, 0, j - b0, i + b0, 128, j + b0)) {
|
2011-05-28 22:50:08 +02:00
|
|
|
entity.bo = entity.locX;
|
|
|
|
entity.bp = entity.locY;
|
|
|
|
entity.bq = entity.locZ;
|
2011-02-07 06:56:07 +01:00
|
|
|
entity.lastYaw = entity.yaw;
|
|
|
|
entity.lastPitch = entity.pitch;
|
2011-05-28 22:50:08 +02:00
|
|
|
if (flag && entity.bF) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (entity.vehicle != null) {
|
2011-05-28 22:50:08 +02:00
|
|
|
entity.D();
|
2011-02-07 06:56:07 +01:00
|
|
|
} else {
|
2011-05-28 22:50:08 +02:00
|
|
|
entity.o_();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Double.isNaN(entity.locX) || Double.isInfinite(entity.locX)) {
|
2011-05-28 22:50:08 +02:00
|
|
|
entity.locX = entity.bo;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Double.isNaN(entity.locY) || Double.isInfinite(entity.locY)) {
|
2011-05-28 22:50:08 +02:00
|
|
|
entity.locY = entity.bp;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Double.isNaN(entity.locZ) || Double.isInfinite(entity.locZ)) {
|
2011-05-28 22:50:08 +02:00
|
|
|
entity.locZ = entity.bq;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Double.isNaN((double) entity.pitch) || Double.isInfinite((double) entity.pitch)) {
|
|
|
|
entity.pitch = entity.lastPitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Double.isNaN((double) entity.yaw) || Double.isInfinite((double) entity.yaw)) {
|
|
|
|
entity.yaw = entity.lastYaw;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
int k = MathHelper.floor(entity.locX / 16.0D);
|
|
|
|
int l = MathHelper.floor(entity.locY / 16.0D);
|
|
|
|
int i1 = MathHelper.floor(entity.locZ / 16.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-05-28 22:50:08 +02:00
|
|
|
if (!entity.bF || entity.bG != k || entity.bH != l || entity.bI != i1) {
|
|
|
|
if (entity.bF && this.isChunkLoaded(entity.bG, entity.bI)) {
|
|
|
|
this.getChunkAt(entity.bG, entity.bI).a(entity, entity.bH);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.isChunkLoaded(k, i1)) {
|
2011-05-28 22:50:08 +02:00
|
|
|
entity.bF = true;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.getChunkAt(k, i1).a(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
} else {
|
2011-05-28 22:50:08 +02:00
|
|
|
entity.bF = false;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-28 22:50:08 +02:00
|
|
|
if (flag && entity.bF && entity.passenger != null) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (!entity.passenger.dead && entity.passenger.vehicle == entity) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.playerJoinedWorld(entity.passenger);
|
2011-02-07 06:56:07 +01:00
|
|
|
} else {
|
|
|
|
entity.passenger.vehicle = null;
|
|
|
|
entity.passenger = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean containsEntity(AxisAlignedBB axisalignedbb) {
|
2011-02-07 06:56:07 +01:00
|
|
|
List list = this.b((Entity) null, axisalignedbb);
|
|
|
|
|
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
Entity entity = (Entity) list.get(i);
|
|
|
|
|
2011-05-28 22:50:08 +02:00
|
|
|
if (!entity.dead && entity.aI) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean b(AxisAlignedBB axisalignedbb) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
if (axisalignedbb.a < 0.0D) {
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (axisalignedbb.b < 0.0D) {
|
|
|
|
--k;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (axisalignedbb.c < 0.0D) {
|
|
|
|
--i1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int k1 = i; k1 < j; ++k1) {
|
|
|
|
for (int l1 = k; l1 < l; ++l1) {
|
|
|
|
for (int i2 = i1; i2 < j1; ++i2) {
|
|
|
|
Block block = Block.byId[this.getTypeId(k1, l1, i2)];
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (block != null) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean c(AxisAlignedBB axisalignedbb) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (axisalignedbb.a < 0.0D) {
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (axisalignedbb.b < 0.0D) {
|
|
|
|
--k;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (axisalignedbb.c < 0.0D) {
|
|
|
|
--i1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int k1 = i; k1 < j; ++k1) {
|
|
|
|
for (int l1 = k; l1 < l; ++l1) {
|
|
|
|
for (int i2 = i1; i2 < j1; ++i2) {
|
|
|
|
Block block = Block.byId[this.getTypeId(k1, l1, i2)];
|
|
|
|
|
|
|
|
if (block != null && block.material.isLiquid()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean d(AxisAlignedBB axisalignedbb) {
|
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
if (this.a(i, k, i1, j, l, j1)) {
|
|
|
|
for (int k1 = i; k1 < j; ++k1) {
|
|
|
|
for (int l1 = k; l1 < l; ++l1) {
|
|
|
|
for (int i2 = i1; i2 < j1; ++i2) {
|
|
|
|
int j2 = this.getTypeId(k1, l1, i2);
|
|
|
|
|
|
|
|
if (j2 == Block.FIRE.id || j2 == Block.LAVA.id || j2 == Block.STATIONARY_LAVA.id) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(AxisAlignedBB axisalignedbb, Material material, Entity entity) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
if (!this.a(i, k, i1, j, l, j1)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
boolean flag = false;
|
2011-04-20 19:05:14 +02:00
|
|
|
Vec3D vec3d = Vec3D.create(0.0D, 0.0D, 0.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
for (int k1 = i; k1 < j; ++k1) {
|
|
|
|
for (int l1 = k; l1 < l; ++l1) {
|
|
|
|
for (int i2 = i1; i2 < j1; ++i2) {
|
|
|
|
Block block = Block.byId[this.getTypeId(k1, l1, i2)];
|
|
|
|
|
|
|
|
if (block != null && block.material == material) {
|
|
|
|
double d0 = (double) ((float) (l1 + 1) - BlockFluids.c(this.getData(k1, l1, i2)));
|
|
|
|
|
|
|
|
if ((double) l >= d0) {
|
|
|
|
flag = true;
|
|
|
|
block.a(this, k1, l1, i2, entity, vec3d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vec3d.c() > 0.0D) {
|
|
|
|
vec3d = vec3d.b();
|
2011-04-20 22:47:26 +02:00
|
|
|
double d1 = 0.014D;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
entity.motX += vec3d.a * d1;
|
|
|
|
entity.motY += vec3d.b * d1;
|
|
|
|
entity.motZ += vec3d.c * d1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(AxisAlignedBB axisalignedbb, Material material) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
for (int k1 = i; k1 < j; ++k1) {
|
|
|
|
for (int l1 = k; l1 < l; ++l1) {
|
|
|
|
for (int i2 = i1; i2 < j1; ++i2) {
|
|
|
|
Block block = Block.byId[this.getTypeId(k1, l1, i2)];
|
|
|
|
|
|
|
|
if (block != null && block.material == material) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean b(AxisAlignedBB axisalignedbb, Material material) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
for (int k1 = i; k1 < j; ++k1) {
|
|
|
|
for (int l1 = k; l1 < l; ++l1) {
|
|
|
|
for (int i2 = i1; i2 < j1; ++i2) {
|
|
|
|
Block block = Block.byId[this.getTypeId(k1, l1, i2)];
|
|
|
|
|
|
|
|
if (block != null && block.material == material) {
|
|
|
|
int j2 = this.getData(k1, l1, i2);
|
|
|
|
double d0 = (double) (l1 + 1);
|
|
|
|
|
|
|
|
if (j2 < 8) {
|
|
|
|
d0 = (double) (l1 + 1) - (double) j2 / 8.0D;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d0 >= axisalignedbb.b) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Explosion a(Entity entity, double d0, double d1, double d2, float f) {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.createExplosion(entity, d0, d1, d2, f, false);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag) {
|
2011-02-07 06:56:07 +01:00
|
|
|
Explosion explosion = new Explosion(this, entity, d0, d1, d2, f);
|
|
|
|
|
|
|
|
explosion.a = flag;
|
|
|
|
explosion.a();
|
2011-04-20 22:47:26 +02:00
|
|
|
explosion.a(true);
|
2011-02-07 06:56:07 +01:00
|
|
|
return explosion;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float a(Vec3D vec3d, AxisAlignedBB axisalignedbb) {
|
|
|
|
double d0 = 1.0D / ((axisalignedbb.d - axisalignedbb.a) * 2.0D + 1.0D);
|
|
|
|
double d1 = 1.0D / ((axisalignedbb.e - axisalignedbb.b) * 2.0D + 1.0D);
|
|
|
|
double d2 = 1.0D / ((axisalignedbb.f - axisalignedbb.c) * 2.0D + 1.0D);
|
|
|
|
int i = 0;
|
|
|
|
int j = 0;
|
|
|
|
|
|
|
|
for (float f = 0.0F; f <= 1.0F; f = (float) ((double) f + d0)) {
|
|
|
|
for (float f1 = 0.0F; f1 <= 1.0F; f1 = (float) ((double) f1 + d1)) {
|
|
|
|
for (float f2 = 0.0F; f2 <= 1.0F; f2 = (float) ((double) f2 + d2)) {
|
|
|
|
double d3 = axisalignedbb.a + (axisalignedbb.d - axisalignedbb.a) * (double) f;
|
|
|
|
double d4 = axisalignedbb.b + (axisalignedbb.e - axisalignedbb.b) * (double) f1;
|
|
|
|
double d5 = axisalignedbb.c + (axisalignedbb.f - axisalignedbb.c) * (double) f2;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.a(Vec3D.create(d3, d4, d5), vec3d) == null) {
|
2011-02-07 06:56:07 +01:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (float) i / (float) j;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public void a(EntityHuman entityhuman, int i, int j, int k, int l) {
|
|
|
|
if (l == 0) {
|
|
|
|
--j;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 1) {
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 2) {
|
|
|
|
--k;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 3) {
|
|
|
|
++k;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 4) {
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 5) {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.getTypeId(i, j, k) == Block.FIRE.id) {
|
|
|
|
this.a(entityhuman, 1004, i, j, k, 0);
|
|
|
|
this.setTypeId(i, j, k, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
public TileEntity getTileEntity(int i, int j, int k) {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
return chunk != null ? chunk.d(i & 15, j, k & 15) : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTileEntity(int i, int j, int k, TileEntity tileentity) {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
if (chunk != null) {
|
|
|
|
chunk.a(i & 15, j, k & 15, tileentity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public void o(int i, int j, int k) {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
if (chunk != null) {
|
|
|
|
chunk.e(i & 15, j, k & 15);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public boolean p(int i, int j, int k) {
|
2011-02-07 06:56:07 +01:00
|
|
|
Block block = Block.byId[this.getTypeId(i, j, k)];
|
|
|
|
|
|
|
|
return block == null ? false : block.a();
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public boolean d(int i, int j, int k) {
|
|
|
|
Block block = Block.byId[this.getTypeId(i, j, k)];
|
|
|
|
|
|
|
|
return block == null ? false : block.material.h() && block.b();
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean doLighting() {
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.K >= 50) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
2011-05-26 14:48:22 +02:00
|
|
|
++this.K;
|
|
|
|
|
|
|
|
boolean flag;
|
2011-04-20 19:05:14 +02:00
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
try {
|
|
|
|
int i = 500;
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
while (this.C.size() > 0) {
|
2011-02-07 06:56:07 +01:00
|
|
|
--i;
|
|
|
|
if (i <= 0) {
|
|
|
|
flag = true;
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
((MetadataChunkBlock) this.C.remove(this.C.size() - 1)).a(this);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
flag = false;
|
|
|
|
} finally {
|
2011-05-26 14:48:22 +02:00
|
|
|
--this.K;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
2011-05-26 14:48:22 +02:00
|
|
|
|
|
|
|
return flag;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l, int i1, int j1) {
|
|
|
|
this.a(enumskyblock, i, j, k, l, i1, j1, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l, int i1, int j1, boolean flag) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!this.worldProvider.e || enumskyblock != EnumSkyBlock.SKY) {
|
2011-05-26 14:48:22 +02:00
|
|
|
++A;
|
2011-05-28 22:50:08 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
if (A == 50) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
int k1 = (l + i) / 2;
|
|
|
|
int l1 = (j1 + k) / 2;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!this.isLoaded(k1, 64, l1)) {
|
2011-05-28 22:50:08 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-31 15:55:45 +02:00
|
|
|
if (this.b(k1, l1).g()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-05-31 15:55:45 +02:00
|
|
|
int i2 = this.C.size();
|
|
|
|
int j2;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-05-31 15:55:45 +02:00
|
|
|
if (flag) {
|
|
|
|
j2 = 5;
|
|
|
|
if (j2 > i2) {
|
|
|
|
j2 = i2;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-05-31 15:55:45 +02:00
|
|
|
for (int k2 = 0; k2 < j2; ++k2) {
|
|
|
|
MetadataChunkBlock metadatachunkblock = (MetadataChunkBlock) this.C.get(this.C.size() - k2 - 1);
|
|
|
|
|
|
|
|
if (metadatachunkblock.a == enumskyblock && metadatachunkblock.a(i, j, k, l, i1, j1)) {
|
|
|
|
return;
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
2011-05-31 15:55:45 +02:00
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-05-31 15:55:45 +02:00
|
|
|
this.C.add(new MetadataChunkBlock(enumskyblock, i, j, k, l, i1, j1));
|
|
|
|
j2 = 1000000;
|
|
|
|
if (this.C.size() > 1000000) {
|
|
|
|
System.out.println("More than " + j2 + " updates, aborting lighting updates");
|
|
|
|
this.C.clear();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
2011-05-28 22:50:08 +02:00
|
|
|
} finally {
|
|
|
|
--A;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public void g() {
|
2011-02-07 06:56:07 +01:00
|
|
|
int i = this.a(1.0F);
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (i != this.f) {
|
|
|
|
this.f = i;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void setSpawnFlags(boolean flag, boolean flag1) {
|
|
|
|
this.allowMonsters = flag;
|
|
|
|
this.allowAnimals = flag1;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void doTick() {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.i();
|
2011-02-23 03:37:56 +01:00
|
|
|
long i;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.everyoneDeeplySleeping()) {
|
2011-02-23 03:37:56 +01:00
|
|
|
boolean flag = false;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.allowMonsters && this.spawnMonsters >= 1) {
|
|
|
|
flag = SpawnerCreature.a(this, this.players);
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!flag) {
|
2011-04-20 19:05:14 +02:00
|
|
|
i = this.worldData.f() + 24000L;
|
|
|
|
this.worldData.a(i - i % 24000L);
|
2011-04-20 22:47:26 +02:00
|
|
|
this.s();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals
|
2011-06-17 04:06:45 +02:00
|
|
|
if ((this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && getServer().getHandle().players.size() > 0)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
SpawnerCreature.spawnEntities(this, this.allowMonsters, this.allowAnimals);
|
2011-02-23 13:56:36 +01:00
|
|
|
}
|
2011-02-13 01:21:50 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.chunkProvider.unloadChunks();
|
2011-02-23 03:37:56 +01:00
|
|
|
int j = this.a(1.0F);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (j != this.f) {
|
|
|
|
this.f = j;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
for (int k = 0; k < this.u.size(); ++k) {
|
|
|
|
((IWorldAccess) this.u.get(k)).a();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
i = this.worldData.f() + 1L;
|
2011-05-26 14:48:22 +02:00
|
|
|
if (i % (long) this.p == 0L) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.save(false, (IProgressUpdate) null);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.worldData.a(i);
|
2011-02-07 06:56:07 +01:00
|
|
|
this.a(false);
|
2011-04-20 22:47:26 +02:00
|
|
|
this.j();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void x() {
|
|
|
|
if (this.worldData.l()) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.j = 1.0F;
|
2011-04-20 22:47:26 +02:00
|
|
|
if (this.worldData.j()) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.l = 1.0F;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
protected void i() {
|
2011-04-20 22:47:26 +02:00
|
|
|
if (!this.worldProvider.e) {
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.m > 0) {
|
|
|
|
--this.m;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int i = this.worldData.k();
|
|
|
|
|
|
|
|
if (i <= 0) {
|
|
|
|
if (this.worldData.j()) {
|
|
|
|
this.worldData.b(this.random.nextInt(12000) + 3600);
|
|
|
|
} else {
|
|
|
|
this.worldData.b(this.random.nextInt(168000) + 12000);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
--i;
|
|
|
|
this.worldData.b(i);
|
|
|
|
if (i <= 0) {
|
2011-04-26 04:00:18 +02:00
|
|
|
// CraftBukkit start
|
2011-06-17 04:06:45 +02:00
|
|
|
CraftServer server = getServer();
|
2011-04-26 01:47:25 +02:00
|
|
|
|
|
|
|
ThunderChangeEvent thunder = new ThunderChangeEvent(((WorldServer) this).getWorld(), !this.worldData.j());
|
|
|
|
server.getPluginManager().callEvent(thunder);
|
|
|
|
if (!thunder.isCancelled()) {
|
|
|
|
this.worldData.a(!this.worldData.j());
|
|
|
|
}
|
2011-04-26 04:00:18 +02:00
|
|
|
// CraftBukkit end
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int j = this.worldData.m();
|
|
|
|
|
|
|
|
if (j <= 0) {
|
|
|
|
if (this.worldData.l()) {
|
|
|
|
this.worldData.c(this.random.nextInt(12000) + 12000);
|
|
|
|
} else {
|
|
|
|
this.worldData.c(this.random.nextInt(168000) + 12000);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
--j;
|
|
|
|
this.worldData.c(j);
|
|
|
|
if (j <= 0) {
|
2011-04-26 04:00:18 +02:00
|
|
|
// CraftBukkit start
|
2011-06-17 04:06:45 +02:00
|
|
|
CraftServer server = getServer();
|
2011-04-26 01:47:25 +02:00
|
|
|
|
|
|
|
WeatherChangeEvent weather = new WeatherChangeEvent(((WorldServer) this).getWorld(), !this.worldData.l());
|
|
|
|
server.getPluginManager().callEvent(weather);
|
|
|
|
if (!weather.isCancelled()) {
|
|
|
|
this.worldData.b(!this.worldData.l());
|
|
|
|
}
|
2011-04-26 04:00:18 +02:00
|
|
|
// CraftBukkit end
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.i = this.j;
|
2011-04-20 22:47:26 +02:00
|
|
|
if (this.worldData.l()) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.j = (float) ((double) this.j + 0.01D);
|
2011-04-20 22:47:26 +02:00
|
|
|
} else {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.j = (float) ((double) this.j - 0.01D);
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.j < 0.0F) {
|
|
|
|
this.j = 0.0F;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.j > 1.0F) {
|
|
|
|
this.j = 1.0F;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.k = this.l;
|
2011-04-20 22:47:26 +02:00
|
|
|
if (this.worldData.j()) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.l = (float) ((double) this.l + 0.01D);
|
2011-04-20 22:47:26 +02:00
|
|
|
} else {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.l = (float) ((double) this.l - 0.01D);
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.l < 0.0F) {
|
|
|
|
this.l = 0.0F;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.l > 1.0F) {
|
|
|
|
this.l = 1.0F;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void y() {
|
2011-04-26 01:47:25 +02:00
|
|
|
// CraftBukkit start
|
2011-06-17 04:06:45 +02:00
|
|
|
CraftServer server = getServer();
|
2011-04-26 01:47:25 +02:00
|
|
|
|
2011-04-26 03:57:22 +02:00
|
|
|
WeatherChangeEvent weather = new WeatherChangeEvent(((WorldServer) this).getWorld(), false);
|
2011-04-26 01:47:25 +02:00
|
|
|
server.getPluginManager().callEvent(weather);
|
|
|
|
|
2011-04-26 03:57:22 +02:00
|
|
|
ThunderChangeEvent thunder = new ThunderChangeEvent(((WorldServer) this).getWorld(), false);
|
2011-04-26 01:47:25 +02:00
|
|
|
server.getPluginManager().callEvent(thunder);
|
|
|
|
if (!weather.isCancelled()) {
|
|
|
|
this.worldData.c(0);
|
|
|
|
this.worldData.b(false);
|
|
|
|
}
|
|
|
|
if (!thunder.isCancelled()) {
|
|
|
|
this.worldData.b(0);
|
|
|
|
this.worldData.a(false);
|
|
|
|
}
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit end
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void j() {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.N.clear();
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int k;
|
|
|
|
int l;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
for (int i1 = 0; i1 < this.players.size(); ++i1) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) this.players.get(i1);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
i = MathHelper.floor(entityhuman.locX / 16.0D);
|
|
|
|
j = MathHelper.floor(entityhuman.locZ / 16.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
byte b0 = 9;
|
|
|
|
|
|
|
|
for (k = -b0; k <= b0; ++k) {
|
|
|
|
for (l = -b0; l <= b0; ++l) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.N.add(new ChunkCoordIntPair(k + i, l + j));
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.O > 0) {
|
|
|
|
--this.O;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
Iterator iterator = this.N.iterator();
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next();
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
i = chunkcoordintpair.x * 16;
|
|
|
|
j = chunkcoordintpair.z * 16;
|
|
|
|
Chunk chunk = this.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z);
|
2011-02-07 06:56:07 +01:00
|
|
|
int j1;
|
|
|
|
int k1;
|
|
|
|
int l1;
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.O == 0) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.g = this.g * 3 + this.h;
|
|
|
|
k = this.g >> 2;
|
2011-02-07 06:56:07 +01:00
|
|
|
l = k & 15;
|
|
|
|
j1 = k >> 8 & 15;
|
|
|
|
k1 = k >> 16 & 127;
|
2011-04-20 19:05:14 +02:00
|
|
|
l1 = chunk.getTypeId(l, k1, j1);
|
2011-02-07 06:56:07 +01:00
|
|
|
l += i;
|
|
|
|
j1 += j;
|
2011-05-26 14:48:22 +02:00
|
|
|
if (l1 == 0 && this.j(l, k1, j1) <= this.random.nextInt(8) && this.a(EnumSkyBlock.SKY, l, k1, j1) <= 0) {
|
2011-02-07 06:56:07 +01:00
|
|
|
EntityHuman entityhuman1 = this.a((double) l + 0.5D, (double) k1 + 0.5D, (double) j1 + 0.5D, 8.0D);
|
|
|
|
|
|
|
|
if (entityhuman1 != null && entityhuman1.d((double) l + 0.5D, (double) k1 + 0.5D, (double) j1 + 0.5D) > 4.0D) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.makeSound((double) l + 0.5D, (double) k1 + 0.5D, (double) j1 + 0.5D, "ambient.cave.cave", 0.7F, 0.8F + this.random.nextFloat() * 0.2F);
|
2011-05-26 14:48:22 +02:00
|
|
|
this.O = this.random.nextInt(12000) + 6000;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.random.nextInt(100000) == 0 && this.v() && this.u()) {
|
|
|
|
this.g = this.g * 3 + this.h;
|
|
|
|
k = this.g >> 2;
|
|
|
|
l = i + (k & 15);
|
|
|
|
j1 = j + (k >> 8 & 15);
|
|
|
|
k1 = this.e(l, j1);
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.s(l, k1, j1)) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.a((Entity) (new EntityWeatherStorm(this, (double) l, (double) k1, (double) j1)));
|
2011-05-26 14:48:22 +02:00
|
|
|
this.m = 2;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int i2;
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.random.nextInt(16) == 0) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.g = this.g * 3 + this.h;
|
|
|
|
k = this.g >> 2;
|
|
|
|
l = k & 15;
|
|
|
|
j1 = k >> 8 & 15;
|
|
|
|
k1 = this.e(l + i, j1 + j);
|
|
|
|
if (this.getWorldChunkManager().getBiome(l + i, j1 + j).c() && k1 >= 0 && k1 < 128 && chunk.a(EnumSkyBlock.BLOCK, l, k1, j1) < 10) {
|
|
|
|
l1 = chunk.getTypeId(l, k1 - 1, j1);
|
|
|
|
i2 = chunk.getTypeId(l, k1, j1);
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.v() && i2 == 0 && Block.SNOW.canPlace(this, l + i, k1, j1 + j) && l1 != 0 && l1 != Block.ICE.id && Block.byId[l1].material.isSolid()) {
|
2011-05-02 07:48:08 +02:00
|
|
|
// CraftBukkit start
|
2011-06-17 20:48:20 +02:00
|
|
|
SnowFormEvent snow = new SnowFormEvent(this.getWorld().getBlockAt(l + i, k1, j1 + j));
|
2011-05-14 16:29:42 +02:00
|
|
|
|
2011-06-17 04:06:45 +02:00
|
|
|
getServer().getPluginManager().callEvent(snow);
|
2011-05-02 07:48:08 +02:00
|
|
|
if (!snow.isCancelled()) {
|
|
|
|
this.setTypeId(l + i, k1, j1 + j, snow.getMaterial().getId());
|
|
|
|
this.setData(l + i, k1, j1 + j, snow.getData());
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2011-06-17 20:48:20 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
if (l1 == Block.STATIONARY_WATER.id && chunk.getData(l, k1 - 1, j1) == 0) {
|
|
|
|
BlockState blockState = this.getWorld().getBlockAt(l + i, k1 - 1, j1 + j).getState();
|
|
|
|
blockState.setTypeId(Block.ICE.id);
|
|
|
|
|
|
|
|
BlockFormEvent iceBlockForm = new BlockFormEvent(this.getWorld().getBlockAt(l + i, k1 - 1, j1 + j), blockState);
|
|
|
|
this.getServer().getPluginManager().callEvent(iceBlockForm);
|
|
|
|
if (!iceBlockForm.isCancelled()) {
|
|
|
|
blockState.update(true);
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
2011-06-17 20:48:20 +02:00
|
|
|
// CraftBukkit end
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (k = 0; k < 80; ++k) {
|
2011-04-20 22:47:26 +02:00
|
|
|
this.g = this.g * 3 + this.h;
|
|
|
|
l = this.g >> 2;
|
2011-02-07 06:56:07 +01:00
|
|
|
j1 = l & 15;
|
|
|
|
k1 = l >> 8 & 15;
|
|
|
|
l1 = l >> 16 & 127;
|
2011-04-20 22:47:26 +02:00
|
|
|
i2 = chunk.b[j1 << 11 | k1 << 7 | l1] & 255;
|
2011-03-31 22:40:00 +02:00
|
|
|
if (Block.n[i2]) {
|
2011-04-20 19:05:14 +02:00
|
|
|
Block.byId[i2].a(this, j1 + i, l1, k1 + j, this.random);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(boolean flag) {
|
2011-05-26 14:48:22 +02:00
|
|
|
int i = this.E.size();
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
if (i != this.F.size()) {
|
2011-02-07 06:56:07 +01:00
|
|
|
throw new IllegalStateException("TickNextTick list out of synch");
|
|
|
|
} else {
|
|
|
|
if (i > 1000) {
|
|
|
|
i = 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int j = 0; j < i; ++j) {
|
2011-05-26 14:48:22 +02:00
|
|
|
NextTickListEntry nextticklistentry = (NextTickListEntry) this.E.first();
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!flag && nextticklistentry.e > this.worldData.f()) {
|
2011-02-07 06:56:07 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
this.E.remove(nextticklistentry);
|
|
|
|
this.F.remove(nextticklistentry);
|
2011-02-07 06:56:07 +01:00
|
|
|
byte b0 = 8;
|
|
|
|
|
|
|
|
if (this.a(nextticklistentry.a - b0, nextticklistentry.b - b0, nextticklistentry.c - b0, nextticklistentry.a + b0, nextticklistentry.b + b0, nextticklistentry.c + b0)) {
|
|
|
|
int k = this.getTypeId(nextticklistentry.a, nextticklistentry.b, nextticklistentry.c);
|
|
|
|
|
|
|
|
if (k == nextticklistentry.d && k > 0) {
|
2011-04-20 19:05:14 +02:00
|
|
|
Block.byId[k].a(this, nextticklistentry.a, nextticklistentry.b, nextticklistentry.c, this.random);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
return this.E.size() != 0;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public List b(Entity entity, AxisAlignedBB axisalignedbb) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.P.clear();
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor((axisalignedbb.a - 2.0D) / 16.0D);
|
|
|
|
int j = MathHelper.floor((axisalignedbb.d + 2.0D) / 16.0D);
|
|
|
|
int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D);
|
|
|
|
int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
for (int i1 = i; i1 <= j; ++i1) {
|
|
|
|
for (int j1 = k; j1 <= l; ++j1) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.isChunkLoaded(i1, j1)) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.getChunkAt(i1, j1).a(entity, axisalignedbb, this.P);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
return this.P;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public List a(Class oclass, AxisAlignedBB axisalignedbb) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor((axisalignedbb.a - 2.0D) / 16.0D);
|
|
|
|
int j = MathHelper.floor((axisalignedbb.d + 2.0D) / 16.0D);
|
|
|
|
int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D);
|
|
|
|
int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
ArrayList arraylist = new ArrayList();
|
|
|
|
|
|
|
|
for (int i1 = i; i1 <= j; ++i1) {
|
|
|
|
for (int j1 = k; j1 <= l; ++j1) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.isChunkLoaded(i1, j1)) {
|
|
|
|
this.getChunkAt(i1, j1).a(oclass, axisalignedbb, arraylist);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return arraylist;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(int i, int j, int k, TileEntity tileentity) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.isLoaded(i, j, k)) {
|
2011-02-07 06:56:07 +01:00
|
|
|
this.b(i, k).f();
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
for (int l = 0; l < this.u.size(); ++l) {
|
|
|
|
((IWorldAccess) this.u.get(l)).a(i, j, k, tileentity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a(Class oclass) {
|
|
|
|
int i = 0;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
for (int j = 0; j < this.entityList.size(); ++j) {
|
|
|
|
Entity entity = (Entity) this.entityList.get(j);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
if (oclass.isAssignableFrom(entity.getClass())) {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(List list) {
|
2011-03-20 21:18:38 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
Entity entity = null;
|
2011-02-07 06:56:07 +01:00
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
2011-03-20 21:18:38 +01:00
|
|
|
entity = (Entity) list.get(i);
|
2011-06-18 05:36:35 +02:00
|
|
|
// CraftBukkit start - fixed an NPE
|
|
|
|
if (entity == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-04-20 19:05:14 +02:00
|
|
|
this.entityList.add(entity);
|
2011-03-20 21:18:38 +01:00
|
|
|
// CraftBukkit end
|
2011-04-20 22:47:26 +02:00
|
|
|
this.c((Entity) list.get(i));
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(List list) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.D.addAll(list);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public boolean a(int i, int j, int k, int l, boolean flag, int i1) {
|
|
|
|
int j1 = this.getTypeId(j, k, l);
|
|
|
|
Block block = Block.byId[j1];
|
2011-02-07 06:56:07 +01:00
|
|
|
Block block1 = Block.byId[i];
|
|
|
|
AxisAlignedBB axisalignedbb = block1.d(this, j, k, l);
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
axisalignedbb = null;
|
|
|
|
}
|
|
|
|
|
2011-06-12 00:02:58 +02:00
|
|
|
boolean defaultReturn; // CraftBukkit - store the default action
|
2011-02-07 10:26:12 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (axisalignedbb != null && !this.containsEntity(axisalignedbb)) {
|
2011-06-12 00:02:58 +02:00
|
|
|
defaultReturn = false; // CraftBukkit
|
2011-05-14 16:29:42 +02:00
|
|
|
} else {
|
|
|
|
if (block == Block.WATER || block == Block.STATIONARY_WATER || block == Block.LAVA || block == Block.STATIONARY_LAVA || block == Block.FIRE || block == Block.SNOW) {
|
|
|
|
block = null;
|
|
|
|
}
|
|
|
|
|
2011-06-12 00:02:58 +02:00
|
|
|
defaultReturn = i > 0 && block == null && block1.canPlace(this, j, k, l, i1); // CraftBukkit
|
2011-02-07 10:26:12 +01:00
|
|
|
}
|
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit start
|
2011-03-26 22:32:56 +01:00
|
|
|
BlockCanBuildEvent event = new BlockCanBuildEvent(((WorldServer) this).getWorld().getBlockAt(j, k, l), i, defaultReturn);
|
2011-06-17 04:06:45 +02:00
|
|
|
getServer().getPluginManager().callEvent(event);
|
2011-02-07 10:26:12 +01:00
|
|
|
|
|
|
|
return event.isBuildable();
|
|
|
|
// CraftBukkit end
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public PathEntity findPath(Entity entity, Entity entity1, float f) {
|
|
|
|
int i = MathHelper.floor(entity.locX);
|
|
|
|
int j = MathHelper.floor(entity.locY);
|
|
|
|
int k = MathHelper.floor(entity.locZ);
|
2011-02-07 06:56:07 +01:00
|
|
|
int l = (int) (f + 16.0F);
|
|
|
|
int i1 = i - l;
|
|
|
|
int j1 = j - l;
|
|
|
|
int k1 = k - l;
|
|
|
|
int l1 = i + l;
|
|
|
|
int i2 = j + l;
|
|
|
|
int j2 = k + l;
|
|
|
|
ChunkCache chunkcache = new ChunkCache(this, i1, j1, k1, l1, i2, j2);
|
|
|
|
|
|
|
|
return (new Pathfinder(chunkcache)).a(entity, entity1, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public PathEntity a(Entity entity, int i, int j, int k, float f) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int l = MathHelper.floor(entity.locX);
|
|
|
|
int i1 = MathHelper.floor(entity.locY);
|
|
|
|
int j1 = MathHelper.floor(entity.locZ);
|
2011-02-07 06:56:07 +01:00
|
|
|
int k1 = (int) (f + 8.0F);
|
|
|
|
int l1 = l - k1;
|
|
|
|
int i2 = i1 - k1;
|
|
|
|
int j2 = j1 - k1;
|
|
|
|
int k2 = l + k1;
|
|
|
|
int l2 = i1 + k1;
|
|
|
|
int i3 = j1 + k1;
|
|
|
|
ChunkCache chunkcache = new ChunkCache(this, l1, i2, j2, k2, l2, i3);
|
|
|
|
|
|
|
|
return (new Pathfinder(chunkcache)).a(entity, i, j, k, f);
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isBlockFacePowered(int i, int j, int k, int l) {
|
2011-02-07 06:56:07 +01:00
|
|
|
int i1 = this.getTypeId(i, j, k);
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
return i1 == 0 ? false : Block.byId[i1].c(this, i, j, k, l);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isBlockPowered(int i, int j, int k) {
|
|
|
|
return this.isBlockFacePowered(i, j - 1, k, 0) ? true : (this.isBlockFacePowered(i, j + 1, k, 1) ? true : (this.isBlockFacePowered(i, j, k - 1, 2) ? true : (this.isBlockFacePowered(i, j, k + 1, 3) ? true : (this.isBlockFacePowered(i - 1, j, k, 4) ? true : this.isBlockFacePowered(i + 1, j, k, 5)))));
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isBlockFaceIndirectlyPowered(int i, int j, int k, int l) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (this.d(i, j, k)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.isBlockPowered(i, j, k);
|
2011-02-07 06:56:07 +01:00
|
|
|
} else {
|
|
|
|
int i1 = this.getTypeId(i, j, k);
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
return i1 == 0 ? false : Block.byId[i1].a(this, i, j, k, l);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isBlockIndirectlyPowered(int i, int j, int k) {
|
|
|
|
return this.isBlockFaceIndirectlyPowered(i, j - 1, k, 0) ? true : (this.isBlockFaceIndirectlyPowered(i, j + 1, k, 1) ? true : (this.isBlockFaceIndirectlyPowered(i, j, k - 1, 2) ? true : (this.isBlockFaceIndirectlyPowered(i, j, k + 1, 3) ? true : (this.isBlockFaceIndirectlyPowered(i - 1, j, k, 4) ? true : this.isBlockFaceIndirectlyPowered(i + 1, j, k, 5)))));
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public EntityHuman a(Entity entity, double d0) {
|
|
|
|
return this.a(entity.locX, entity.locY, entity.locZ, d0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public EntityHuman a(double d0, double d1, double d2, double d3) {
|
|
|
|
double d4 = -1.0D;
|
|
|
|
EntityHuman entityhuman = null;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
for (int i = 0; i < this.players.size(); ++i) {
|
|
|
|
EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
|
2011-06-18 05:36:35 +02:00
|
|
|
// CraftBukkit start - fixed an NPE
|
|
|
|
if (entityhuman1 == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-02-07 06:56:07 +01:00
|
|
|
double d5 = entityhuman1.d(d0, d1, d2);
|
|
|
|
|
|
|
|
if ((d3 < 0.0D || d5 < d3 * d3) && (d4 == -1.0D || d5 < d4)) {
|
|
|
|
d4 = d5;
|
|
|
|
entityhuman = entityhuman1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return entityhuman;
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public EntityHuman a(String s) {
|
2011-04-20 19:05:14 +02:00
|
|
|
for (int i = 0; i < this.players.size(); ++i) {
|
|
|
|
if (s.equals(((EntityHuman) this.players.get(i)).name)) {
|
|
|
|
return (EntityHuman) this.players.get(i);
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
public byte[] c(int i, int j, int k, int l, int i1, int j1) {
|
|
|
|
byte[] abyte = new byte[l * i1 * j1 * 5 / 2];
|
|
|
|
int k1 = i >> 4;
|
|
|
|
int l1 = k >> 4;
|
|
|
|
int i2 = i + l - 1 >> 4;
|
|
|
|
int j2 = k + j1 - 1 >> 4;
|
|
|
|
int k2 = 0;
|
|
|
|
int l2 = j;
|
|
|
|
int i3 = j + i1;
|
|
|
|
|
|
|
|
if (j < 0) {
|
|
|
|
l2 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i3 > 128) {
|
|
|
|
i3 = 128;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int j3 = k1; j3 <= i2; ++j3) {
|
|
|
|
int k3 = i - j3 * 16;
|
|
|
|
int l3 = i + l - j3 * 16;
|
|
|
|
|
|
|
|
if (k3 < 0) {
|
|
|
|
k3 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l3 > 16) {
|
|
|
|
l3 = 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i4 = l1; i4 <= j2; ++i4) {
|
|
|
|
int j4 = k - i4 * 16;
|
|
|
|
int k4 = k + j1 - i4 * 16;
|
|
|
|
|
|
|
|
if (j4 < 0) {
|
|
|
|
j4 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (k4 > 16) {
|
|
|
|
k4 = 16;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
k2 = this.getChunkAt(j3, i4).a(abyte, k3, l2, j4, l3, i3, k4, k2);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return abyte;
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public void k() {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.w.b();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void setTime(long i) {
|
|
|
|
this.worldData.a(i);
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public long getSeed() {
|
|
|
|
return this.worldData.b();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public long getTime() {
|
|
|
|
return this.worldData.f();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public ChunkCoordinates getSpawn() {
|
|
|
|
return new ChunkCoordinates(this.worldData.c(), this.worldData.d(), this.worldData.e());
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(EntityHuman entityhuman, int i, int j, int k) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Entity entity, byte b0) {}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public IChunkProvider o() {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.chunkProvider;
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void d(int i, int j, int k, int l, int i1) {
|
2011-02-07 06:56:07 +01:00
|
|
|
int j1 = this.getTypeId(i, j, k);
|
|
|
|
|
|
|
|
if (j1 > 0) {
|
|
|
|
Block.byId[j1].a(this, i, j, k, l, i1);
|
|
|
|
}
|
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public IDataManager p() {
|
2011-05-26 14:48:22 +02:00
|
|
|
return this.w;
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
public WorldData q() {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.worldData;
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void everyoneSleeping() {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.I = !this.players.isEmpty();
|
2011-04-20 19:05:14 +02:00
|
|
|
Iterator iterator = this.players.iterator();
|
2011-02-23 03:37:56 +01:00
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
// CraftBukkit
|
|
|
|
if (!entityhuman.isSleeping() && !entityhuman.fauxSleeping) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.I = false;
|
2011-02-23 03:37:56 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-11 20:48:31 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
// Calls the method that checks to see if players are sleeping
|
|
|
|
// Called by CraftPlayer.setPermanentSleeping()
|
|
|
|
public void checkSleepStatus() {
|
|
|
|
if (!isStatic) {
|
2011-04-20 19:05:14 +02:00
|
|
|
everyoneSleeping();
|
2011-04-11 20:48:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
protected void s() {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.I = false;
|
2011-04-20 19:05:14 +02:00
|
|
|
Iterator iterator = this.players.iterator();
|
2011-02-23 03:37:56 +01:00
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (entityhuman.isSleeping()) {
|
2011-04-20 22:47:26 +02:00
|
|
|
entityhuman.a(false, false, true);
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
}
|
2011-04-20 22:47:26 +02:00
|
|
|
|
|
|
|
this.y();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean everyoneDeeplySleeping() {
|
2011-05-26 14:48:22 +02:00
|
|
|
if (this.I && !this.isStatic) {
|
2011-04-20 19:05:14 +02:00
|
|
|
Iterator iterator = this.players.iterator();
|
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit - This allows us to assume that some people are in bed but not really, allowing time to pass in spite of AFKers
|
2011-04-11 20:48:31 +02:00
|
|
|
boolean foundActualSleepers = false;
|
2011-04-20 19:05:14 +02:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
EntityHuman entityhuman;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (!iterator.hasNext()) {
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit
|
2011-04-11 20:48:31 +02:00
|
|
|
return foundActualSleepers;
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
entityhuman = (EntityHuman) iterator.next();
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit start
|
2011-04-20 19:05:14 +02:00
|
|
|
if (entityhuman.isDeeplySleeping()) {
|
2011-04-11 20:48:31 +02:00
|
|
|
foundActualSleepers = true;
|
|
|
|
}
|
2011-04-20 19:05:14 +02:00
|
|
|
} while (entityhuman.isDeeplySleeping() || entityhuman.fauxSleeping);
|
2011-04-11 20:48:31 +02:00
|
|
|
// CraftBukkit end
|
2011-02-23 03:37:56 +01:00
|
|
|
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-04-20 22:47:26 +02:00
|
|
|
|
|
|
|
public float c(float f) {
|
2011-05-26 14:48:22 +02:00
|
|
|
return (this.k + (this.l - this.k) * f) * this.d(f);
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public float d(float f) {
|
2011-05-26 14:48:22 +02:00
|
|
|
return this.i + (this.j - this.i) * f;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean u() {
|
|
|
|
return (double) this.c(1.0F) > 0.9D;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean v() {
|
|
|
|
return (double) this.d(1.0F) > 0.2D;
|
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public boolean s(int i, int j, int k) {
|
2011-04-20 22:47:26 +02:00
|
|
|
if (!this.v()) {
|
|
|
|
return false;
|
|
|
|
} else if (!this.isChunkLoaded(i, j, k)) {
|
|
|
|
return false;
|
|
|
|
} else if (this.e(i, k) > j) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
BiomeBase biomebase = this.getWorldChunkManager().getBiome(i, k);
|
|
|
|
|
|
|
|
return biomebase.c() ? false : biomebase.d();
|
|
|
|
}
|
|
|
|
}
|
2011-05-26 14:48:22 +02:00
|
|
|
|
|
|
|
public void a(String s, WorldMapBase worldmapbase) {
|
|
|
|
this.z.a(s, worldmapbase);
|
|
|
|
}
|
|
|
|
|
|
|
|
public WorldMapBase a(Class oclass, String s) {
|
|
|
|
return this.z.a(oclass, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int b(String s) {
|
|
|
|
return this.z.a(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void e(int i, int j, int k, int l, int i1) {
|
|
|
|
this.a((EntityHuman) null, i, j, k, l, i1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(EntityHuman entityhuman, int i, int j, int k, int l, int i1) {
|
|
|
|
for (int j1 = 0; j1 < this.u.size(); ++j1) {
|
|
|
|
((IWorldAccess) this.u.get(j1)).a(entityhuman, i, j, k, l, i1);
|
|
|
|
}
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|