Paper/src/main/java/net/minecraft/server/World.java

2936 Zeilen
95 KiB
Java

2011-02-07 06:56:07 +01:00
package net.minecraft.server;
import java.util.ArrayList;
2011-06-30 00:02:25 +02:00
import java.util.Collection;
2011-02-07 06:56:07 +01:00
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
import java.util.UUID;
import org.bukkit.Bukkit;
2011-06-06 22:38:35 +02:00
import org.bukkit.Location;
import org.bukkit.craftbukkit.util.LongHash;
import org.bukkit.craftbukkit.util.LongHashset;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.craftbukkit.CraftServer;
2011-02-07 10:43:50 +01:00
import org.bukkit.craftbukkit.CraftWorld;
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;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
2011-06-11 08:00:05 +02:00
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.weather.ThunderChangeEvent;
import org.bukkit.block.BlockState;
2011-02-07 10:43:50 +01:00
// CraftBukkit end
2011-02-07 06:56:07 +01:00
public class World implements IBlockAccess {
2012-03-01 11:49:23 +01:00
public boolean a = false;
public List entityList = new ArrayList();
private List G = new ArrayList();
private TreeSet H = new TreeSet();
private Set I = new HashSet();
public List tileEntityList = new ArrayList();
private List J = new ArrayList();
private List K = new ArrayList();
public List players = new ArrayList();
public List e = new ArrayList();
private long L = 16777215L;
public int f = 0;
protected int g = (new Random()).nextInt();
protected final int h = 1013904223;
protected float i;
protected float j;
protected float k;
protected float l;
protected int m = 0;
public int n = 0;
public boolean suppressPhysics = false;
private long M = System.currentTimeMillis();
protected int p = 40;
public int difficulty;
2012-03-01 11:49:23 +01:00
public Random random = new Random();
public boolean s = false;
2011-06-12 00:02:58 +02:00
public WorldProvider worldProvider; // CraftBukkit - remove final
2012-03-01 11:49:23 +01:00
protected List u = new ArrayList();
2011-05-14 16:29:42 +02:00
public IChunkProvider chunkProvider; // CraftBukkit - protected -> public
protected final IDataManager dataManager;
2011-05-14 16:29:42 +02:00
public WorldData worldData; // CraftBukkit - protected -> public
public boolean isLoading;
2012-03-01 11:49:23 +01:00
private boolean N;
public WorldMapCollection worldMaps;
2012-03-01 11:49:23 +01:00
public final VillageCollection villages = new VillageCollection(this);
private final VillageSiege O = new VillageSiege(this);
private ArrayList P = new ArrayList();
private boolean Q;
public boolean allowMonsters = true; // CraftBukkit - private -> public
public boolean allowAnimals = true; // CraftBukkit - private -> public
private LongHashset chunkTickList; // CraftBukkit
public long ticksPerAnimalSpawns; // CraftBukkit
public long ticksPerMonsterSpawns; // CraftBukkit
2012-03-01 11:49:23 +01:00
private int R;
int[] E;
private List S;
2011-02-07 06:56:07 +01:00
public boolean isStatic;
2012-03-01 11:49:23 +01:00
public BiomeBase getBiome(int i, int j) {
if (this.isLoaded(i, 0, j)) {
Chunk chunk = this.getChunkAtWorldCoords(i, j);
if (chunk != null) {
return chunk.a(i & 15, j & 15, this.worldProvider.c);
}
}
return this.worldProvider.c.getBiome(i, j);
}
public WorldChunkManager getWorldChunkManager() {
2012-01-12 23:10:13 +01:00
return this.worldProvider.c;
2011-02-07 06:56:07 +01:00
}
2011-06-12 00:02:58 +02:00
// CraftBukkit start
private final CraftWorld world;
2011-06-12 00:02:58 +02:00
public boolean pvpMode;
public boolean keepSpawnInMemory = true;
2011-06-12 00:02:58 +02:00
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 (this.generator != null) {
return this.generator.canSpawn(this.getWorld(), x, z);
2011-06-12 00:02:58 +02:00
} else {
return this.worldProvider.canSpawn(x, z);
2011-06-12 00:02:58 +02:00
}
}
public CraftWorld getWorld() {
return this.world;
}
public CraftServer getServer() {
return (CraftServer) Bukkit.getServer();
}
2011-06-12 00:02:58 +02:00
// CraftBukkit - changed signature
2011-09-15 02:23:52 +02:00
public World(IDataManager idatamanager, String s, WorldSettings worldsettings, WorldProvider worldprovider, ChunkGenerator gen, org.bukkit.World.Environment env) {
this.generator = gen;
this.world = new CraftWorld((WorldServer) this, gen, env);
2011-06-12 00:02:58 +02:00
// CraftBukkit end
this.chunkTickList = new LongHashset(); // CraftBukkit
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit
2012-03-01 11:49:23 +01:00
this.R = this.random.nextInt(12000);
this.E = new int['\u8000'];
this.S = new ArrayList();
2011-02-07 06:56:07 +01:00
this.isStatic = false;
this.dataManager = idatamanager;
this.worldMaps = new WorldMapCollection(idatamanager);
this.worldData = idatamanager.getWorldData();
2012-03-01 11:49:23 +01:00
this.s = this.worldData == null;
2011-02-07 06:56:07 +01:00
if (worldprovider != null) {
this.worldProvider = worldprovider;
2012-03-01 11:49:23 +01:00
} else if (this.worldData != null && this.worldData.g() != 0) {
this.worldProvider = WorldProvider.byDimension(this.worldData.g());
2011-02-23 03:37:56 +01:00
} else {
this.worldProvider = WorldProvider.byDimension(0);
2011-02-07 06:56:07 +01:00
}
boolean flag = false;
if (this.worldData == null) {
2011-09-15 02:23:52 +02:00
this.worldData = new WorldData(worldsettings, s);
2011-02-07 06:56:07 +01:00
flag = true;
2011-02-23 03:37:56 +01:00
} else {
this.worldData.a(s);
2011-02-07 06:56:07 +01: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-11-20 09:01:14 +01:00
this.g();
2012-03-01 11:49:23 +01:00
this.B();
this.getServer().addWorld(this.world); // CraftBukkit
2011-02-07 06:56:07 +01:00
}
2011-02-23 03:37:56 +01:00
protected IChunkProvider b() {
IChunkLoader ichunkloader = this.dataManager.createChunkLoader(this.worldProvider);
2011-02-23 03:37:56 +01:00
return new ChunkProviderLoadOrGenerate(this, ichunkloader, this.worldProvider.getChunkProvider());
2011-02-07 06:56:07 +01:00
}
2011-03-31 22:40:00 +02:00
protected void c() {
2012-01-12 23:10:13 +01:00
if (!this.worldProvider.c()) {
this.worldData.setSpawn(0, this.worldProvider.getSeaLevel(), 0);
} else {
this.isLoading = true;
2012-03-01 11:49:23 +01:00
WorldChunkManager worldchunkmanager = this.worldProvider.c;
2012-01-12 23:10:13 +01:00
List list = worldchunkmanager.a();
Random random = new Random(this.getSeed());
ChunkPosition chunkposition = worldchunkmanager.a(0, 0, 256, list, random);
int i = 0;
int j = this.worldProvider.getSeaLevel();
int k = 0;
// CraftBukkit start
if (this.generator != null) {
Random rand = new Random(this.getSeed());
Location spawn = this.generator.getFixedSpawnLocation(((WorldServer) this).getWorld(), rand);
if (spawn != null) {
if (spawn.getWorld() != ((WorldServer) this).getWorld()) {
throw new IllegalStateException("Cannot set spawn point for " + this.worldData.name + " to be in another world (" + spawn.getWorld().getName() + ")");
} else {
this.worldData.setSpawn(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
this.isLoading = false;
return;
}
2011-06-06 22:38:35 +02:00
}
}
2012-01-12 23:10:13 +01:00
// CraftBukkit end
2011-06-06 22:38:35 +02:00
2012-01-12 23:10:13 +01:00
if (chunkposition != null) {
i = chunkposition.x;
k = chunkposition.z;
} else {
System.out.println("Unable to find spawn biome");
}
2011-09-15 02:23:52 +02:00
2012-01-12 23:10:13 +01:00
int l = 0;
2011-09-15 02:23:52 +02:00
2012-03-01 11:49:23 +01:00
// CraftBukkit - use our own canSpawn
2012-01-12 23:10:13 +01:00
while (!this.canSpawn(i, k)) {
i += random.nextInt(64) - random.nextInt(64);
k += random.nextInt(64) - random.nextInt(64);
++l;
if (l == 1000) {
break;
}
2011-09-15 02:23:52 +02:00
}
2011-03-31 22:40:00 +02:00
2012-01-12 23:10:13 +01:00
this.worldData.setSpawn(i, j, k);
this.isLoading = false;
}
2011-03-31 22:40:00 +02:00
}
public ChunkCoordinates getDimensionSpawn() {
2012-03-01 11:49:23 +01:00
return this.worldProvider.e();
2011-11-20 09:01:14 +01:00
}
2012-03-01 11:49:23 +01:00
public int b(int i, int j) {
2011-02-07 06:56:07 +01:00
int k;
2012-03-01 11:49:23 +01:00
for (k = 63; !this.isEmpty(i, k + 1, j); ++k) {
2011-02-07 06:56:07 +01:00
;
}
return this.getTypeId(i, k, j);
}
public void save(boolean flag, IProgressUpdate iprogressupdate) {
if (this.chunkProvider.canSave()) {
2011-02-07 06:56:07 +01:00
if (iprogressupdate != null) {
iprogressupdate.a("Saving level");
}
2012-03-01 11:49:23 +01:00
this.A();
2011-02-07 06:56:07 +01:00
if (iprogressupdate != null) {
iprogressupdate.b("Saving chunks");
}
this.chunkProvider.saveChunks(flag, iprogressupdate);
2011-02-07 06:56:07 +01:00
}
}
2012-03-01 11:49:23 +01:00
private void A() {
this.m();
this.dataManager.saveWorldData(this.worldData, this.players);
this.worldMaps.a();
2011-02-07 06:56:07 +01:00
}
public int getTypeId(int i, int j, int k) {
2012-03-01 11:49:23 +01:00
return i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000 ? (j < 0 ? 0 : (j >= 256 ? 0 : this.getChunkAt(i >> 4, k >> 4).getTypeId(i & 15, j, k & 15))) : 0;
}
public int f(int i, int j, int k) {
return i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000 ? (j < 0 ? 0 : (j >= 256 ? 0 : this.getChunkAt(i >> 4, k >> 4).b(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;
}
2012-03-01 11:49:23 +01:00
public boolean isTileEntity(int i, int j, int k) {
int l = this.getTypeId(i, j, k);
return Block.byId[l] != null && Block.byId[l].o();
2012-03-01 11:49:23 +01:00
}
public boolean isLoaded(int i, int j, int k) {
2012-03-01 11:49:23 +01:00
return j >= 0 && j < 256 ? this.isChunkLoaded(i >> 4, k >> 4) : false;
2011-02-07 06:56:07 +01:00
}
public boolean areChunksLoaded(int i, int j, int k, int l) {
2011-02-07 06:56:07 +01:00
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) {
2012-03-01 11:49:23 +01:00
if (i1 >= 0 && j < 256) {
2011-02-07 06:56:07 +01:00
i >>= 4;
k >>= 4;
l >>= 4;
j1 >>= 4;
for (int k1 = i; k1 <= l; ++k1) {
for (int l1 = k; l1 <= j1; ++l1) {
if (!this.isChunkLoaded(k1, l1)) {
2011-02-07 06:56:07 +01:00
return false;
}
}
}
return true;
} else {
return false;
}
}
private boolean isChunkLoaded(int i, int j) {
return this.chunkProvider.isChunkLoaded(i, j);
2011-02-07 06:56:07 +01:00
}
public Chunk getChunkAtWorldCoords(int i, int j) {
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
public Chunk getChunkAt(int i, int j) {
2011-02-10 12:56:30 +01:00
Chunk result = null;
synchronized (this.chunkLock) {
if (this.lastChunkAccessed == null || this.lastXAccessed != i || this.lastZAccessed != j) {
this.lastXAccessed = i;
this.lastZAccessed = j;
this.lastChunkAccessed = this.chunkProvider.getOrCreateChunk(i, j);
2011-02-10 12:56:30 +01:00
}
result = this.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
public boolean setRawTypeIdAndData(int i, int j, int k, int l, int i1) {
2011-09-15 02:23:52 +02:00
if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) {
2011-02-07 06:56:07 +01:00
if (j < 0) {
return false;
2012-03-01 11:49:23 +01:00
} else if (j >= 256) {
2011-02-07 06:56:07 +01:00
return false;
} else {
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
2011-09-15 02:23:52 +02:00
boolean flag = chunk.a(i & 15, j, k & 15, l, i1);
2011-02-07 06:56:07 +01:00
2012-03-01 11:49:23 +01:00
// MethodProfiler.a("checkLight"); // CraftBukkit - not in production code
this.v(i, j, k);
// MethodProfiler.a(); // CraftBukkit - not in production code
2011-09-15 02:23:52 +02:00
return flag;
2011-02-07 06:56:07 +01:00
}
} else {
return false;
}
}
public boolean setRawTypeId(int i, int j, int k, int l) {
2011-09-15 02:23:52 +02:00
if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) {
2011-02-07 06:56:07 +01:00
if (j < 0) {
return false;
2012-03-01 11:49:23 +01:00
} else if (j >= 256) {
2011-02-07 06:56:07 +01:00
return false;
} else {
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
2011-09-15 02:23:52 +02:00
boolean flag = chunk.a(i & 15, j, k & 15, l);
2011-02-07 06:56:07 +01:00
2012-03-01 11:49:23 +01:00
// MethodProfiler.a("checkLight"); // CraftBukkit - not in production code
this.v(i, j, k);
// MethodProfiler.a(); // CraftBukkit - not in production code
2011-09-15 02:23:52 +02:00
return flag;
2011-02-07 06:56:07 +01:00
}
} 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) {
2011-09-15 02:23:52 +02:00
if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) {
2011-02-07 06:56:07 +01:00
if (j < 0) {
return 0;
2012-03-01 11:49:23 +01:00
} else if (j >= 256) {
2011-02-07 06:56:07 +01:00
return 0;
} else {
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
2011-02-07 06:56:07 +01:00
i &= 15;
k &= 15;
return chunk.getData(i, j, k);
2011-02-07 06:56:07 +01:00
}
} else {
return 0;
}
}
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);
2012-03-01 11:49:23 +01:00
if (Block.r[i1 & 4095]) {
2011-05-28 22:50:08 +02:00
this.update(i, j, k, i1);
} else {
this.applyPhysics(i, j, k, i1);
}
2011-02-07 06:56:07 +01:00
}
}
public boolean setRawData(int i, int j, int k, int l) {
2011-09-15 02:23:52 +02:00
if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) {
2011-02-07 06:56:07 +01:00
if (j < 0) {
return false;
2012-03-01 11:49:23 +01:00
} else if (j >= 256) {
2011-02-07 06:56:07 +01:00
return false;
} else {
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
2011-02-07 06:56:07 +01:00
i &= 15;
k &= 15;
2011-11-20 09:01:14 +01:00
return chunk.b(i, j, k, l);
2011-02-07 06:56:07 +01:00
}
} else {
return false;
}
}
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);
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
}
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);
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
}
public void notify(int i, int j, int k) {
2012-03-01 11:49:23 +01: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
}
}
2012-03-01 11:49:23 +01:00
public 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) {
2011-09-15 02:23:52 +02:00
int i1;
2011-02-07 06:56:07 +01:00
2011-09-15 02:23:52 +02:00
if (k > l) {
i1 = l;
2011-02-07 06:56:07 +01:00
l = k;
k = i1;
}
2012-03-01 11:49:23 +01:00
if (!this.worldProvider.e) {
2011-11-20 09:01:14 +01:00
for (i1 = k; i1 <= l; ++i1) {
this.b(EnumSkyBlock.SKY, i, i1, j);
}
2011-09-15 02:23:52 +02:00
}
2011-02-07 06:56:07 +01:00
this.b(i, k, j, i, l, j);
}
2012-03-01 11:49:23 +01:00
public void k(int i, int j, int k) {
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) {
2012-03-01 11:49:23 +01: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
}
}
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) {
if (!this.suppressPhysics && !this.isStatic) {
2011-02-07 06:56:07 +01:00
Block block = Block.byId[this.getTypeId(i, j, k)];
if (block != null) {
// CraftBukkit start
2011-02-07 10:43:50 +01:00
CraftWorld world = ((WorldServer) this).getWorld();
if (world != null) {
BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(i, j, k), l);
this.getServer().getPluginManager().callEvent(event);
2011-02-23 13:56:36 +01:00
if (event.isCancelled()) {
return;
}
}
2011-05-14 16:29:42 +02:00
// CraftBukkit end
block.doPhysics(this, i, j, k, l);
2011-02-07 06:56:07 +01:00
}
}
}
public boolean isChunkLoaded(int i, int j, int k) {
2012-03-01 11:49:23 +01:00
return this.getChunkAt(i >> 4, k >> 4).d(i & 15, j, k & 15);
2011-02-07 06:56:07 +01:00
}
2012-03-01 11:49:23 +01:00
public int m(int i, int j, int k) {
2011-05-26 14:48:22 +02:00
if (j < 0) {
return 0;
} else {
2012-03-01 11:49:23 +01:00
if (j >= 256) {
j = 255;
2011-05-26 14:48:22 +02:00
}
return this.getChunkAt(i >> 4, k >> 4).c(i & 15, j, k & 15, 0);
}
}
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) {
2011-09-15 02:23:52 +02:00
if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) {
2011-02-07 06:56:07 +01:00
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 {
2012-03-01 11:49:23 +01:00
if (j >= 256) {
j = 255;
2011-02-07 06:56:07 +01:00
}
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
2011-02-07 06:56:07 +01:00
i &= 15;
k &= 15;
2012-03-01 11:49:23 +01:00
return chunk.c(i, j, k, this.f);
2011-02-07 06:56:07 +01:00
}
} else {
return 15;
}
}
public int getHighestBlockYAt(int i, int j) {
2011-09-15 02:23:52 +02:00
if (i >= -30000000 && j >= -30000000 && i < 30000000 && j < 30000000) {
if (!this.isChunkLoaded(i >> 4, j >> 4)) {
2011-02-07 06:56:07 +01:00
return 0;
} else {
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 int a(EnumSkyBlock enumskyblock, int i, int j, int k) {
2011-05-26 14:48:22 +02:00
if (j < 0) {
j = 0;
}
2012-03-01 11:49:23 +01:00
if (j >= 256) {
j = 255;
2011-05-26 14:48:22 +02:00
}
2012-03-01 11:49:23 +01:00
if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) {
2011-02-07 06:56:07 +01:00
int l = i >> 4;
int i1 = k >> 4;
if (!this.isChunkLoaded(l, i1)) {
2012-03-01 11:49:23 +01:00
return enumskyblock.c;
2011-02-07 06:56:07 +01:00
} else {
Chunk chunk = this.getChunkAt(l, i1);
2011-02-07 06:56:07 +01:00
2012-02-29 22:31:04 +01:00
return chunk.getBrightness(enumskyblock, i & 15, j, k & 15);
2011-02-07 06:56:07 +01:00
}
} else {
return enumskyblock.c;
}
}
2011-09-15 02:23:52 +02:00
public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l) {
if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) {
2011-02-07 06:56:07 +01:00
if (j >= 0) {
2012-03-01 11:49:23 +01:00
if (j < 256) {
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);
2012-03-01 11:49:23 +01:00
for (int i1 = 0; i1 < this.u.size(); ++i1) {
((IWorldAccess) this.u.get(i1)).b(i, j, k);
2011-02-07 06:56:07 +01:00
}
}
}
}
}
}
2012-03-01 11:49:23 +01:00
public void o(int i, int j, int k) {
for (int l = 0; l < this.u.size(); ++l) {
((IWorldAccess) this.u.get(l)).b(i, j, k);
}
}
public float p(int i, int j, int k) {
return this.worldProvider.f[this.getLightLevel(i, j, k)];
2011-02-07 06:56:07 +01:00
}
2011-11-20 09:01:14 +01:00
public boolean e() {
2012-03-01 11:49:23 +01: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
}
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)) {
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];
2011-06-30 00:02:25 +02:00
if ((!flag1 || block == null || block.e(this, l, i1, j1) != null) && k1 > 0 && block.a(l1, flag)) {
2011-05-26 14:48:22 +02:00
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;
}
Vec3D vec3d2 = Vec3D.create(vec3d.a, vec3d.b, vec3d.c);
2011-02-07 06:56:07 +01:00
l = (int) (vec3d2.a = (double) MathHelper.floor(vec3d.a));
2011-02-07 06:56:07 +01:00
if (b0 == 5) {
--l;
++vec3d2.a;
}
i1 = (int) (vec3d2.b = (double) MathHelper.floor(vec3d.b));
2011-02-07 06:56:07 +01:00
if (b0 == 1) {
--i1;
++vec3d2.b;
}
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-06-30 00:02:25 +02:00
if ((!flag1 || block1 == null || block1.e(this, l, i1, j1) != null) && i2 > 0 && block1.a(j2, flag)) {
2011-05-26 14:48:22 +02:00
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;
}
}
public void makeSound(Entity entity, String s, float f, float f1) {
2012-03-01 11:49:23 +01: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
}
}
public void makeSound(double d0, double d1, double d2, String s, float f, float f1) {
2012-03-01 11:49:23 +01: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) {
2012-03-01 11:49:23 +01: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) {
2012-03-01 11:49:23 +01: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
}
}
public boolean strikeLightning(Entity entity) {
2012-03-01 11:49:23 +01:00
this.e.add(entity);
2011-04-20 22:47:26 +02:00
return true;
}
// CraftBukkit start - used for entities other than creatures
public boolean addEntity(Entity entity) {
return this.addEntity(entity, SpawnReason.CUSTOM); // Set reason as Custom by default
}
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
if (entity == null) return false;
2012-01-28 09:04:16 +01:00
// CraftBukkit end
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
if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;
if (spawnReason == SpawnReason.NATURAL || spawnReason == SpawnReason.CHUNK_GEN || spawnReason == SpawnReason.JOCKEY || spawnReason == SpawnReason.SPAWNER || spawnReason == SpawnReason.BED || spawnReason == SpawnReason.EGG || spawnReason == SpawnReason.VILLAGE_INVASION || spawnReason == SpawnReason.VILLAGE_DEFENSE || spawnReason == SpawnReason.BUILD_SNOWMAN || spawnReason == SpawnReason.BUILD_IRONGOLEM) {
if (isAnimal && !allowAnimals || isMonster && !allowMonsters) return false;
}
CreatureSpawnEvent event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
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);
if (event.isCancelled()) {
return false;
}
} else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
// Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
if (CraftEventFactory.callProjectileLaunchEvent(entity).isCancelled()) {
return false;
}
}
2011-02-23 03:37:56 +01:00
// CraftBukkit end
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;
this.players.add(entityhuman);
this.everyoneSleeping();
2011-02-07 06:56:07 +01: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) {
2012-03-01 11:49:23 +01: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) {
2012-03-01 11:49:23 +01: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
}
}
public void kill(Entity entity) {
2011-02-07 06:56:07 +01:00
if (entity.passenger != null) {
entity.passenger.mount((Entity) null);
2011-02-07 06:56:07 +01:00
}
if (entity.vehicle != null) {
entity.mount((Entity) null);
2011-02-07 06:56:07 +01:00
}
entity.die();
2011-02-07 06:56:07 +01:00
if (entity instanceof EntityHuman) {
this.players.remove((EntityHuman) entity);
this.everyoneSleeping();
2011-02-07 06:56:07 +01:00
}
}
public void removeEntity(Entity entity) {
entity.die();
2011-02-07 06:56:07 +01:00
if (entity instanceof EntityHuman) {
this.players.remove((EntityHuman) entity);
this.everyoneSleeping();
2011-02-07 06:56:07 +01:00
}
2012-01-12 23:10:13 +01:00
int i = entity.ca;
int j = entity.cc;
2011-02-07 06:56:07 +01:00
2012-01-12 23:10:13 +01:00
if (entity.bZ && this.isChunkLoaded(i, j)) {
this.getChunkAt(i, j).b(entity);
2011-02-07 06:56:07 +01:00
}
this.entityList.remove(entity);
2011-04-20 22:47:26 +02:00
this.d(entity);
2011-02-07 06:56:07 +01:00
}
public void addIWorldAccess(IWorldAccess iworldaccess) {
2012-03-01 11:49:23 +01:00
this.u.add(iworldaccess);
2011-02-07 06:56:07 +01:00
}
2012-02-29 22:31:04 +01:00
public List getCubes(Entity entity, AxisAlignedBB axisalignedbb) {
2012-03-01 11:49:23 +01:00
this.P.clear();
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) {
2012-03-01 11:49:23 +01: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) {
2012-03-01 11:49:23 +01:00
block.a(this, k1, i2, l1, axisalignedbb, this.P);
2011-02-07 06:56:07 +01:00
}
}
}
}
}
double d0 = 0.25D;
2012-01-12 16:27:39 +01:00
List list = this.getEntities(entity, axisalignedbb.grow(d0, d0, d0));
2011-02-07 06:56:07 +01:00
for (int j2 = 0; j2 < list.size(); ++j2) {
2012-03-01 11:49:23 +01:00
AxisAlignedBB axisalignedbb1 = ((Entity) list.get(j2)).h();
2011-02-07 06:56:07 +01:00
if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) {
2012-03-01 11:49:23 +01:00
this.P.add(axisalignedbb1);
2011-02-07 06:56:07 +01:00
}
2012-03-01 11:49:23 +01:00
axisalignedbb1 = entity.b_((Entity) list.get(j2));
2011-02-07 06:56:07 +01:00
if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) {
2012-03-01 11:49:23 +01:00
this.P.add(axisalignedbb1);
2011-02-07 06:56:07 +01:00
}
}
2012-03-01 11:49:23 +01:00
return this.P;
2011-02-07 06:56:07 +01:00
}
public int a(float f) {
float f1 = this.b(f);
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) {
return this.worldProvider.a(this.worldData.getTime(), f);
2011-02-07 06:56:07 +01:00
}
2012-03-01 11:49:23 +01:00
public int f(int i, int j) {
return this.getChunkAtWorldCoords(i, j).d(i & 15, j & 15);
2011-05-26 14:48:22 +02:00
}
2012-03-01 11:49:23 +01:00
public int g(int i, int j) {
Chunk chunk = this.getChunkAtWorldCoords(i, j);
2012-03-01 11:49:23 +01:00
int k = chunk.g() + 16;
2011-05-26 14:48:22 +02:00
i &= 15;
2011-02-07 06:56:07 +01:00
for (j &= 15; k > 0; --k) {
int l = chunk.getTypeId(i, k, j);
2011-02-07 06:56:07 +01:00
2011-09-15 02:23:52 +02:00
if (l != 0 && Block.byId[l].material.isSolid() && Block.byId[l].material != Material.LEAVES) {
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;
2012-03-01 11:49:23 +01:00
if (this.a) {
2011-02-07 06:56:07 +01:00
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) {
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) {
nextticklistentry.a((long) i1 + this.worldData.getTime());
2011-02-07 06:56:07 +01:00
}
2012-03-01 11:49:23 +01:00
if (!this.I.contains(nextticklistentry)) {
this.I.add(nextticklistentry);
this.H.add(nextticklistentry);
2011-02-07 06:56:07 +01:00
}
}
}
}
2011-11-20 09:01:14 +01:00
public void d(int i, int j, int k, int l, int i1) {
NextTickListEntry nextticklistentry = new NextTickListEntry(i, j, k, l);
if (l > 0) {
nextticklistentry.a((long) i1 + this.worldData.getTime());
2011-11-20 09:01:14 +01:00
}
2012-03-01 11:49:23 +01:00
if (!this.I.contains(nextticklistentry)) {
this.I.add(nextticklistentry);
this.H.add(nextticklistentry);
2011-11-20 09:01:14 +01:00
}
}
public void tickEntities() {
2012-01-12 12:02:39 +01:00
// MethodProfiler.a("entities"); // CraftBukkit - not in production code
// MethodProfiler.a("global"); // CraftBukkit - not in production code
2011-11-20 09:01:14 +01:00
2011-02-07 06:56:07 +01:00
int i;
Entity entity;
2011-04-20 22:47:26 +02:00
2012-03-01 11:49:23 +01:00
for (i = 0; i < this.e.size(); ++i) {
entity = (Entity) this.e.get(i);
// CraftBukkit start - fixed an NPE
if (entity == null) {
continue;
}
// CraftBukkit end
entity.F_();
2011-04-20 22:47:26 +02:00
if (entity.dead) {
2012-03-01 11:49:23 +01:00
this.e.remove(i--);
2011-04-20 22:47:26 +02:00
}
}
2012-01-12 12:02:39 +01:00
// MethodProfiler.b("remove"); // CraftBukkit - not in production code
2012-03-01 11:49:23 +01:00
this.entityList.removeAll(this.G);
2011-04-20 22:47:26 +02:00
2011-02-07 06:56:07 +01:00
int j;
int k;
2012-03-01 11:49:23 +01:00
for (i = 0; i < this.G.size(); ++i) {
entity = (Entity) this.G.get(i);
2012-01-12 23:10:13 +01:00
j = entity.ca;
k = entity.cc;
if (entity.bZ && this.isChunkLoaded(j, k)) {
this.getChunkAt(j, k).b(entity);
2011-02-07 06:56:07 +01:00
}
}
2012-03-01 11:49:23 +01:00
for (i = 0; i < this.G.size(); ++i) {
this.d((Entity) this.G.get(i));
2011-02-07 06:56:07 +01:00
}
2012-03-01 11:49:23 +01:00
this.G.clear();
2012-01-12 12:02:39 +01:00
// MethodProfiler.b("regular"); // CraftBukkit - not in production code
2011-02-07 06:56:07 +01: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) {
this.playerJoinedWorld(entity);
2011-02-07 06:56:07 +01:00
}
2012-01-12 12:02:39 +01:00
// MethodProfiler.a("remove"); // CraftBukkit - not in production code
2011-02-07 06:56:07 +01:00
if (entity.dead) {
2012-01-12 23:10:13 +01:00
j = entity.ca;
k = entity.cc;
if (entity.bZ && this.isChunkLoaded(j, k)) {
this.getChunkAt(j, k).b(entity);
2011-02-07 06:56:07 +01:00
}
this.entityList.remove(i--);
2011-04-20 22:47:26 +02:00
this.d(entity);
2011-02-07 06:56:07 +01:00
}
2011-11-20 09:01:14 +01:00
2012-01-12 12:02:39 +01:00
// MethodProfiler.a(); // CraftBukkit - not in production code
2011-02-07 06:56:07 +01:00
}
2012-01-12 12:02:39 +01:00
// MethodProfiler.b("tileEntities"); // CraftBukkit - not in production code
2012-03-01 11:49:23 +01:00
this.Q = true;
Iterator iterator = this.tileEntityList.iterator();
2011-02-07 06:56:07 +01:00
2011-06-30 00:02:25 +02:00
while (iterator.hasNext()) {
TileEntity tileentity = (TileEntity) iterator.next();
2011-11-20 09:01:14 +01:00
if (!tileentity.l() && tileentity.world != null && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) {
2012-03-01 11:49:23 +01:00
tileentity.q_();
2011-06-30 00:02:25 +02:00
}
2011-11-20 09:01:14 +01:00
if (tileentity.l()) {
2011-06-30 00:02:25 +02:00
iterator.remove();
2011-09-15 02:23:52 +02:00
if (this.isChunkLoaded(tileentity.x >> 4, tileentity.z >> 4)) {
Chunk chunk = this.getChunkAt(tileentity.x >> 4, tileentity.z >> 4);
2011-06-30 00:02:25 +02:00
2011-09-15 02:23:52 +02:00
if (chunk != null) {
2012-03-01 11:49:23 +01:00
chunk.f(tileentity.x & 15, tileentity.y, tileentity.z & 15);
2011-09-15 02:23:52 +02:00
}
2011-06-30 00:02:25 +02:00
}
}
}
2012-03-01 11:49:23 +01:00
this.Q = false;
if (!this.K.isEmpty()) {
this.tileEntityList.removeAll(this.K);
this.K.clear();
}
2012-01-12 12:02:39 +01:00
// MethodProfiler.b("pendingTileEntities"); // CraftBukkit - not in production code
2012-03-01 11:49:23 +01:00
if (!this.J.isEmpty()) {
Iterator iterator1 = this.J.iterator();
2011-06-30 00:02:25 +02:00
while (iterator1.hasNext()) {
TileEntity tileentity1 = (TileEntity) iterator1.next();
2011-11-20 09:01:14 +01:00
if (!tileentity1.l()) {
// CraftBukkit - order matters, moved down
2011-09-15 02:23:52 +02:00
/* if (!this.h.contains(tileentity1)) {
this.h.add(tileentity1);
} */
2011-06-30 00:02:25 +02:00
2011-09-15 02:23:52 +02:00
if (this.isChunkLoaded(tileentity1.x >> 4, tileentity1.z >> 4)) {
Chunk chunk1 = this.getChunkAt(tileentity1.x >> 4, tileentity1.z >> 4);
2011-06-30 00:02:25 +02:00
2011-09-15 02:23:52 +02:00
if (chunk1 != null) {
chunk1.a(tileentity1.x & 15, tileentity1.y, tileentity1.z & 15, tileentity1);
// CraftBukkit start - moved in from above
if (!this.tileEntityList.contains(tileentity1)) {
this.tileEntityList.add(tileentity1);
2011-09-15 02:23:52 +02:00
}
// CraftBukkit end
}
2011-06-30 00:02:25 +02:00
}
this.notify(tileentity1.x, tileentity1.y, tileentity1.z);
}
}
2012-03-01 11:49:23 +01:00
this.J.clear();
2011-06-30 00:02:25 +02:00
}
2011-11-20 09:01:14 +01:00
2012-01-12 12:02:39 +01:00
// MethodProfiler.a(); // CraftBukkit - not in production code
// MethodProfiler.a(); // CraftBukkit - not in production code
2011-06-30 00:02:25 +02:00
}
public void a(Collection collection) {
2012-03-01 11:49:23 +01:00
if (this.Q) {
this.J.addAll(collection);
2011-06-30 00:02:25 +02:00
} else {
this.tileEntityList.addAll(collection);
2011-02-07 06:56:07 +01:00
}
}
public void playerJoinedWorld(Entity entity) {
this.entityJoinedWorld(entity, true);
2011-02-07 06:56:07 +01: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;
2012-03-01 11:49:23 +01:00
if (!flag || this.a(i - b0, 0, j - b0, i + b0, 0, j + b0)) {
2012-01-12 23:10:13 +01:00
entity.bL = entity.locX;
entity.bM = entity.locY;
entity.bN = entity.locZ;
2011-02-07 06:56:07 +01:00
entity.lastYaw = entity.yaw;
entity.lastPitch = entity.pitch;
2012-01-12 23:10:13 +01:00
if (flag && entity.bZ) {
2011-02-07 06:56:07 +01:00
if (entity.vehicle != null) {
entity.R();
2011-02-07 06:56:07 +01:00
} else {
entity.F_();
2011-02-07 06:56:07 +01:00
}
}
2012-01-12 12:02:39 +01:00
// MethodProfiler.a("chunkCheck"); // CraftBukkit - not in production code
2011-02-07 06:56:07 +01:00
if (Double.isNaN(entity.locX) || Double.isInfinite(entity.locX)) {
2012-01-12 23:10:13 +01:00
entity.locX = entity.bL;
2011-02-07 06:56:07 +01:00
}
if (Double.isNaN(entity.locY) || Double.isInfinite(entity.locY)) {
2012-01-12 23:10:13 +01:00
entity.locY = entity.bM;
2011-02-07 06:56:07 +01:00
}
if (Double.isNaN(entity.locZ) || Double.isInfinite(entity.locZ)) {
2012-01-12 23:10:13 +01:00
entity.locZ = entity.bN;
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;
}
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
2012-01-12 23:10:13 +01:00
if (!entity.bZ || entity.ca != k || entity.cb != l || entity.cc != i1) {
if (entity.bZ && this.isChunkLoaded(entity.ca, entity.cc)) {
this.getChunkAt(entity.ca, entity.cc).a(entity, entity.cb);
2011-02-07 06:56:07 +01:00
}
if (this.isChunkLoaded(k, i1)) {
2012-01-12 23:10:13 +01:00
entity.bZ = true;
this.getChunkAt(k, i1).a(entity);
2011-02-07 06:56:07 +01:00
} else {
2012-01-12 23:10:13 +01:00
entity.bZ = false;
2011-02-07 06:56:07 +01:00
}
}
2012-01-12 12:02:39 +01:00
// MethodProfiler.a(); // CraftBukkit - not in production code
2012-01-12 23:10:13 +01:00
if (flag && entity.bZ && entity.passenger != null) {
2011-02-07 06:56:07 +01:00
if (!entity.passenger.dead && entity.passenger.vehicle == entity) {
this.playerJoinedWorld(entity.passenger);
2011-02-07 06:56:07 +01:00
} else {
entity.passenger.vehicle = null;
entity.passenger = null;
}
}
}
}
public boolean containsEntity(AxisAlignedBB axisalignedbb) {
2012-01-12 23:10:13 +01:00
List list = this.getEntities((Entity) null, axisalignedbb);
2011-02-07 06:56:07 +01:00
for (int i = 0; i < list.size(); ++i) {
Entity entity = (Entity) list.get(i);
2012-01-12 23:10:13 +01:00
if (!entity.dead && entity.bf) {
2011-02-07 06:56:07 +01:00
return false;
}
}
return true;
}
public boolean b(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 (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;
}
2012-02-29 22:31:04 +01:00
public boolean containsLiquid(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
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) {
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;
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) {
2011-11-20 09:01:14 +01:00
double d0 = (double) ((float) (l1 + 1) - BlockFluids.d(this.getData(k1, l1, i2)));
2011-02-07 06:56:07 +01:00
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) {
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) {
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;
}
2012-02-29 22:31:04 +01:00
public Explosion explode(Entity entity, double d0, double d1, double d2, float f) {
return this.createExplosion(entity, d0, d1, d2, f, false);
2011-02-07 06:56:07 +01: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;
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;
}
2012-03-01 11:49:23 +01:00
public boolean douseFire(EntityHuman entityhuman, int i, int j, int k, int l) {
2011-05-26 14:48:22 +02:00
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);
2012-03-01 11:49:23 +01:00
return true;
} else {
return false;
2011-05-26 14:48:22 +02:00
}
}
2011-02-07 06:56:07 +01:00
public TileEntity getTileEntity(int i, int j, int k) {
2012-03-01 11:49:23 +01:00
if (j >= 256) {
2011-11-20 09:01:14 +01:00
return null;
} else {
2012-03-01 11:49:23 +01:00
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
if (chunk == null) {
return null;
} else {
TileEntity tileentity = chunk.e(i & 15, j, k & 15);
2011-11-20 09:01:14 +01:00
2012-03-01 11:49:23 +01:00
if (tileentity == null) {
Iterator iterator = this.J.iterator();
2011-11-20 09:01:14 +01:00
2012-03-01 11:49:23 +01:00
while (iterator.hasNext()) {
TileEntity tileentity1 = (TileEntity) iterator.next();
2011-11-20 09:01:14 +01:00
2012-03-01 11:49:23 +01:00
if (!tileentity1.l() && tileentity1.x == i && tileentity1.y == j && tileentity1.z == k) {
tileentity = tileentity1;
break;
}
2011-11-20 09:01:14 +01:00
}
}
2012-03-01 11:49:23 +01:00
return tileentity;
}
2011-11-20 09:01:14 +01:00
}
2011-02-07 06:56:07 +01:00
}
public void setTileEntity(int i, int j, int k, TileEntity tileentity) {
2011-11-20 09:01:14 +01:00
if (tileentity != null && !tileentity.l()) {
2012-03-01 11:49:23 +01:00
if (this.Q) {
2011-06-30 00:02:25 +02:00
tileentity.x = i;
tileentity.y = j;
tileentity.z = k;
2012-03-01 11:49:23 +01:00
this.J.add(tileentity);
2011-06-30 00:02:25 +02:00
} else {
// CraftBukkit - order matters, moved down
2012-03-01 11:49:23 +01:00
// this.tileEntityList.add(tileentity);
2011-06-30 00:02:25 +02:00
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
2011-02-07 06:56:07 +01:00
2011-06-30 00:02:25 +02:00
if (chunk != null) {
chunk.a(i & 15, j, k & 15, tileentity);
this.tileEntityList.add(tileentity); // CraftBukkit - moved in from above
2011-06-30 00:02:25 +02:00
}
}
2011-02-07 06:56:07 +01:00
}
}
2012-03-01 11:49:23 +01:00
public void q(int i, int j, int k) {
2011-06-30 00:02:25 +02:00
TileEntity tileentity = this.getTileEntity(i, j, k);
2012-03-01 11:49:23 +01:00
if (tileentity != null && this.Q) {
tileentity.j();
this.J.remove(tileentity);
2011-06-30 00:02:25 +02:00
} else {
if (tileentity != null) {
2012-03-01 11:49:23 +01:00
this.J.remove(tileentity);
this.tileEntityList.remove(tileentity);
2011-06-30 00:02:25 +02:00
}
2011-02-07 06:56:07 +01:00
2011-06-30 00:02:25 +02:00
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
if (chunk != null) {
2012-03-01 11:49:23 +01:00
chunk.f(i & 15, j, k & 15);
2011-06-30 00:02:25 +02:00
}
2011-02-07 06:56:07 +01:00
}
}
2011-09-15 02:23:52 +02:00
public void a(TileEntity tileentity) {
2012-03-01 11:49:23 +01:00
this.K.add(tileentity);
2011-09-15 02:23:52 +02:00
}
2012-03-01 11:49:23 +01:00
public boolean r(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-06-30 00:02:25 +02:00
public boolean e(int i, int j, int k) {
2012-03-01 11:49:23 +01:00
return Block.g(this.getTypeId(i, j, k));
2011-02-07 06:56:07 +01:00
}
2011-11-20 09:01:14 +01:00
public boolean b(int i, int j, int k, boolean flag) {
if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) {
Chunk chunk = this.chunkProvider.getOrCreateChunk(i >> 4, k >> 4);
if (chunk != null && !chunk.isEmpty()) {
Block block = Block.byId[this.getTypeId(i, j, k)];
return block == null ? false : block.material.j() && block.b();
} else {
return flag;
}
} else {
return flag;
}
}
public void g() {
2011-02-07 06:56:07 +01:00
int i = this.a(1.0F);
2012-03-01 11:49:23 +01:00
if (i != this.f) {
this.f = i;
2011-02-07 06:56:07 +01:00
}
}
public void setSpawnFlags(boolean flag, boolean flag1) {
this.allowMonsters = flag;
this.allowAnimals = flag1;
2011-02-07 06:56:07 +01:00
}
public void doTick() {
if (this.getWorldData().isHardcore() && this.difficulty < 3) {
2011-11-20 09:01:14 +01:00
this.difficulty = 3;
}
2012-03-01 11:49:23 +01:00
this.worldProvider.c.b();
2011-11-20 09:01:14 +01:00
this.i();
2011-02-23 03:37:56 +01:00
long i;
if (this.everyoneDeeplySleeping()) {
2011-02-23 03:37:56 +01:00
boolean flag = false;
if (this.allowMonsters && this.difficulty >= 1) {
2011-11-20 09:01:14 +01:00
;
2011-02-23 03:37:56 +01:00
}
if (!flag) {
i = this.worldData.getTime() + 24000L;
this.worldData.a(i - i % 24000L);
2012-03-01 11:49:23 +01:00
this.u();
2011-02-23 03:37:56 +01:00
}
}
2012-01-12 12:02:39 +01:00
// MethodProfiler.a("mobSpawner"); // CraftBukkit - not in production code
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
long time = this.worldData.getTime();
if ((this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.getServer().getHandle().players.size() > 0)) {
SpawnerCreature.spawnEntities(this, this.allowMonsters && (this.ticksPerMonsterSpawns != 0 && time % this.ticksPerMonsterSpawns == 0L), this.allowAnimals && (this.ticksPerAnimalSpawns != 0 && time % this.ticksPerAnimalSpawns == 0L));
2011-02-23 13:56:36 +01:00
}
// CraftBukkit end
2012-01-12 12:02:39 +01:00
// MethodProfiler.b("chunkSource"); // CraftBukkit - not in production code
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
2012-03-01 11:49:23 +01:00
if (j != this.f) {
this.f = j;
2011-02-07 06:56:07 +01:00
}
i = this.worldData.getTime() + 1L;
2012-03-01 11:49:23 +01:00
if (i % (long) this.p == 0L) {
2012-01-12 12:02:39 +01:00
// MethodProfiler.b("save"); // CraftBukkit - not in production code
this.save(false, (IProgressUpdate) null);
2011-02-07 06:56:07 +01:00
}
this.worldData.a(i);
2012-01-12 12:02:39 +01:00
// MethodProfiler.b("tickPending"); // CraftBukkit - not in production code
2011-02-07 06:56:07 +01:00
this.a(false);
2012-01-12 12:02:39 +01:00
// MethodProfiler.b("tickTiles"); // CraftBukkit - not in production code
2012-03-01 11:49:23 +01:00
this.l();
// MethodProfiler.b("village"); // CraftBukkit - not in production code
this.villages.tick();
this.O.a();
2012-01-12 12:02:39 +01:00
// MethodProfiler.a(); // CraftBukkit - not in production code
2011-04-20 22:47:26 +02:00
}
2012-03-01 11:49:23 +01:00
private void B() {
if (this.worldData.hasStorm()) {
2012-03-01 11:49:23 +01:00
this.j = 1.0F;
if (this.worldData.isThundering()) {
2012-03-01 11:49:23 +01:00
this.l = 1.0F;
2011-04-20 22:47:26 +02:00
}
}
2011-02-07 06:56:07 +01:00
}
2011-11-20 09:01:14 +01:00
protected void i() {
2012-03-01 11:49:23 +01:00
if (!this.worldProvider.e) {
if (this.m > 0) {
--this.m;
2011-04-20 22:47:26 +02:00
}
int i = this.worldData.getThunderDuration();
2011-04-20 22:47:26 +02:00
if (i <= 0) {
if (this.worldData.isThundering()) {
this.worldData.setThunderDuration(this.random.nextInt(12000) + 3600);
2011-04-20 22:47:26 +02:00
} else {
this.worldData.setThunderDuration(this.random.nextInt(168000) + 12000);
2011-04-20 22:47:26 +02:00
}
} else {
--i;
this.worldData.setThunderDuration(i);
2011-04-20 22:47:26 +02:00
if (i <= 0) {
// CraftBukkit start
ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), !this.worldData.isThundering());
this.getServer().getPluginManager().callEvent(thunder);
if (!thunder.isCancelled()) {
this.worldData.setThundering(!this.worldData.isThundering());
}
// CraftBukkit end
2011-04-20 22:47:26 +02:00
}
}
int j = this.worldData.getWeatherDuration();
2011-04-20 22:47:26 +02:00
if (j <= 0) {
if (this.worldData.hasStorm()) {
this.worldData.setWeatherDuration(this.random.nextInt(12000) + 12000);
2011-04-20 22:47:26 +02:00
} else {
this.worldData.setWeatherDuration(this.random.nextInt(168000) + 12000);
2011-04-20 22:47:26 +02:00
}
} else {
--j;
this.worldData.setWeatherDuration(j);
2011-04-20 22:47:26 +02:00
if (j <= 0) {
// CraftBukkit start
WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), !this.worldData.hasStorm());
this.getServer().getPluginManager().callEvent(weather);
if (!weather.isCancelled()) {
this.worldData.setStorm(!this.worldData.hasStorm());
}
// CraftBukkit end
2011-04-20 22:47:26 +02:00
}
}
2012-03-01 11:49:23 +01:00
this.i = this.j;
if (this.worldData.hasStorm()) {
2012-03-01 11:49:23 +01:00
this.j = (float) ((double) this.j + 0.01D);
2011-04-20 22:47:26 +02:00
} else {
2012-03-01 11:49:23 +01:00
this.j = (float) ((double) this.j - 0.01D);
2011-04-20 22:47:26 +02:00
}
2012-03-01 11:49:23 +01:00
if (this.j < 0.0F) {
this.j = 0.0F;
2011-04-20 22:47:26 +02:00
}
2012-03-01 11:49:23 +01:00
if (this.j > 1.0F) {
this.j = 1.0F;
2011-04-20 22:47:26 +02:00
}
2012-03-01 11:49:23 +01:00
this.k = this.l;
if (this.worldData.isThundering()) {
2012-03-01 11:49:23 +01:00
this.l = (float) ((double) this.l + 0.01D);
2011-04-20 22:47:26 +02:00
} else {
2012-03-01 11:49:23 +01:00
this.l = (float) ((double) this.l - 0.01D);
2011-04-20 22:47:26 +02:00
}
2012-03-01 11:49:23 +01:00
if (this.l < 0.0F) {
this.l = 0.0F;
2011-04-20 22:47:26 +02:00
}
2012-03-01 11:49:23 +01:00
if (this.l > 1.0F) {
this.l = 1.0F;
2011-04-20 22:47:26 +02:00
}
}
}
2012-03-01 11:49:23 +01:00
private void C() {
// CraftBukkit start
WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false);
this.getServer().getPluginManager().callEvent(weather);
ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), false);
this.getServer().getPluginManager().callEvent(thunder);
if (!weather.isCancelled()) {
this.worldData.setWeatherDuration(0);
this.worldData.setStorm(false);
}
if (!thunder.isCancelled()) {
this.worldData.setThunderDuration(0);
this.worldData.setThundering(false);
}
2011-05-14 16:29:42 +02:00
// CraftBukkit end
2011-04-20 22:47:26 +02:00
}
2011-11-20 09:01:14 +01:00
public void j() {
this.worldData.setWeatherDuration(1);
}
protected void k() {
2012-03-01 11:49:23 +01:00
// this.chunkTickList.clear(); // CraftBukkit - removed
2012-01-12 12:02:39 +01:00
// MethodProfiler.a("buildList"); // CraftBukkit - not in production code
2011-02-07 06:56:07 +01:00
int i;
2012-03-01 11:49:23 +01:00
EntityHuman entityhuman;
2011-02-07 06:56:07 +01:00
int j;
2012-03-01 11:49:23 +01:00
int k;
2011-02-07 06:56:07 +01:00
2011-11-20 09:01:14 +01:00
for (i = 0; i < this.players.size(); ++i) {
2012-03-01 11:49:23 +01:00
entityhuman = (EntityHuman) this.players.get(i);
j = MathHelper.floor(entityhuman.locX / 16.0D);
k = MathHelper.floor(entityhuman.locZ / 16.0D);
2011-11-20 09:01:14 +01:00
byte b0 = 7;
2011-02-07 06:56:07 +01:00
2012-03-01 11:49:23 +01:00
for (int l = -b0; l <= b0; ++l) {
2011-11-20 09:01:14 +01:00
for (int i1 = -b0; i1 <= b0; ++i1) {
this.chunkTickList.add(LongHash.toLong(l + j, i1 + k)); // CraftBukkit
2011-02-07 06:56:07 +01:00
}
}
}
2012-03-01 11:49:23 +01:00
// MethodProfiler.a(); // CraftBukkit - not in production code
if (this.R > 0) {
--this.R;
2011-02-07 06:56:07 +01:00
}
2012-03-01 11:49:23 +01:00
// MethodProfiler.a("playerCheckLight"); // CraftBukkit - not in production code
if (!this.players.isEmpty()) {
i = this.random.nextInt(this.players.size());
entityhuman = (EntityHuman) this.players.get(i);
j = MathHelper.floor(entityhuman.locX) + this.random.nextInt(11) - 5;
k = MathHelper.floor(entityhuman.locY) + this.random.nextInt(11) - 5;
int j1 = MathHelper.floor(entityhuman.locZ) + this.random.nextInt(11) - 5;
this.v(j, k, j1);
}
2011-11-20 09:01:14 +01:00
2012-01-12 12:02:39 +01:00
// MethodProfiler.a(); // CraftBukkit - not in production code
2012-03-01 11:49:23 +01:00
}
protected void a(int i, int j, Chunk chunk) {
// MethodProfiler.b("tickChunk"); // CraftBukkit - not in production code
chunk.j();
// MethodProfiler.b("moodSound"); // CraftBukkit - not in production code
if (this.R == 0) {
this.g = this.g * 3 + 1013904223;
int k = this.g >> 2;
int l = k & 15;
int i1 = k >> 8 & 15;
int j1 = k >> 16 & 255; // CraftBukkit - 127 -> 255
2012-03-01 11:49:23 +01:00
int k1 = chunk.getTypeId(l, j1, i1);
l += i;
i1 += j;
if (k1 == 0 && this.m(l, j1, i1) <= this.random.nextInt(8) && this.a(EnumSkyBlock.SKY, l, j1, i1) <= 0) {
EntityHuman entityhuman = this.findNearbyPlayer((double) l + 0.5D, (double) j1 + 0.5D, (double) i1 + 0.5D, 8.0D);
if (entityhuman != null && entityhuman.e((double) l + 0.5D, (double) j1 + 0.5D, (double) i1 + 0.5D) > 4.0D) {
this.makeSound((double) l + 0.5D, (double) j1 + 0.5D, (double) i1 + 0.5D, "ambient.cave.cave", 0.7F, 0.8F + this.random.nextFloat() * 0.2F);
this.R = this.random.nextInt(12000) + 6000;
}
}
}
// MethodProfiler.b("checkLight"); // CraftBukkit - not in production code
chunk.n();
}
protected void l() {
this.k();
int i = 0;
int j = 0;
// Iterator iterator = this.chunkTickList.iterator(); // CraftBukkit
2011-02-07 06:56:07 +01:00
// CraftBukkit start
for (long chunkCoord : this.chunkTickList.popAll()) {
int chunkX = LongHash.msw(chunkCoord);
int chunkZ = LongHash.lsw(chunkCoord);
// ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next();
2012-03-01 11:49:23 +01:00
int k = chunkX * 16;
int l = chunkZ * 16;
2011-02-07 06:56:07 +01:00
2012-01-12 12:02:39 +01:00
// MethodProfiler.a("getChunk"); // CraftBukkit - not in production code
Chunk chunk = this.getChunkAt(chunkX, chunkZ);
// CraftBukkit end
2011-09-15 02:23:52 +02:00
2012-03-01 11:49:23 +01:00
this.a(k, l, chunk);
// MethodProfiler.b("thunder"); // CraftBukkit - not in production code
int i1;
int j1;
int k1;
2011-02-07 06:56:07 +01:00
int l1;
2011-04-20 22:47:26 +02:00
2012-03-01 11:49:23 +01:00
if (this.random.nextInt(100000) == 0 && this.x() && this.w()) {
this.g = this.g * 3 + 1013904223;
i1 = this.g >> 2;
j1 = k + (i1 & 15);
k1 = l + (i1 >> 8 & 15);
l1 = this.f(j1, k1);
if (this.y(j1, l1, k1)) {
this.strikeLightning(new EntityWeatherLighting(this, (double) j1, (double) l1, (double) k1));
this.m = 2;
2011-04-20 22:47:26 +02:00
}
}
2012-01-12 12:02:39 +01:00
// MethodProfiler.b("iceandsnow"); // CraftBukkit - not in production code
2012-01-12 23:10:13 +01:00
if (this.random.nextInt(16) == 0) {
2012-03-01 11:49:23 +01:00
this.g = this.g * 3 + 1013904223;
i1 = this.g >> 2;
j1 = i1 & 15;
k1 = i1 >> 8 & 15;
l1 = this.f(j1 + k, k1 + l);
if (this.t(j1 + k, l1 - 1, k1 + l)) {
2012-01-12 23:10:13 +01:00
// CraftBukkit start
2012-03-01 11:49:23 +01:00
BlockState blockState = this.getWorld().getBlockAt(j1 + k, l1 - 1, k1 + l).getState();
2012-01-12 23:10:13 +01:00
blockState.setTypeId(Block.ICE.id);
2011-11-20 09:01:14 +01:00
2012-01-12 23:10:13 +01:00
BlockFormEvent iceBlockForm = new BlockFormEvent(blockState.getBlock(), blockState);
this.getServer().getPluginManager().callEvent(iceBlockForm);
if (!iceBlockForm.isCancelled()) {
blockState.update(true);
}
// CraftBukkit end
2011-11-20 09:01:14 +01:00
}
2012-03-01 11:49:23 +01:00
if (this.x() && this.u(j1 + k, l1, k1 + l)) {
2012-01-12 23:10:13 +01:00
// CraftBukkit start
2012-03-01 11:49:23 +01:00
BlockState blockState = this.getWorld().getBlockAt(j1 + k, l1, k1 + l).getState();
2012-01-12 23:10:13 +01:00
blockState.setTypeId(Block.SNOW.id);
2011-04-20 22:47:26 +02:00
2012-01-12 23:10:13 +01:00
BlockFormEvent snow = new BlockFormEvent(blockState.getBlock(), blockState);
this.getServer().getPluginManager().callEvent(snow);
if (!snow.isCancelled()) {
blockState.update(true);
}
// CraftBukkit end
2011-11-20 09:01:14 +01:00
}
}
2012-01-12 12:02:39 +01:00
// MethodProfiler.b("tickTiles"); // CraftBukkit - not in production code
2012-03-01 11:49:23 +01:00
ChunkSection[] achunksection = chunk.h();
j1 = achunksection.length;
for (k1 = 0; k1 < j1; ++k1) {
ChunkSection chunksection = achunksection[k1];
if (chunksection != null && chunksection.b()) {
for (int i2 = 0; i2 < 3; ++i2) {
this.g = this.g * 3 + 1013904223;
int j2 = this.g >> 2;
int k2 = j2 & 15;
int l2 = j2 >> 8 & 15;
int i3 = j2 >> 16 & 15;
int j3 = chunksection.a(k2, i3, l2);
2011-11-20 09:01:14 +01:00
2012-03-01 11:49:23 +01:00
++j;
Block block = Block.byId[j3];
if (block != null && block.n()) {
2012-03-01 11:49:23 +01:00
++i;
block.a(this, k2 + k, i3 + chunksection.c(), l2 + l, this.random);
}
}
2011-11-20 09:01:14 +01:00
}
}
2012-01-12 12:02:39 +01:00
// MethodProfiler.a(); // CraftBukkit - not in production code
2011-11-20 09:01:14 +01:00
}
}
2011-04-20 22:47:26 +02:00
2012-03-01 11:49:23 +01:00
public boolean s(int i, int j, int k) {
2011-11-20 09:01:14 +01:00
return this.c(i, j, k, false);
}
2011-09-15 02:23:52 +02:00
2012-03-01 11:49:23 +01:00
public boolean t(int i, int j, int k) {
2011-11-20 09:01:14 +01:00
return this.c(i, j, k, true);
}
2011-09-15 02:23:52 +02:00
2011-11-20 09:01:14 +01:00
public boolean c(int i, int j, int k, boolean flag) {
2012-03-01 11:49:23 +01:00
BiomeBase biomebase = this.getBiome(i, k);
float f = biomebase.i();
2011-09-15 02:23:52 +02:00
2011-11-20 09:01:14 +01:00
if (f > 0.15F) {
return false;
} else {
2012-03-01 11:49:23 +01:00
if (j >= 0 && j < 256 && this.a(EnumSkyBlock.BLOCK, i, j, k) < 10) {
2011-11-20 09:01:14 +01:00
int l = this.getTypeId(i, j, k);
2011-09-15 02:23:52 +02:00
2011-11-20 09:01:14 +01:00
if ((l == Block.STATIONARY_WATER.id || l == Block.WATER.id) && this.getData(i, j, k) == 0) {
if (!flag) {
return true;
}
2011-09-15 02:23:52 +02:00
2011-11-20 09:01:14 +01:00
boolean flag1 = true;
2011-11-20 09:01:14 +01:00
if (flag1 && this.getMaterial(i - 1, j, k) != Material.WATER) {
flag1 = false;
}
if (flag1 && this.getMaterial(i + 1, j, k) != Material.WATER) {
flag1 = false;
}
if (flag1 && this.getMaterial(i, j, k - 1) != Material.WATER) {
flag1 = false;
}
if (flag1 && this.getMaterial(i, j, k + 1) != Material.WATER) {
flag1 = false;
}
if (!flag1) {
return true;
2011-02-07 06:56:07 +01:00
}
}
}
2011-11-20 09:01:14 +01:00
return false;
}
}
2012-03-01 11:49:23 +01:00
public boolean u(int i, int j, int k) {
BiomeBase biomebase = this.getBiome(i, k);
float f = biomebase.i();
2011-09-15 02:23:52 +02:00
2011-11-20 09:01:14 +01:00
if (f > 0.15F) {
return false;
} else {
2012-03-01 11:49:23 +01:00
if (j >= 0 && j < 256 && this.a(EnumSkyBlock.BLOCK, i, j, k) < 10) {
2011-11-20 09:01:14 +01:00
int l = this.getTypeId(i, j - 1, k);
int i1 = this.getTypeId(i, j, k);
if (i1 == 0 && Block.SNOW.canPlace(this, i, j, k) && l != 0 && l != Block.ICE.id && Block.byId[l].material.isSolid()) {
return true;
2011-02-07 06:56:07 +01:00
}
}
2011-11-20 09:01:14 +01:00
return false;
2011-02-07 06:56:07 +01:00
}
}
2012-03-01 11:49:23 +01:00
public void v(int i, int j, int k) {
if (!this.worldProvider.e) {
2011-11-20 09:01:14 +01:00
this.b(EnumSkyBlock.SKY, i, j, k);
}
2011-09-15 02:23:52 +02:00
this.b(EnumSkyBlock.BLOCK, i, j, k);
}
2012-03-01 11:49:23 +01:00
private int c(int i, int j, int k, int l, int i1, int j1) {
2011-09-15 02:23:52 +02:00
int k1 = 0;
if (this.isChunkLoaded(j, k, l)) {
k1 = 15;
} else {
if (j1 == 0) {
j1 = 1;
}
2012-03-01 11:49:23 +01:00
int l1 = this.a(EnumSkyBlock.SKY, j - 1, k, l) - j1;
int i2 = this.a(EnumSkyBlock.SKY, j + 1, k, l) - j1;
int j2 = this.a(EnumSkyBlock.SKY, j, k - 1, l) - j1;
int k2 = this.a(EnumSkyBlock.SKY, j, k + 1, l) - j1;
int l2 = this.a(EnumSkyBlock.SKY, j, k, l - 1) - j1;
int i3 = this.a(EnumSkyBlock.SKY, j, k, l + 1) - j1;
2011-09-15 02:23:52 +02:00
2012-03-01 11:49:23 +01:00
if (l1 > k1) {
k1 = l1;
}
if (i2 > k1) {
k1 = i2;
}
if (j2 > k1) {
k1 = j2;
}
if (k2 > k1) {
k1 = k2;
}
if (l2 > k1) {
k1 = l2;
}
if (i3 > k1) {
k1 = i3;
2011-09-15 02:23:52 +02:00
}
}
return k1;
}
2012-03-01 11:49:23 +01:00
private int d(int i, int j, int k, int l, int i1, int j1) {
int k1 = Block.lightEmission[i1];
2011-09-15 02:23:52 +02:00
int l1 = this.a(EnumSkyBlock.BLOCK, j - 1, k, l) - j1;
int i2 = this.a(EnumSkyBlock.BLOCK, j + 1, k, l) - j1;
int j2 = this.a(EnumSkyBlock.BLOCK, j, k - 1, l) - j1;
int k2 = this.a(EnumSkyBlock.BLOCK, j, k + 1, l) - j1;
int l2 = this.a(EnumSkyBlock.BLOCK, j, k, l - 1) - j1;
int i3 = this.a(EnumSkyBlock.BLOCK, j, k, l + 1) - j1;
if (l1 > k1) {
k1 = l1;
}
if (i2 > k1) {
k1 = i2;
}
if (j2 > k1) {
k1 = j2;
}
if (k2 > k1) {
k1 = k2;
}
if (l2 > k1) {
k1 = l2;
}
if (i3 > k1) {
k1 = i3;
}
return k1;
}
public void b(EnumSkyBlock enumskyblock, int i, int j, int k) {
if (this.areChunksLoaded(i, j, k, 17)) {
int l = 0;
int i1 = 0;
2012-03-01 11:49:23 +01:00
// MethodProfiler.a("getBrightness"); // CraftBukkit - not in production code
2011-09-15 02:23:52 +02:00
int j1 = this.a(enumskyblock, i, j, k);
boolean flag = false;
int k1 = this.getTypeId(i, j, k);
2012-03-01 11:49:23 +01:00
int l1 = this.f(i, j, k);
2011-09-15 02:23:52 +02:00
if (l1 == 0) {
l1 = 1;
}
boolean flag1 = false;
int i2;
if (enumskyblock == EnumSkyBlock.SKY) {
2012-03-01 11:49:23 +01:00
i2 = this.c(j1, i, j, k, k1, l1);
2011-09-15 02:23:52 +02:00
} else {
2012-03-01 11:49:23 +01:00
i2 = this.d(j1, i, j, k, k1, l1);
2011-09-15 02:23:52 +02:00
}
int j2;
int k2;
int l2;
int i3;
int j3;
int k3;
if (i2 > j1) {
2012-03-01 11:49:23 +01:00
this.E[i1++] = 133152;
2011-09-15 02:23:52 +02:00
} else if (i2 < j1) {
if (enumskyblock != EnumSkyBlock.BLOCK) {
;
}
2012-03-01 11:49:23 +01:00
this.E[i1++] = 133152 + (j1 << 18);
2011-09-15 02:23:52 +02:00
while (l < i1) {
2012-03-01 11:49:23 +01:00
j2 = this.E[l++];
2011-09-15 02:23:52 +02:00
k1 = (j2 & 63) - 32 + i;
l1 = (j2 >> 6 & 63) - 32 + j;
i2 = (j2 >> 12 & 63) - 32 + k;
k2 = j2 >> 18 & 15;
l2 = this.a(enumskyblock, k1, l1, i2);
if (l2 == k2) {
this.a(enumskyblock, k1, l1, i2, 0);
if (k2 > 0) {
i3 = k1 - i;
k3 = l1 - j;
j3 = i2 - k;
if (i3 < 0) {
i3 = -i3;
}
if (k3 < 0) {
k3 = -k3;
}
if (j3 < 0) {
j3 = -j3;
}
if (i3 + k3 + j3 < 17) {
for (int l3 = 0; l3 < 6; ++l3) {
int i4 = l3 % 2 * 2 - 1;
int j4 = k1 + l3 / 2 % 3 / 2 * i4;
int k4 = l1 + (l3 / 2 + 1) % 3 / 2 * i4;
int l4 = i2 + (l3 / 2 + 2) % 3 / 2 * i4;
l2 = this.a(enumskyblock, j4, k4, l4);
int i5 = Block.lightBlock[this.getTypeId(j4, k4, l4)];
2011-11-20 09:01:14 +01:00
if (i5 == 0) {
i5 = 1;
}
if (l2 == k2 - i5 && i1 < this.E.length) {
2012-03-01 11:49:23 +01:00
this.E[i1++] = j4 - i + 32 + (k4 - j + 32 << 6) + (l4 - k + 32 << 12) + (k2 - i5 << 18);
2011-09-15 02:23:52 +02:00
}
}
}
}
}
}
l = 0;
}
2012-03-01 11:49:23 +01:00
// MethodProfiler.a(); // CraftBukkit - not in production code
// MethodProfiler.a("tcp < tcc"); // CraftBukkit - not in production code
2011-09-15 02:23:52 +02:00
while (l < i1) {
2012-03-01 11:49:23 +01:00
j1 = this.E[l++];
2011-11-20 09:01:14 +01:00
int j5 = (j1 & 63) - 32 + i;
2011-09-15 02:23:52 +02:00
j2 = (j1 >> 6 & 63) - 32 + j;
k1 = (j1 >> 12 & 63) - 32 + k;
2011-11-20 09:01:14 +01:00
l1 = this.a(enumskyblock, j5, j2, k1);
i2 = this.getTypeId(j5, j2, k1);
k2 = Block.lightBlock[i2];
2011-09-15 02:23:52 +02:00
if (k2 == 0) {
k2 = 1;
}
boolean flag2 = false;
if (enumskyblock == EnumSkyBlock.SKY) {
2012-03-01 11:49:23 +01:00
l2 = this.c(l1, j5, j2, k1, i2, k2);
2011-09-15 02:23:52 +02:00
} else {
2012-03-01 11:49:23 +01:00
l2 = this.d(l1, j5, j2, k1, i2, k2);
2011-09-15 02:23:52 +02:00
}
if (l2 != l1) {
2011-11-20 09:01:14 +01:00
this.a(enumskyblock, j5, j2, k1, l2);
2011-09-15 02:23:52 +02:00
if (l2 > l1) {
2011-11-20 09:01:14 +01:00
i3 = j5 - i;
2011-09-15 02:23:52 +02:00
k3 = j2 - j;
j3 = k1 - k;
if (i3 < 0) {
i3 = -i3;
}
if (k3 < 0) {
k3 = -k3;
}
if (j3 < 0) {
j3 = -j3;
}
2012-03-01 11:49:23 +01:00
if (i3 + k3 + j3 < 17 && i1 < this.E.length - 6) {
2011-11-20 09:01:14 +01:00
if (this.a(enumskyblock, j5 - 1, j2, k1) < l2) {
2012-03-01 11:49:23 +01:00
this.E[i1++] = j5 - 1 - i + 32 + (j2 - j + 32 << 6) + (k1 - k + 32 << 12);
2011-09-15 02:23:52 +02:00
}
2011-11-20 09:01:14 +01:00
if (this.a(enumskyblock, j5 + 1, j2, k1) < l2) {
2012-03-01 11:49:23 +01:00
this.E[i1++] = j5 + 1 - i + 32 + (j2 - j + 32 << 6) + (k1 - k + 32 << 12);
2011-09-15 02:23:52 +02:00
}
2011-11-20 09:01:14 +01:00
if (this.a(enumskyblock, j5, j2 - 1, k1) < l2) {
2012-03-01 11:49:23 +01:00
this.E[i1++] = j5 - i + 32 + (j2 - 1 - j + 32 << 6) + (k1 - k + 32 << 12);
2011-09-15 02:23:52 +02:00
}
2011-11-20 09:01:14 +01:00
if (this.a(enumskyblock, j5, j2 + 1, k1) < l2) {
2012-03-01 11:49:23 +01:00
this.E[i1++] = j5 - i + 32 + (j2 + 1 - j + 32 << 6) + (k1 - k + 32 << 12);
2011-09-15 02:23:52 +02:00
}
2011-11-20 09:01:14 +01:00
if (this.a(enumskyblock, j5, j2, k1 - 1) < l2) {
2012-03-01 11:49:23 +01:00
this.E[i1++] = j5 - i + 32 + (j2 - j + 32 << 6) + (k1 - 1 - k + 32 << 12);
2011-09-15 02:23:52 +02:00
}
2011-11-20 09:01:14 +01:00
if (this.a(enumskyblock, j5, j2, k1 + 1) < l2) {
2012-03-01 11:49:23 +01:00
this.E[i1++] = j5 - i + 32 + (j2 - j + 32 << 6) + (k1 + 1 - k + 32 << 12);
2011-09-15 02:23:52 +02:00
}
}
}
}
}
2012-03-01 11:49:23 +01:00
// MethodProfiler.a(); // CraftBukkit - not in production code
2011-09-15 02:23:52 +02:00
}
}
2011-02-07 06:56:07 +01:00
public boolean a(boolean flag) {
2012-03-01 11:49:23 +01:00
int i = this.H.size();
2011-02-07 06:56:07 +01:00
2012-03-01 11:49:23 +01:00
if (i != this.I.size()) {
2011-02-07 06:56:07 +01:00
throw new IllegalStateException("TickNextTick list out of synch");
} else {
if (i > 1000) {
// CraftBukkit start - if the server has too much to process over time, try to alleviate that
2012-01-14 23:02:10 +01:00
if (i > 20 * 1000) {
i = i / 20;
} else {
i = 1000;
}
// CraftBukkit end
2011-02-07 06:56:07 +01:00
}
for (int j = 0; j < i; ++j) {
2012-03-01 11:49:23 +01:00
NextTickListEntry nextticklistentry = (NextTickListEntry) this.H.first();
2011-02-07 06:56:07 +01:00
if (!flag && nextticklistentry.e > this.worldData.getTime()) {
2011-02-07 06:56:07 +01:00
break;
}
2012-03-01 11:49:23 +01:00
this.H.remove(nextticklistentry);
this.I.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) {
Block.byId[k].a(this, nextticklistentry.a, nextticklistentry.b, nextticklistentry.c, this.random);
2011-02-07 06:56:07 +01:00
}
}
}
2012-03-01 11:49:23 +01:00
return this.H.size() != 0;
2011-02-07 06:56:07 +01:00
}
}
2011-11-20 09:01:14 +01:00
public List a(Chunk chunk, boolean flag) {
ArrayList arraylist = null;
2012-03-01 11:49:23 +01:00
ChunkCoordIntPair chunkcoordintpair = chunk.k();
2011-11-20 09:01:14 +01:00
int i = chunkcoordintpair.x << 4;
int j = i + 16;
int k = chunkcoordintpair.z << 4;
int l = k + 16;
2012-03-01 11:49:23 +01:00
Iterator iterator = this.I.iterator();
2011-11-20 09:01:14 +01:00
while (iterator.hasNext()) {
NextTickListEntry nextticklistentry = (NextTickListEntry) iterator.next();
if (nextticklistentry.a >= i && nextticklistentry.a < j && nextticklistentry.c >= k && nextticklistentry.c < l) {
if (flag) {
2012-03-01 11:49:23 +01:00
this.H.remove(nextticklistentry);
2011-11-20 09:01:14 +01:00
iterator.remove();
}
if (arraylist == null) {
arraylist = new ArrayList();
}
arraylist.add(nextticklistentry);
}
}
return arraylist;
}
2012-01-12 16:27:39 +01:00
public List getEntities(Entity entity, AxisAlignedBB axisalignedbb) {
2012-03-01 11:49:23 +01:00
this.S.clear();
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) {
if (this.isChunkLoaded(i1, j1)) {
2012-03-01 11:49:23 +01:00
this.getChunkAt(i1, j1).a(entity, axisalignedbb, this.S);
2011-02-07 06:56:07 +01:00
}
}
}
2012-03-01 11:49:23 +01:00
return this.S;
2011-02-07 06:56:07 +01:00
}
public List a(Class oclass, AxisAlignedBB axisalignedbb) {
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) {
if (this.isChunkLoaded(i1, j1)) {
this.getChunkAt(i1, j1).a(oclass, axisalignedbb, arraylist);
2011-02-07 06:56:07 +01:00
}
}
}
return arraylist;
}
2012-03-01 11:49:23 +01:00
public Entity a(Class oclass, AxisAlignedBB axisalignedbb, Entity entity) {
List list = this.a(oclass, axisalignedbb);
Entity entity1 = null;
double d0 = Double.MAX_VALUE;
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
Entity entity2 = (Entity) iterator.next();
if (entity2 != entity) {
double d1 = entity.j(entity2);
if (d1 <= d0) {
entity1 = entity2;
d0 = d1;
}
}
}
return entity1;
}
2011-02-07 06:56:07 +01:00
public void b(int i, int j, int k, TileEntity tileentity) {
if (this.isLoaded(i, j, k)) {
2012-03-01 11:49:23 +01:00
this.getChunkAtWorldCoords(i, k).e();
2011-02-07 06:56:07 +01:00
}
2012-03-01 11:49:23 +01: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;
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) {
// CraftBukkit start
Entity entity = null;
2011-02-07 06:56:07 +01:00
for (int i = 0; i < list.size(); ++i) {
entity = (Entity) list.get(i);
if (entity == null) {
continue;
}
this.entityList.add(entity);
// 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) {
2012-03-01 11:49:23 +01:00
this.G.addAll(list);
2011-02-07 06:56:07 +01:00
}
public boolean mayPlace(int i, int j, int k, int l, boolean flag, int i1) {
2011-05-26 14:48:22 +02:00
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];
2011-06-30 00:02:25 +02:00
AxisAlignedBB axisalignedbb = block1.e(this, j, k, l);
2011-02-07 06:56:07 +01:00
if (flag) {
axisalignedbb = null;
}
2011-06-12 00:02:58 +02:00
boolean defaultReturn; // CraftBukkit - store the default action
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 != null && (block == Block.WATER || block == Block.STATIONARY_WATER || block == Block.LAVA || block == Block.STATIONARY_LAVA || block == Block.FIRE || block.material.isReplacable())) {
2011-05-14 16:29:42 +02:00
block = null;
}
2011-06-12 00:02:58 +02:00
defaultReturn = i > 0 && block == null && block1.canPlace(this, j, k, l, i1); // CraftBukkit
}
2011-05-14 16:29:42 +02:00
// CraftBukkit start
BlockCanBuildEvent event = new BlockCanBuildEvent(this.getWorld().getBlockAt(j, k, l), i, defaultReturn);
this.getServer().getPluginManager().callEvent(event);
return event.isBuildable();
// CraftBukkit end
2011-02-07 06:56:07 +01:00
}
2012-03-01 11:49:23 +01:00
public PathEntity findPath(Entity entity, Entity entity1, float f, boolean flag, boolean flag1, boolean flag2, boolean flag3) {
2012-01-12 12:02:39 +01:00
// MethodProfiler.a("pathfind"); // CraftBukkit - not in production code
int i = MathHelper.floor(entity.locX);
2012-03-01 11:49:23 +01:00
int j = MathHelper.floor(entity.locY + 1.0D);
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);
2012-03-01 11:49:23 +01:00
PathEntity pathentity = (new Pathfinder(chunkcache, flag, flag1, flag2, flag3)).a(entity, entity1, f);
2011-02-07 06:56:07 +01:00
2012-01-12 12:02:39 +01:00
// MethodProfiler.a(); // CraftBukkit - not in production code
2011-11-20 09:01:14 +01:00
return pathentity;
2011-02-07 06:56:07 +01:00
}
2012-03-01 11:49:23 +01:00
public PathEntity a(Entity entity, int i, int j, int k, float f, boolean flag, boolean flag1, boolean flag2, boolean flag3) {
2012-01-12 12:02:39 +01:00
// MethodProfiler.a("pathfind"); // CraftBukkit - not in production code
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);
2012-03-01 11:49:23 +01:00
PathEntity pathentity = (new Pathfinder(chunkcache, flag, flag1, flag2, flag3)).a(entity, i, j, k, f);
2011-02-07 06:56:07 +01:00
2012-01-12 12:02:39 +01:00
// MethodProfiler.a(); // CraftBukkit - not in production code
2011-11-20 09:01:14 +01:00
return pathentity;
2011-02-07 06:56:07 +01: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-06-30 00:02:25 +02:00
return i1 == 0 ? false : Block.byId[i1].d(this, i, j, k, l);
2011-02-07 06:56:07 +01: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
}
public boolean isBlockFaceIndirectlyPowered(int i, int j, int k, int l) {
2011-06-30 00:02:25 +02:00
if (this.e(i, j, k)) {
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
}
}
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 findNearbyPlayer(Entity entity, double d0) {
return this.findNearbyPlayer(entity.locX, entity.locY, entity.locZ, d0);
2011-02-07 06:56:07 +01:00
}
public EntityHuman findNearbyPlayer(double d0, double d1, double d2, double d3) {
2011-02-07 06:56:07 +01:00
double d4 = -1.0D;
EntityHuman entityhuman = null;
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
// CraftBukkit start - fixed an NPE
if (entityhuman1 == null || entityhuman1.dead) {
continue;
}
// CraftBukkit end
2011-07-08 14:25:53 +02:00
double d5 = entityhuman1.e(d0, d1, d2);
2011-02-07 06:56:07 +01:00
if ((d3 < 0.0D || d5 < d3 * d3) && (d4 == -1.0D || d5 < d4)) {
d4 = d5;
entityhuman = entityhuman1;
}
}
return entityhuman;
}
2012-03-01 11:49:23 +01:00
public EntityHuman a(double d0, double d1, double d2) {
double d3 = -1.0D;
EntityHuman entityhuman = null;
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
double d4 = entityhuman1.e(d0, entityhuman1.locY, d1);
if ((d2 < 0.0D || d4 < d2 * d2) && (d3 == -1.0D || d4 < d3)) {
d3 = d4;
entityhuman = entityhuman1;
}
}
return entityhuman;
}
public EntityHuman findNearbyVulnerablePlayer(Entity entity, double d0) {
return this.findNearbyVulnerablePlayer(entity.locX, entity.locY, entity.locZ, d0);
2011-11-20 09:01:14 +01:00
}
public EntityHuman findNearbyVulnerablePlayer(double d0, double d1, double d2, double d3) {
2011-11-20 09:01:14 +01:00
double d4 = -1.0D;
EntityHuman entityhuman = null;
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
// CraftBukkit - fixed NPE
if (entityhuman1 == null || entityhuman1.dead) continue;
2011-11-20 09:01:14 +01:00
if (!entityhuman1.abilities.isInvulnerable) {
double d5 = entityhuman1.e(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) {
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;
}
2012-03-01 11:49:23 +01:00
public void m() {
this.dataManager.checkSession();
2011-02-23 03:37:56 +01:00
}
2011-02-07 06:56:07 +01:00
public void setTime(long i) {
this.worldData.a(i);
2011-02-23 03:37:56 +01:00
}
2011-07-08 14:25:53 +02:00
public void setTimeAndFixTicklists(long i) {
long j = i - this.worldData.getTime();
2011-07-08 14:25:53 +02:00
NextTickListEntry nextticklistentry;
2012-03-01 11:49:23 +01:00
for (Iterator iterator = this.I.iterator(); iterator.hasNext(); nextticklistentry.e += j) {
2011-07-08 14:25:53 +02:00
nextticklistentry = (NextTickListEntry) iterator.next();
}
this.setTime(i);
}
public long getSeed() {
return this.worldData.getSeed();
2011-02-23 03:37:56 +01:00
}
public long getTime() {
return this.worldData.getTime();
2011-02-23 03:37:56 +01: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;
}
2012-02-29 22:31:04 +01:00
public void broadcastEntityEffect(Entity entity, byte b0) {}
2011-02-07 06:56:07 +01:00
2012-03-01 11:49:23 +01:00
public IChunkProvider q() {
return this.chunkProvider;
2011-03-31 22:40:00 +02:00
}
public void playNote(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
public IDataManager getDataManager() {
return this.dataManager;
2011-02-23 03:37:56 +01:00
}
public WorldData getWorldData() {
return this.worldData;
2011-02-23 03:37:56 +01:00
}
public void everyoneSleeping() {
2012-03-01 11:49:23 +01:00
this.N = !this.players.isEmpty();
Iterator iterator = this.players.iterator();
2011-02-23 03:37:56 +01:00
while (iterator.hasNext()) {
EntityHuman entityhuman = (EntityHuman) iterator.next();
// CraftBukkit
if (!entityhuman.isSleeping() && !entityhuman.fauxSleeping) {
2012-03-01 11:49:23 +01:00
this.N = false;
2011-02-23 03:37:56 +01:00
break;
}
}
}
// CraftBukkit start
// Calls the method that checks to see if players are sleeping
// Called by CraftPlayer.setPermanentSleeping()
public void checkSleepStatus() {
if (!this.isStatic) {
this.everyoneSleeping();
}
}
// CraftBukkit end
2012-03-01 11:49:23 +01:00
protected void u() {
this.N = false;
Iterator iterator = this.players.iterator();
2011-02-23 03:37:56 +01:00
while (iterator.hasNext()) {
EntityHuman entityhuman = (EntityHuman) iterator.next();
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
2012-03-01 11:49:23 +01:00
this.C();
2011-02-23 03:37:56 +01:00
}
public boolean everyoneDeeplySleeping() {
2012-03-01 11:49:23 +01:00
if (this.N && !this.isStatic) {
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
boolean foundActualSleepers = false;
2011-02-23 03:37:56 +01:00
EntityHuman entityhuman;
do {
if (!iterator.hasNext()) {
2011-05-14 16:29:42 +02:00
// CraftBukkit
return foundActualSleepers;
2011-02-23 03:37:56 +01:00
}
entityhuman = (EntityHuman) iterator.next();
2011-05-14 16:29:42 +02:00
// CraftBukkit start
if (entityhuman.isDeeplySleeping()) {
foundActualSleepers = true;
}
} while (entityhuman.isDeeplySleeping() || entityhuman.fauxSleeping);
// 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) {
2012-03-01 11:49:23 +01: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) {
2012-03-01 11:49:23 +01:00
return this.i + (this.j - this.i) * f;
2011-04-20 22:47:26 +02:00
}
2012-03-01 11:49:23 +01:00
public boolean w() {
2011-04-20 22:47:26 +02:00
return (double) this.c(1.0F) > 0.9D;
}
2012-03-01 11:49:23 +01:00
public boolean x() {
2011-04-20 22:47:26 +02:00
return (double) this.d(1.0F) > 0.2D;
}
2012-03-01 11:49:23 +01:00
public boolean y(int i, int j, int k) {
if (!this.x()) {
2011-04-20 22:47:26 +02:00
return false;
} else if (!this.isChunkLoaded(i, j, k)) {
return false;
2012-03-01 11:49:23 +01:00
} else if (this.f(i, k) > j) {
2011-04-20 22:47:26 +02:00
return false;
} else {
2012-03-01 11:49:23 +01:00
BiomeBase biomebase = this.getBiome(i, k);
2011-04-20 22:47:26 +02:00
return biomebase.c() ? false : biomebase.d();
2011-04-20 22:47:26 +02:00
}
}
2011-05-26 14:48:22 +02:00
2012-03-01 11:49:23 +01:00
public boolean z(int i, int j, int k) {
BiomeBase biomebase = this.getBiome(i, k);
return biomebase.e();
2012-03-01 11:49:23 +01:00
}
2011-05-26 14:48:22 +02:00
public void a(String s, WorldMapBase worldmapbase) {
this.worldMaps.a(s, worldmapbase);
2011-05-26 14:48:22 +02:00
}
public WorldMapBase a(Class oclass, String s) {
2012-01-12 16:27:39 +01:00
return this.worldMaps.get(oclass, s);
2011-05-26 14:48:22 +02:00
}
public int b(String s) {
return this.worldMaps.a(s);
2011-05-26 14:48:22 +02:00
}
2012-02-29 22:31:04 +01:00
public void triggerEffect(int i, int j, int k, int l, int i1) {
2011-05-26 14:48:22 +02:00
this.a((EntityHuman) null, i, j, k, l, i1);
}
public void a(EntityHuman entityhuman, int i, int j, int k, int l, int i1) {
2012-03-01 11:49:23 +01:00
for (int j1 = 0; j1 < this.u.size(); ++j1) {
((IWorldAccess) this.u.get(j1)).a(entityhuman, i, j, k, l, i1);
2011-05-26 14:48:22 +02:00
}
}
2011-07-13 06:06:07 +02:00
2012-03-01 11:49:23 +01:00
public int getHeight() {
return 256;
}
public Random A(int i, int j, int k) {
long l = (long) i * 341873128712L + (long) j * 132897987541L + this.getWorldData().getSeed() + (long) k;
2011-09-15 02:23:52 +02:00
this.random.setSeed(l);
return this.random;
}
public boolean updateLights() {
2011-09-15 02:23:52 +02:00
return false;
}
2011-11-20 09:01:14 +01:00
public BiomeMeta a(EnumCreatureType enumcreaturetype, int i, int j, int k) {
2012-03-01 11:49:23 +01:00
List list = this.q().getMobsFor(enumcreaturetype, i, j, k);
2011-11-20 09:01:14 +01:00
return list != null && !list.isEmpty() ? (BiomeMeta) WeightedRandom.a(this.random, (Collection) list) : null;
}
public ChunkPosition b(String s, int i, int j, int k) {
2012-03-01 11:49:23 +01:00
return this.q().findNearestMapFeature(this, s, i, j, k);
2011-11-20 09:01:14 +01:00
}
2011-07-13 06:06:07 +02:00
// CraftBukkit start
public UUID getUUID() {
return this.dataManager.getUUID();
2011-07-13 06:06:07 +02:00
}
// CraftBukkit end
2011-02-07 06:56:07 +01:00
}