2011-02-07 06:56:07 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2012-10-25 05:53:23 +02:00
|
|
|
import java.util.Calendar;
|
2011-06-30 00:02:25 +02:00
|
|
|
import java.util.Collection;
|
2012-10-25 05:53:23 +02:00
|
|
|
import java.util.HashSet;
|
2011-02-07 06:56:07 +01:00
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
2012-10-25 05:53:23 +02:00
|
|
|
import java.util.Set;
|
2012-07-29 09:33:13 +02:00
|
|
|
import java.util.concurrent.Callable;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-02-07 10:43:50 +01:00
|
|
|
// CraftBukkit start
|
2011-06-17 04:06:45 +02:00
|
|
|
import org.bukkit.Bukkit;
|
2013-12-02 00:42:26 +01:00
|
|
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
2012-08-18 01:53:59 +02:00
|
|
|
import org.bukkit.craftbukkit.util.LongHashSet;
|
2012-08-17 19:55:33 +02:00
|
|
|
import org.bukkit.craftbukkit.util.UnsafeList;
|
2011-06-06 15:52:02 +02:00
|
|
|
import org.bukkit.generator.ChunkGenerator;
|
2011-04-26 01:47:25 +02:00
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
2011-02-07 10:43:50 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftWorld;
|
2011-03-20 21:18:38 +01:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2011-02-07 10:43:50 +01:00
|
|
|
import org.bukkit.event.block.BlockCanBuildEvent;
|
|
|
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
2011-06-21 22:20:11 +02:00
|
|
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
2011-04-26 01:47:25 +02:00
|
|
|
import org.bukkit.event.weather.WeatherChangeEvent;
|
|
|
|
import org.bukkit.event.weather.ThunderChangeEvent;
|
2011-02-07 10:43:50 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public abstract class World implements IBlockAccess {
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public boolean d;
|
2012-03-01 11:49:23 +01:00
|
|
|
public List entityList = new ArrayList();
|
2012-10-25 05:53:23 +02:00
|
|
|
protected List f = new ArrayList();
|
2013-04-12 01:11:10 +02:00
|
|
|
public Set tileEntityList = new HashSet(); // CraftBukkit - ArrayList -> HashSet
|
2012-07-29 09:33:13 +02:00
|
|
|
private List a = new ArrayList();
|
|
|
|
private List b = new ArrayList();
|
2012-03-01 11:49:23 +01:00
|
|
|
public List players = new ArrayList();
|
2012-10-25 05:53:23 +02:00
|
|
|
public List i = new ArrayList();
|
2012-07-29 09:33:13 +02:00
|
|
|
private long c = 16777215L;
|
2013-07-01 13:03:00 +02:00
|
|
|
public int j;
|
2012-10-25 05:53:23 +02:00
|
|
|
protected int k = (new Random()).nextInt();
|
|
|
|
protected final int l = 1013904223;
|
|
|
|
protected float m;
|
2012-07-29 09:33:13 +02:00
|
|
|
protected float n;
|
|
|
|
protected float o;
|
|
|
|
protected float p;
|
2013-07-01 13:03:00 +02:00
|
|
|
public int q;
|
2013-11-04 14:07:38 +01:00
|
|
|
public EnumDifficulty difficulty;
|
2012-03-01 11:49:23 +01:00
|
|
|
public Random random = new Random();
|
2011-06-12 00:02:58 +02:00
|
|
|
public WorldProvider worldProvider; // CraftBukkit - remove final
|
2013-03-13 23:33:27 +01:00
|
|
|
protected List u = new ArrayList();
|
2013-11-04 14:07:38 +01:00
|
|
|
public IChunkProvider chunkProvider; // CraftBukkit - public
|
2011-11-30 00:17:43 +01:00
|
|
|
protected final IDataManager dataManager;
|
2013-11-04 14:07:38 +01:00
|
|
|
public WorldData worldData; // CraftBukkit - public
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isLoading;
|
2013-11-04 14:07:38 +01:00
|
|
|
public PersistentCollection worldMaps;
|
|
|
|
public final PersistentVillage villages;
|
2012-07-29 09:33:13 +02:00
|
|
|
protected final VillageSiege siegeManager = new VillageSiege(this);
|
|
|
|
public final MethodProfiler methodProfiler;
|
2012-12-20 05:03:52 +01:00
|
|
|
private final Vec3DPool J = new Vec3DPool(300, 2000);
|
|
|
|
private final Calendar K = Calendar.getInstance();
|
2013-04-05 06:35:16 +02:00
|
|
|
public Scoreboard scoreboard = new Scoreboard(); // CraftBukkit - protected -> public
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean isStatic;
|
2012-07-29 09:33:13 +02:00
|
|
|
// CraftBukkit start - public, longhashset
|
2012-08-18 01:53:59 +02:00
|
|
|
protected LongHashSet chunkTickList = new LongHashSet();
|
2013-11-04 14:07:38 +01:00
|
|
|
private int L;
|
|
|
|
public boolean allowMonsters;
|
|
|
|
public boolean allowAnimals;
|
|
|
|
// Added the following
|
|
|
|
public boolean callingPlaceEvent = false;
|
2012-07-29 09:33:13 +02:00
|
|
|
public long ticksPerAnimalSpawns;
|
|
|
|
public long ticksPerMonsterSpawns;
|
|
|
|
// CraftBukkit end
|
2013-11-04 14:07:38 +01:00
|
|
|
private ArrayList M;
|
|
|
|
private boolean N;
|
|
|
|
int[] I;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
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);
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
try {
|
2013-07-01 13:03:00 +02:00
|
|
|
return chunk.a(i & 15, j & 15, this.worldProvider.e);
|
2013-11-04 14:07:38 +01:00
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.a(throwable, "Getting biome");
|
|
|
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Coordinates of biome request");
|
|
|
|
|
|
|
|
crashreportsystemdetails.a("Location", (Callable) (new CrashReportWorldLocation(this, i, j)));
|
|
|
|
throw new ReportedException(crashreport);
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
2013-11-04 14:07:38 +01:00
|
|
|
} else {
|
|
|
|
return this.worldProvider.e.getBiome(i, j);
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public WorldChunkManager getWorldChunkManager() {
|
2013-07-01 13:03:00 +02:00
|
|
|
return this.worldProvider.e;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-06-12 00:02:58 +02:00
|
|
|
// CraftBukkit start
|
2011-06-17 04:06:45 +02:00
|
|
|
private final CraftWorld world;
|
2011-06-12 00:02:58 +02:00
|
|
|
public boolean pvpMode;
|
2011-07-27 01:24:27 +02:00
|
|
|
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();
|
|
|
|
|
2011-06-17 04:06:45 +02:00
|
|
|
public CraftWorld getWorld() {
|
2011-06-27 00:25:01 +02:00
|
|
|
return this.world;
|
2011-06-17 04:06:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public CraftServer getServer() {
|
2011-06-27 00:25:01 +02:00
|
|
|
return (CraftServer) Bukkit.getServer();
|
2011-06-17 04:06:45 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
// Changed signature - added gen and env
|
|
|
|
public World(IDataManager idatamanager, String s, WorldSettings worldsettings, WorldProvider worldprovider, MethodProfiler methodprofiler, ChunkGenerator gen, org.bukkit.World.Environment env) {
|
2011-06-06 15:52:02 +02:00
|
|
|
this.generator = gen;
|
2011-06-27 00:25:01 +02:00
|
|
|
this.world = new CraftWorld((WorldServer) this, gen, env);
|
2012-02-10 16:23:52 +01:00
|
|
|
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
|
|
|
|
this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit
|
2012-07-29 09:33:13 +02:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
this.L = this.random.nextInt(12000);
|
|
|
|
this.allowMonsters = true;
|
|
|
|
this.allowAnimals = true;
|
|
|
|
this.M = new ArrayList();
|
|
|
|
this.I = new int['\u8000'];
|
2011-11-30 00:17:43 +01:00
|
|
|
this.dataManager = idatamanager;
|
2012-07-29 09:33:13 +02:00
|
|
|
this.methodProfiler = methodprofiler;
|
2013-11-04 14:07:38 +01:00
|
|
|
this.worldMaps = new PersistentCollection(idatamanager);
|
2011-11-30 00:17:43 +01:00
|
|
|
this.worldData = idatamanager.getWorldData();
|
2011-02-07 06:56:07 +01:00
|
|
|
if (worldprovider != null) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.worldProvider = worldprovider;
|
2012-10-25 05:53:23 +02:00
|
|
|
} else if (this.worldData != null && this.worldData.j() != 0) {
|
|
|
|
this.worldProvider = WorldProvider.byDimension(this.worldData.j());
|
2011-02-23 03:37:56 +01:00
|
|
|
} else {
|
2011-06-27 00:25:01 +02:00
|
|
|
this.worldProvider = WorldProvider.byDimension(0);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.worldData == null) {
|
2011-09-15 02:23:52 +02:00
|
|
|
this.worldData = new WorldData(worldsettings, s);
|
2011-02-23 03:37:56 +01:00
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.worldData.setName(s);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.worldProvider.a(this);
|
2012-10-25 05:53:23 +02:00
|
|
|
this.chunkProvider = this.j();
|
2012-07-29 09:33:13 +02:00
|
|
|
if (!this.worldData.isInitialized()) {
|
2012-11-06 13:05:28 +01:00
|
|
|
try {
|
|
|
|
this.a(worldsettings);
|
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.a(throwable, "Exception initializing level");
|
|
|
|
|
|
|
|
try {
|
|
|
|
this.a(crashreport);
|
|
|
|
} catch (Throwable throwable1) {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new ReportedException(crashreport);
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.worldData.d(true);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
PersistentVillage persistentvillage = (PersistentVillage) this.worldMaps.get(PersistentVillage.class, "villages");
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (persistentvillage == null) {
|
|
|
|
this.villages = new PersistentVillage(this);
|
2012-10-25 05:53:23 +02:00
|
|
|
this.worldMaps.a("villages", this.villages);
|
|
|
|
} else {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.villages = persistentvillage;
|
2012-10-25 05:53:23 +02:00
|
|
|
this.villages.a(this);
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
this.A();
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a();
|
2011-06-17 04:06:45 +02:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
this.getServer().addWorld(this.world); // CraftBukkit
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
protected abstract IChunkProvider j();
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void a(WorldSettings worldsettings) {
|
|
|
|
this.worldData.d(true);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public Block 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
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
return this.getType(i, k, j);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public Block getType(int i, int j, int k) {
|
|
|
|
if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000 && j >= 0 && j < 256) {
|
|
|
|
Chunk chunk = null;
|
2012-11-06 13:05:28 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
try {
|
|
|
|
chunk = this.getChunkAt(i >> 4, k >> 4);
|
|
|
|
return chunk.getType(i & 15, j, k & 15);
|
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.a(throwable, "Exception getting block type in world");
|
|
|
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Requested block coordinates");
|
|
|
|
|
|
|
|
crashreportsystemdetails.a("Found chunk", Boolean.valueOf(chunk == null));
|
|
|
|
crashreportsystemdetails.a("Location", CrashReportSystemDetails.a(i, j, k));
|
|
|
|
throw new ReportedException(crashreport);
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
|
|
|
} else {
|
2013-11-04 14:07:38 +01:00
|
|
|
return Blocks.AIR;
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
public boolean isEmpty(int i, int j, int k) {
|
2013-11-04 14:07:38 +01:00
|
|
|
return this.getType(i, j, k).getMaterial() == Material.AIR;
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02: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
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
public boolean areChunksLoaded(int i, int j, int k, int l) {
|
2013-11-04 14:07:38 +01:00
|
|
|
return this.b(i - l, j - l, k - l, i + l, j + l, k + l);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean b(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) {
|
2012-08-19 23:06:14 +02:00
|
|
|
// CraftBukkit - check unload queue too so we don't leak a chunk
|
|
|
|
if (!this.isChunkLoaded(k1, l1) || ((WorldServer) this).chunkProviderServer.unloadQueue.contains(k1, l1)) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected boolean isChunkLoaded(int i, int j) {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.chunkProvider.isChunkLoaded(i, j);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
public Chunk getChunkAtWorldCoords(int i, int j) {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.getChunkAt(i >> 4, j >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public Chunk getChunkAt(int i, int j) {
|
2013-11-04 14:07:38 +01:00
|
|
|
// CraftBukkit start
|
2011-02-10 12:56:30 +01:00
|
|
|
Chunk result = null;
|
2011-06-27 00:25:01 +02:00
|
|
|
synchronized (this.chunkLock) {
|
|
|
|
if (this.lastChunkAccessed == null || this.lastXAccessed != i || this.lastZAccessed != j) {
|
2012-09-21 06:00:34 +02:00
|
|
|
this.lastChunkAccessed = this.chunkProvider.getOrCreateChunk(i, j);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.lastXAccessed = i;
|
|
|
|
this.lastZAccessed = j;
|
2011-02-10 12:56:30 +01:00
|
|
|
}
|
2011-06-27 00:25:01 +02:00
|
|
|
result = this.lastChunkAccessed;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
2011-02-10 12:56:30 +01:00
|
|
|
return result;
|
2013-11-04 14:07:38 +01:00
|
|
|
// CraftBukkit end
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean setTypeAndData(int i, int j, int k, Block block, 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 {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block1 = null;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if ((i1 & 1) != 0) {
|
|
|
|
block1 = chunk.getType(i & 15, j, k & 15);
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
boolean flag = chunk.a(i & 15, j, k & 15, block, l);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.a("checkLight");
|
2013-11-04 14:07:38 +01:00
|
|
|
this.t(i, j, k);
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.b();
|
2013-03-13 23:33:27 +01:00
|
|
|
if (flag) {
|
2013-11-04 14:07:38 +01:00
|
|
|
if ((i1 & 2) != 0 && (!this.isStatic || (i1 & 4) == 0) && chunk.k()) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.notify(i, j, k);
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (!this.isStatic && (i1 & 1) != 0) {
|
|
|
|
this.update(i, j, k, block1);
|
|
|
|
if (block.M()) {
|
|
|
|
this.f(i, j, k, block);
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
return flag;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
i &= 15;
|
|
|
|
k &= 15;
|
2011-04-20 19:05:14 +02:00
|
|
|
return chunk.getData(i, j, k);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean setData(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 {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2013-03-13 23:33:27 +01:00
|
|
|
int j1 = i & 15;
|
|
|
|
int k1 = k & 15;
|
2013-11-04 14:07:38 +01:00
|
|
|
boolean flag = chunk.a(j1, j, k1, l);
|
2013-03-13 23:33:27 +01:00
|
|
|
|
|
|
|
if (flag) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = chunk.getType(j1, j, k1);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if ((i1 & 2) != 0 && (!this.isStatic || (i1 & 4) == 0) && chunk.k()) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.notify(i, j, k);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.isStatic && (i1 & 1) != 0) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.update(i, j, k, block);
|
|
|
|
if (block.M()) {
|
|
|
|
this.f(i, j, k, block);
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return flag;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean setAir(int i, int j, int k) {
|
2013-11-04 14:07:38 +01:00
|
|
|
return this.setTypeAndData(i, j, k, Blocks.AIR, 0, 3);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean setAir(int i, int j, int k, boolean flag) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = this.getType(i, j, k);
|
2013-03-13 23:33:27 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (block.getMaterial() == Material.AIR) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
int l = this.getData(i, j, k);
|
2013-03-13 23:33:27 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
this.triggerEffect(2001, i, j, k, Block.b(block) + (l << 12));
|
2013-03-13 23:33:27 +01:00
|
|
|
if (flag) {
|
2013-11-04 14:07:38 +01:00
|
|
|
block.b(this, i, j, k, l, 0);
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
return this.setTypeAndData(i, j, k, Blocks.AIR, 0, 3);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean setTypeUpdate(int i, int j, int k, Block block) {
|
|
|
|
return this.setTypeAndData(i, j, k, block, 0, 3);
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void notify(int i, int j, int k) {
|
2013-03-13 23:33:27 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void update(int i, int j, int k, Block block) {
|
|
|
|
this.applyPhysics(i, j, k, block);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void b(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;
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (!this.worldProvider.g) {
|
2011-11-20 09:01:14 +01:00
|
|
|
for (i1 = k; i1 <= l; ++i1) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c(EnumSkyBlock.SKY, i, i1, j);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
this.c(i, k, j, i, l, j);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void c(int i, int j, int k, int l, int i1, int j1) {
|
2013-03-13 23:33:27 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void applyPhysics(int i, int j, int k, Block block) {
|
|
|
|
this.e(i - 1, j, k, block);
|
|
|
|
this.e(i + 1, j, k, block);
|
|
|
|
this.e(i, j - 1, k, block);
|
|
|
|
this.e(i, j + 1, k, block);
|
|
|
|
this.e(i, j, k - 1, block);
|
|
|
|
this.e(i, j, k + 1, block);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void b(int i, int j, int k, Block block, int l) {
|
|
|
|
if (l != 4) {
|
|
|
|
this.e(i - 1, j, k, block);
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (l != 5) {
|
|
|
|
this.e(i + 1, j, k, block);
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (l != 0) {
|
|
|
|
this.e(i, j - 1, k, block);
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (l != 1) {
|
|
|
|
this.e(i, j + 1, k, block);
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (l != 2) {
|
|
|
|
this.e(i, j, k - 1, block);
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (l != 3) {
|
|
|
|
this.e(i, j, k + 1, block);
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void e(int i, int j, int k, Block block) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (!this.isStatic) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block1 = this.getType(i, j, k);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
try {
|
|
|
|
// CraftBukkit start
|
|
|
|
CraftWorld world = ((WorldServer) this).getWorld();
|
|
|
|
if (world != null) {
|
|
|
|
BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(i, j, k), l);
|
|
|
|
this.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
|
|
|
return;
|
2011-02-07 10:26:12 +01:00
|
|
|
}
|
2013-11-04 14:07:38 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-02-07 10:26:12 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
block1.doPhysics(this, i, j, k, block);
|
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours");
|
|
|
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being updated");
|
2012-11-06 13:05:28 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
int l;
|
2012-11-06 13:05:28 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
try {
|
|
|
|
l = this.getData(i, j, k);
|
|
|
|
} catch (Throwable throwable1) {
|
|
|
|
l = -1;
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
2013-11-04 14:07:38 +01:00
|
|
|
|
|
|
|
crashreportsystemdetails.a("Source block type", (Callable) (new CrashReportSourceBlockType(this, block)));
|
|
|
|
CrashReportSystemDetails.a(crashreportsystemdetails, i, j, k, block1, l);
|
|
|
|
throw new ReportedException(crashreport);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean a(int i, int j, int k, Block block) {
|
2013-03-13 23:33:27 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean i(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
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public int j(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
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
return this.getChunkAt(i >> 4, k >> 4).b(i & 15, j, k & 15, 0);
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public int getLightLevel(int i, int j, int k) {
|
2013-03-13 23:33:27 +01:00
|
|
|
return this.b(i, j, k, true);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public int b(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) {
|
2013-11-04 14:07:38 +01:00
|
|
|
if (flag && this.getType(i, j, k).n()) {
|
|
|
|
int l = this.b(i, j + 1, k, false);
|
|
|
|
int i1 = this.b(i + 1, j, k, false);
|
|
|
|
int j1 = this.b(i - 1, j, k, false);
|
|
|
|
int k1 = this.b(i, j, k + 1, false);
|
|
|
|
int l1 = this.b(i, j, k - 1, false);
|
|
|
|
|
|
|
|
if (i1 > l) {
|
|
|
|
l = i1;
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (j1 > l) {
|
|
|
|
l = j1;
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (k1 > l) {
|
|
|
|
l = k1;
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (l1 > l) {
|
|
|
|
l = l1;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
return l;
|
|
|
|
} else if (j < 0) {
|
2011-02-07 06:56:07 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
i &= 15;
|
|
|
|
k &= 15;
|
2013-11-04 14:07:38 +01:00
|
|
|
return chunk.b(i, j, k, this.j);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return 15;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public int getHighestBlockYAt(int i, int j) {
|
2011-09-15 02:23:52 +02:00
|
|
|
if (i >= -30000000 && j >= -30000000 && i < 30000000 && j < 30000000) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!this.isChunkLoaded(i >> 4, j >> 4)) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return 0;
|
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, j >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
return chunk.b(i & 15, j & 15);
|
|
|
|
}
|
|
|
|
} else {
|
2013-11-04 14:07:38 +01:00
|
|
|
return 64;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public int g(int i, int j) {
|
|
|
|
if (i >= -30000000 && j >= -30000000 && i < 30000000 && j < 30000000) {
|
|
|
|
if (!this.isChunkLoaded(i >> 4, j >> 4)) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, j >> 4);
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
return chunk.r;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
} else {
|
2013-11-04 14:07:38 +01:00
|
|
|
return 64;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public int b(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;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
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 {
|
2011-04-20 19:05:14 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void b(EnumSkyBlock enumskyblock, 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) {
|
2012-03-01 11:49:23 +01:00
|
|
|
if (j < 256) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.isChunkLoaded(i >> 4, k >> 4)) {
|
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
chunk.a(enumskyblock, i & 15, j, k & 15, l);
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2013-03-13 23:33:27 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void m(int i, int j, int k) {
|
2013-03-13 23:33:27 +01:00
|
|
|
for (int l = 0; l < this.u.size(); ++l) {
|
|
|
|
((IWorldAccess) this.u.get(l)).b(i, j, k);
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public float n(int i, int j, int k) {
|
2013-07-01 13:03:00 +02:00
|
|
|
return this.worldProvider.h[this.getLightLevel(i, j, k)];
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-04-27 11:40:05 +02:00
|
|
|
public boolean v() {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.j < 4;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public MovingObjectPosition a(Vec3D vec3d, Vec3D vec3d1) {
|
2013-11-04 14:07:38 +01:00
|
|
|
return this.rayTrace(vec3d, vec3d1, false, false, false);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public MovingObjectPosition rayTrace(Vec3D vec3d, Vec3D vec3d1, boolean flag) {
|
2013-11-04 14:07:38 +01:00
|
|
|
return this.rayTrace(vec3d, vec3d1, flag, false, false);
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public MovingObjectPosition rayTrace(Vec3D vec3d, Vec3D vec3d1, boolean flag, boolean flag1, boolean flag2) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (!Double.isNaN(vec3d.c) && !Double.isNaN(vec3d.d) && !Double.isNaN(vec3d.e)) {
|
|
|
|
if (!Double.isNaN(vec3d1.c) && !Double.isNaN(vec3d1.d) && !Double.isNaN(vec3d1.e)) {
|
|
|
|
int i = MathHelper.floor(vec3d1.c);
|
|
|
|
int j = MathHelper.floor(vec3d1.d);
|
|
|
|
int k = MathHelper.floor(vec3d1.e);
|
|
|
|
int l = MathHelper.floor(vec3d.c);
|
|
|
|
int i1 = MathHelper.floor(vec3d.d);
|
|
|
|
int j1 = MathHelper.floor(vec3d.e);
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = this.getType(l, i1, j1);
|
|
|
|
int k1 = this.getData(l, i1, j1);
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if ((!flag1 || block.a(this, l, i1, j1) != null) && block.a(k1, flag)) {
|
2011-05-26 14:48:22 +02:00
|
|
|
MovingObjectPosition movingobjectposition = block.a(this, l, i1, j1, vec3d, vec3d1);
|
|
|
|
|
|
|
|
if (movingobjectposition != null) {
|
|
|
|
return movingobjectposition;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
MovingObjectPosition movingobjectposition1 = null;
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
k1 = 200;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
while (k1-- >= 0) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (Double.isNaN(vec3d.c) || Double.isNaN(vec3d.d) || Double.isNaN(vec3d.e)) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == i && i1 == j && j1 == k) {
|
2013-11-04 14:07:38 +01:00
|
|
|
return flag2 ? movingobjectposition1 : null;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
boolean flag3 = true;
|
|
|
|
boolean flag4 = true;
|
2013-11-04 14:07:38 +01:00
|
|
|
boolean flag5 = 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 {
|
2013-11-04 14:07:38 +01:00
|
|
|
flag3 = 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 {
|
2013-11-04 14:07:38 +01:00
|
|
|
flag4 = 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 {
|
2013-11-04 14:07:38 +01:00
|
|
|
flag5 = false;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
double d3 = 999.0D;
|
|
|
|
double d4 = 999.0D;
|
|
|
|
double d5 = 999.0D;
|
2012-10-25 05:53:23 +02:00
|
|
|
double d6 = vec3d1.c - vec3d.c;
|
|
|
|
double d7 = vec3d1.d - vec3d.d;
|
|
|
|
double d8 = vec3d1.e - vec3d.e;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (flag3) {
|
2012-10-25 05:53:23 +02:00
|
|
|
d3 = (d0 - vec3d.c) / d6;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (flag4) {
|
2012-10-25 05:53:23 +02:00
|
|
|
d4 = (d1 - vec3d.d) / d7;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (flag5) {
|
2012-10-25 05:53:23 +02:00
|
|
|
d5 = (d2 - vec3d.e) / d8;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
boolean flag6 = false;
|
2011-02-07 06:56:07 +01:00
|
|
|
byte b0;
|
|
|
|
|
|
|
|
if (d3 < d4 && d3 < d5) {
|
|
|
|
if (i > l) {
|
|
|
|
b0 = 4;
|
|
|
|
} else {
|
|
|
|
b0 = 5;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
vec3d.c = d0;
|
|
|
|
vec3d.d += d7 * d3;
|
|
|
|
vec3d.e += d8 * d3;
|
2011-02-07 06:56:07 +01:00
|
|
|
} else if (d4 < d5) {
|
|
|
|
if (j > i1) {
|
|
|
|
b0 = 0;
|
|
|
|
} else {
|
|
|
|
b0 = 1;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
vec3d.c += d6 * d4;
|
|
|
|
vec3d.d = d1;
|
|
|
|
vec3d.e += d8 * d4;
|
2011-02-07 06:56:07 +01:00
|
|
|
} else {
|
|
|
|
if (k > j1) {
|
|
|
|
b0 = 2;
|
|
|
|
} else {
|
|
|
|
b0 = 3;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
vec3d.c += d6 * d5;
|
|
|
|
vec3d.d += d7 * d5;
|
|
|
|
vec3d.e = d2;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
Vec3D vec3d2 = this.getVec3DPool().create(vec3d.c, vec3d.d, vec3d.e);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
l = (int) (vec3d2.c = (double) MathHelper.floor(vec3d.c));
|
2011-02-07 06:56:07 +01:00
|
|
|
if (b0 == 5) {
|
|
|
|
--l;
|
2012-10-25 05:53:23 +02:00
|
|
|
++vec3d2.c;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
i1 = (int) (vec3d2.d = (double) MathHelper.floor(vec3d.d));
|
2011-02-07 06:56:07 +01:00
|
|
|
if (b0 == 1) {
|
|
|
|
--i1;
|
2012-10-25 05:53:23 +02:00
|
|
|
++vec3d2.d;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
j1 = (int) (vec3d2.e = (double) MathHelper.floor(vec3d.e));
|
2011-02-07 06:56:07 +01:00
|
|
|
if (b0 == 3) {
|
|
|
|
--j1;
|
2012-10-25 05:53:23 +02:00
|
|
|
++vec3d2.e;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block1 = this.getType(l, i1, j1);
|
|
|
|
int l1 = this.getData(l, i1, j1);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (!flag1 || block1.a(this, l, i1, j1) != null) {
|
|
|
|
if (block1.a(l1, flag)) {
|
|
|
|
MovingObjectPosition movingobjectposition2 = block1.a(this, l, i1, j1, vec3d, vec3d1);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (movingobjectposition2 != null) {
|
|
|
|
vec3d2.b.release(vec3d2); // CraftBukkit
|
|
|
|
return movingobjectposition2;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
movingobjectposition1 = new MovingObjectPosition(l, i1, j1, b0, vec3d, false);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
vec3d2.b.release(vec3d2); // CraftBukkit
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
return flag2 ? movingobjectposition1 : null;
|
2011-02-07 06:56:07 +01:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void makeSound(Entity entity, String s, float f, float f1) {
|
2013-11-04 14:07:38 +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);
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public void a(EntityHuman entityhuman, String s, float f, float f1) {
|
2013-11-04 14:07:38 +01:00
|
|
|
for (int i = 0; i < this.u.size(); ++i) {
|
|
|
|
((IWorldAccess) this.u.get(i)).a(entityhuman, s, entityhuman.locX, entityhuman.locY - (double) entityhuman.height, entityhuman.locZ, f, f1);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void makeSound(double d0, double d1, double d2, String s, float f, float f1) {
|
2013-11-04 14:07:38 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-20 05:03:52 +01:00
|
|
|
public void a(double d0, double d1, double d2, String s, float f, float f1, boolean flag) {}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
public void a(String s, int i, int j, int k) {
|
2013-03-13 23:33:27 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void addParticle(String s, double d0, double d1, double d2, double d3, double d4, double d5) {
|
2013-03-13 23:33:27 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
public boolean strikeLightning(Entity entity) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.i.add(entity);
|
2011-04-20 22:47:26 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean addEntity(Entity entity) {
|
2013-11-04 14:07:38 +01:00
|
|
|
// CraftBukkit start - Used for entities other than creatures
|
2012-04-14 08:44:01 +02:00
|
|
|
return this.addEntity(entity, SpawnReason.DEFAULT); // Set reason as DEFAULT
|
2011-06-21 22:20:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
|
2012-01-27 19:42:04 +01:00
|
|
|
if (entity == null) return false;
|
2012-01-28 09:04:16 +01:00
|
|
|
// CraftBukkit end
|
2012-01-27 19:42:04 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(entity.locX / 16.0D);
|
|
|
|
int j = MathHelper.floor(entity.locZ / 16.0D);
|
2013-11-04 14:07:38 +01:00
|
|
|
boolean flag = entity.o;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
flag = true;
|
|
|
|
}
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start
|
2012-04-04 00:41:55 +02:00
|
|
|
org.bukkit.event.Cancellable event = null;
|
2011-04-01 09:15:48 +02:00
|
|
|
if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
|
2012-03-11 11:28:03 +01:00
|
|
|
boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
|
2011-09-20 04:53:36 +02:00
|
|
|
boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;
|
|
|
|
|
2012-04-14 13:56:23 +02:00
|
|
|
if (spawnReason != SpawnReason.CUSTOM) {
|
2012-04-04 00:41:55 +02:00
|
|
|
if (isAnimal && !allowAnimals || isMonster && !allowMonsters) {
|
|
|
|
entity.dead = true;
|
|
|
|
return false;
|
|
|
|
}
|
2011-09-20 04:53:36 +02:00
|
|
|
}
|
|
|
|
|
2012-04-04 00:41:55 +02:00
|
|
|
event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
|
2011-06-11 08:00:05 +02:00
|
|
|
} else if (entity instanceof EntityItem) {
|
2012-04-04 00:41:55 +02:00
|
|
|
event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
|
2012-03-12 17:45:09 +01:00
|
|
|
} else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
|
|
|
|
// Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
|
2012-04-04 00:41:55 +02:00
|
|
|
event = CraftEventFactory.callProjectileLaunchEvent(entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event != null && (event.isCancelled() || entity.dead)) {
|
|
|
|
entity.dead = true;
|
|
|
|
return false;
|
2011-02-17 04:42:41 +01:00
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
// CraftBukkit end
|
2011-02-17 04:42:41 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (!flag && !this.isChunkLoaded(i, j)) {
|
2012-04-04 00:41:55 +02:00
|
|
|
entity.dead = true; // CraftBukkit
|
2011-02-07 06:56:07 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) entity;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.players.add(entityhuman);
|
|
|
|
this.everyoneSleeping();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.getChunkAt(i, j).a(entity);
|
|
|
|
this.entityList.add(entity);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void a(Entity entity) {
|
2013-03-13 23:33:27 +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
|
|
|
}
|
2012-08-22 03:21:01 +02:00
|
|
|
|
|
|
|
entity.valid = true; // CraftBukkit
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void b(Entity entity) {
|
2013-03-13 23:33:27 +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
|
|
|
}
|
2012-06-25 10:24:53 +02:00
|
|
|
|
|
|
|
entity.valid = false; // CraftBukkit
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void kill(Entity entity) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (entity.passenger != null) {
|
2011-04-20 19:05:14 +02:00
|
|
|
entity.passenger.mount((Entity) null);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (entity.vehicle != null) {
|
2011-04-20 19:05:14 +02:00
|
|
|
entity.mount((Entity) null);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
entity.die();
|
2011-02-07 06:56:07 +01:00
|
|
|
if (entity instanceof EntityHuman) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.players.remove(entity);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.everyoneSleeping();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void removeEntity(Entity entity) {
|
|
|
|
entity.die();
|
2011-02-07 06:56:07 +01:00
|
|
|
if (entity instanceof EntityHuman) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.players.remove(entity);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.everyoneSleeping();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
int i = entity.ai;
|
|
|
|
int j = entity.ak;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (entity.ah && this.isChunkLoaded(i, j)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.getChunkAt(i, j).b(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.entityList.remove(entity);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void addIWorldAccess(IWorldAccess iworldaccess) {
|
2013-03-13 23:33:27 +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) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.M.clear();
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
for (int k1 = i; k1 < j; ++k1) {
|
|
|
|
for (int l1 = i1; l1 < j1; ++l1) {
|
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) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (k1 >= -30000000 && k1 < 30000000 && l1 >= -30000000 && l1 < 30000000) {
|
|
|
|
block = this.getType(k1, i2, l1);
|
|
|
|
} else {
|
|
|
|
block = Blocks.STONE;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
2013-11-04 14:07:38 +01:00
|
|
|
|
|
|
|
block.a(this, k1, i2, l1, axisalignedbb, this.M, entity);
|
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
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
for (int j2 = 0; j2 < list.size(); ++j2) {
|
2013-11-04 14:07:38 +01:00
|
|
|
AxisAlignedBB axisalignedbb1 = ((Entity) list.get(j2)).J();
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (axisalignedbb1 != null && axisalignedbb1.b(axisalignedbb)) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.M.add(axisalignedbb1);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
axisalignedbb1 = entity.g((Entity) list.get(j2));
|
2013-07-01 13:03:00 +02:00
|
|
|
if (axisalignedbb1 != null && axisalignedbb1.b(axisalignedbb)) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.M.add(axisalignedbb1);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
return this.M;
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public List a(AxisAlignedBB axisalignedbb) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.M.clear();
|
2012-07-29 09:33:13 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
|
|
|
|
|
|
|
for (int k1 = i; k1 < j; ++k1) {
|
|
|
|
for (int l1 = i1; l1 < j1; ++l1) {
|
|
|
|
if (this.isLoaded(k1, 64, l1)) {
|
|
|
|
for (int i2 = k - 1; i2 < l; ++i2) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block;
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (k1 >= -30000000 && k1 < 30000000 && l1 >= -30000000 && l1 < 30000000) {
|
|
|
|
block = this.getType(k1, i2, l1);
|
|
|
|
} else {
|
|
|
|
block = Blocks.BEDROCK;
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
2013-11-04 14:07:38 +01:00
|
|
|
|
|
|
|
block.a(this, k1, i2, l1, axisalignedbb, this.M, (Entity) null);
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
return this.M;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int a(float f) {
|
2012-07-29 09:33:13 +02:00
|
|
|
float f1 = this.c(f);
|
2011-04-20 19:05:14 +02:00
|
|
|
float f2 = 1.0F - (MathHelper.cos(f1 * 3.1415927F * 2.0F) * 2.0F + 0.5F);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
if (f2 < 0.0F) {
|
|
|
|
f2 = 0.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (f2 > 1.0F) {
|
|
|
|
f2 = 1.0F;
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
f2 = 1.0F - f2;
|
2013-11-04 14:07:38 +01:00
|
|
|
f2 = (float) ((double) f2 * (1.0D - (double) (this.j(f) * 5.0F) / 16.0D));
|
2013-03-13 23:33:27 +01:00
|
|
|
f2 = (float) ((double) f2 * (1.0D - (double) (this.h(f) * 5.0F) / 16.0D));
|
2011-04-20 22:47:26 +02:00
|
|
|
f2 = 1.0F - f2;
|
2011-02-07 06:56:07 +01:00
|
|
|
return (int) (f2 * 11.0F);
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public float c(float f) {
|
2012-11-06 13:05:28 +01:00
|
|
|
return this.worldProvider.a(this.worldData.getDayTime(), f);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public float x() {
|
|
|
|
return WorldProvider.a[this.worldProvider.a(this.worldData.getDayTime())];
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public float d(float f) {
|
|
|
|
float f1 = this.c(f);
|
|
|
|
|
|
|
|
return f1 * 3.1415927F * 2.0F;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public int h(int i, int j) {
|
2012-03-01 11:49:23 +01:00
|
|
|
return this.getChunkAtWorldCoords(i, j).d(i & 15, j & 15);
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public int i(int i, int j) {
|
2011-06-27 00:25:01 +02:00
|
|
|
Chunk chunk = this.getChunkAtWorldCoords(i, j);
|
2012-07-29 09:33:13 +02:00
|
|
|
int k = chunk.h() + 15;
|
2011-05-26 14:48:22 +02:00
|
|
|
|
|
|
|
i &= 15;
|
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
for (j &= 15; k > 0; --k) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = chunk.getType(i, k, j);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (block.getMaterial().isSolid() && block.getMaterial() != Material.LEAVES) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return k + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void a(int i, int j, int k, Block block, int l) {}
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void a(int i, int j, int k, Block block, int l, int i1) {}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void b(int i, int j, int k, Block block, int l, int i1) {}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public void tickEntities() {
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.a("entities");
|
|
|
|
this.methodProfiler.a("global");
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
int i;
|
|
|
|
Entity entity;
|
2012-11-06 13:05:28 +01:00
|
|
|
CrashReport crashreport;
|
|
|
|
CrashReportSystemDetails crashreportsystemdetails;
|
2011-04-20 22:47:26 +02:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
for (i = 0; i < this.i.size(); ++i) {
|
|
|
|
entity = (Entity) this.i.get(i);
|
2013-03-25 05:22:32 +01:00
|
|
|
// CraftBukkit start - Fixed an NPE, don't process entities in chunks queued for unload
|
2012-08-18 01:53:59 +02:00
|
|
|
if (entity == null) {
|
2012-08-04 09:22:57 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-09-25 23:09:22 +02:00
|
|
|
ChunkProviderServer chunkProviderServer = ((WorldServer) this).chunkProviderServer;
|
2012-08-18 01:53:59 +02:00
|
|
|
if (chunkProviderServer.unloadQueue.contains(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4)) {
|
2011-06-18 05:36:35 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
try {
|
2012-12-20 05:03:52 +01:00
|
|
|
++entity.ticksLived;
|
2013-11-04 14:07:38 +01:00
|
|
|
entity.h();
|
2012-11-06 13:05:28 +01:00
|
|
|
} catch (Throwable throwable) {
|
|
|
|
crashreport = CrashReport.a(throwable, "Ticking entity");
|
|
|
|
crashreportsystemdetails = crashreport.a("Entity being ticked");
|
|
|
|
if (entity == null) {
|
|
|
|
crashreportsystemdetails.a("Entity", "~~NULL~~");
|
|
|
|
} else {
|
|
|
|
entity.a(crashreportsystemdetails);
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new ReportedException(crashreport);
|
|
|
|
}
|
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (entity.dead) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.i.remove(i--);
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.c("remove");
|
2012-10-25 05:53:23 +02:00
|
|
|
this.entityList.removeAll(this.f);
|
2011-04-20 22:47:26 +02:00
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
int j;
|
|
|
|
int k;
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
for (i = 0; i < this.f.size(); ++i) {
|
|
|
|
entity = (Entity) this.f.get(i);
|
2013-11-04 14:07:38 +01:00
|
|
|
j = entity.ai;
|
|
|
|
k = entity.ak;
|
|
|
|
if (entity.ah && this.isChunkLoaded(j, k)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.getChunkAt(j, k).b(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
for (i = 0; i < this.f.size(); ++i) {
|
|
|
|
this.b((Entity) this.f.get(i));
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
this.f.clear();
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.c("regular");
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
for (i = 0; i < this.entityList.size(); ++i) {
|
|
|
|
entity = (Entity) this.entityList.get(i);
|
2012-08-04 09:22:57 +02:00
|
|
|
|
2013-03-25 05:22:32 +01:00
|
|
|
// CraftBukkit start - Don't tick entities in chunks queued for unload
|
2012-09-25 23:09:22 +02:00
|
|
|
ChunkProviderServer chunkProviderServer = ((WorldServer) this).chunkProviderServer;
|
2012-08-18 01:53:59 +02:00
|
|
|
if (chunkProviderServer.unloadQueue.contains(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4)) {
|
2012-08-04 09:22:57 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.a("tick");
|
2011-02-07 06:56:07 +01:00
|
|
|
if (!entity.dead) {
|
2012-11-06 13:05:28 +01:00
|
|
|
try {
|
|
|
|
this.playerJoinedWorld(entity);
|
|
|
|
} catch (Throwable throwable1) {
|
|
|
|
crashreport = CrashReport.a(throwable1, "Ticking entity");
|
|
|
|
crashreportsystemdetails = crashreport.a("Entity being ticked");
|
2013-03-13 23:33:27 +01:00
|
|
|
entity.a(crashreportsystemdetails);
|
2012-11-06 13:05:28 +01:00
|
|
|
throw new ReportedException(crashreport);
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.b();
|
|
|
|
this.methodProfiler.a("remove");
|
2011-02-07 06:56:07 +01:00
|
|
|
if (entity.dead) {
|
2013-11-04 14:07:38 +01:00
|
|
|
j = entity.ai;
|
|
|
|
k = entity.ak;
|
|
|
|
if (entity.ah && this.isChunkLoaded(j, k)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.getChunkAt(j, k).b(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.entityList.remove(i--);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.b();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
this.methodProfiler.c("blockEntities");
|
2013-03-13 23:33:27 +01:00
|
|
|
this.N = true;
|
2012-11-06 13:05:28 +01:00
|
|
|
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();
|
2013-03-25 05:22:32 +01:00
|
|
|
// CraftBukkit start - Don't tick entities in chunks queued for unload
|
2012-09-25 23:09:22 +02:00
|
|
|
ChunkProviderServer chunkProviderServer = ((WorldServer) this).chunkProviderServer;
|
2012-08-18 01:53:59 +02:00
|
|
|
if (chunkProviderServer.unloadQueue.contains(tileentity.x >> 4, tileentity.z >> 4)) {
|
2012-08-04 09:22:57 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (!tileentity.r() && tileentity.o() && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) {
|
2012-11-06 13:05:28 +01:00
|
|
|
try {
|
2013-03-13 23:33:27 +01:00
|
|
|
tileentity.h();
|
2012-11-06 13:05:28 +01:00
|
|
|
} catch (Throwable throwable2) {
|
2013-11-04 14:07:38 +01:00
|
|
|
crashreport = CrashReport.a(throwable2, "Ticking block entity");
|
|
|
|
crashreportsystemdetails = crashreport.a("Block entity being ticked");
|
2013-03-13 23:33:27 +01:00
|
|
|
tileentity.a(crashreportsystemdetails);
|
2012-11-06 13:05:28 +01:00
|
|
|
throw new ReportedException(crashreport);
|
|
|
|
}
|
2011-06-30 00:02:25 +02:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (tileentity.r()) {
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
this.N = false;
|
2012-07-29 09:33:13 +02:00
|
|
|
if (!this.b.isEmpty()) {
|
|
|
|
this.tileEntityList.removeAll(this.b);
|
|
|
|
this.b.clear();
|
2011-08-04 12:57:51 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
this.methodProfiler.c("pendingBlockEntities");
|
2012-07-29 09:33:13 +02:00
|
|
|
if (!this.a.isEmpty()) {
|
2012-11-06 13:05:28 +01:00
|
|
|
for (int l = 0; l < this.a.size(); ++l) {
|
|
|
|
TileEntity tileentity1 = (TileEntity) this.a.get(l);
|
2011-06-30 00:02:25 +02:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (!tileentity1.r()) {
|
2013-03-25 05:22:32 +01:00
|
|
|
/* CraftBukkit start - Order matters, moved down
|
2012-07-29 09:33:13 +02:00
|
|
|
if (!this.tileEntityList.contains(tileentity1)) {
|
|
|
|
this.tileEntityList.add(tileentity1);
|
|
|
|
}
|
|
|
|
// CraftBukkit end */
|
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);
|
2013-03-25 05:22:32 +01:00
|
|
|
// CraftBukkit start - Moved down from above
|
2012-01-14 21:03:48 +01:00
|
|
|
if (!this.tileEntityList.contains(tileentity1)) {
|
|
|
|
this.tileEntityList.add(tileentity1);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-07-14 01:49:20 +02:00
|
|
|
}
|
2011-06-30 00:02:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.notify(tileentity1.x, tileentity1.y, tileentity1.z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a.clear();
|
2011-06-30 00:02:25 +02:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.b();
|
|
|
|
this.methodProfiler.b();
|
2011-06-30 00:02:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(Collection collection) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.N) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a.addAll(collection);
|
2011-06-30 00:02:25 +02:00
|
|
|
} else {
|
2012-01-14 21:03:48 +01:00
|
|
|
this.tileEntityList.addAll(collection);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void playerJoinedWorld(Entity entity) {
|
|
|
|
this.entityJoinedWorld(entity, true);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void entityJoinedWorld(Entity entity, boolean flag) {
|
|
|
|
int i = MathHelper.floor(entity.locX);
|
|
|
|
int j = MathHelper.floor(entity.locZ);
|
2011-02-07 06:56:07 +01:00
|
|
|
byte b0 = 32;
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (!flag || this.b(i - b0, 0, j - b0, i + b0, 0, j + b0)) {
|
|
|
|
entity.T = entity.locX;
|
|
|
|
entity.U = entity.locY;
|
|
|
|
entity.V = entity.locZ;
|
2011-02-07 06:56:07 +01:00
|
|
|
entity.lastYaw = entity.yaw;
|
|
|
|
entity.lastPitch = entity.pitch;
|
2013-11-04 14:07:38 +01:00
|
|
|
if (flag && entity.ah) {
|
2013-07-09 01:43:37 +02:00
|
|
|
++entity.ticksLived;
|
2011-02-07 06:56:07 +01:00
|
|
|
if (entity.vehicle != null) {
|
2013-11-04 14:07:38 +01:00
|
|
|
entity.ab();
|
2011-02-07 06:56:07 +01:00
|
|
|
} else {
|
2013-11-04 14:07:38 +01:00
|
|
|
entity.h();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.a("chunkCheck");
|
2011-02-07 06:56:07 +01:00
|
|
|
if (Double.isNaN(entity.locX) || Double.isInfinite(entity.locX)) {
|
2013-11-04 14:07:38 +01:00
|
|
|
entity.locX = entity.T;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Double.isNaN(entity.locY) || Double.isInfinite(entity.locY)) {
|
2013-11-04 14:07:38 +01:00
|
|
|
entity.locY = entity.U;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Double.isNaN(entity.locZ) || Double.isInfinite(entity.locZ)) {
|
2013-11-04 14:07:38 +01:00
|
|
|
entity.locZ = entity.V;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Double.isNaN((double) entity.pitch) || Double.isInfinite((double) entity.pitch)) {
|
|
|
|
entity.pitch = entity.lastPitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Double.isNaN((double) entity.yaw) || Double.isInfinite((double) entity.yaw)) {
|
|
|
|
entity.yaw = entity.lastYaw;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
int k = MathHelper.floor(entity.locX / 16.0D);
|
|
|
|
int l = MathHelper.floor(entity.locY / 16.0D);
|
|
|
|
int i1 = MathHelper.floor(entity.locZ / 16.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (!entity.ah || entity.ai != k || entity.aj != l || entity.ak != i1) {
|
|
|
|
if (entity.ah && this.isChunkLoaded(entity.ai, entity.ak)) {
|
|
|
|
this.getChunkAt(entity.ai, entity.ak).a(entity, entity.aj);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.isChunkLoaded(k, i1)) {
|
2013-11-04 14:07:38 +01:00
|
|
|
entity.ah = true;
|
2011-04-20 19:05:14 +02:00
|
|
|
this.getChunkAt(k, i1).a(entity);
|
2011-02-07 06:56:07 +01:00
|
|
|
} else {
|
2013-11-04 14:07:38 +01:00
|
|
|
entity.ah = false;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.b();
|
2013-11-04 14:07:38 +01:00
|
|
|
if (flag && entity.ah && entity.passenger != null) {
|
2011-02-07 06:56:07 +01:00
|
|
|
if (!entity.passenger.dead && entity.passenger.vehicle == entity) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.playerJoinedWorld(entity.passenger);
|
2011-02-07 06:56:07 +01:00
|
|
|
} else {
|
|
|
|
entity.passenger.vehicle = null;
|
|
|
|
entity.passenger = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean b(AxisAlignedBB axisalignedbb) {
|
|
|
|
return this.a(axisalignedbb, (Entity) null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(AxisAlignedBB axisalignedbb, Entity entity) {
|
2012-01-12 23:10:13 +01:00
|
|
|
List list = this.getEntities((Entity) null, axisalignedbb);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
Entity entity1 = (Entity) list.get(i);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (!entity1.dead && entity1.l && entity1 != entity) {
|
2012-11-06 13:05:28 +01:00
|
|
|
return false;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
return true;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean c(AxisAlignedBB axisalignedbb) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
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) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = this.getType(k1, l1, i2);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (block.getMaterial() != Material.AIR) {
|
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) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-04-20 22:47:26 +02:00
|
|
|
if (axisalignedbb.a < 0.0D) {
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (axisalignedbb.b < 0.0D) {
|
|
|
|
--k;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (axisalignedbb.c < 0.0D) {
|
|
|
|
--i1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int k1 = i; k1 < j; ++k1) {
|
|
|
|
for (int l1 = k; l1 < l; ++l1) {
|
|
|
|
for (int i2 = i1; i2 < j1; ++i2) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = this.getType(k1, l1, i2);
|
2011-04-20 22:47:26 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (block.getMaterial().isLiquid()) {
|
2011-04-20 22:47:26 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean e(AxisAlignedBB axisalignedbb) {
|
2011-04-20 22:47:26 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (this.b(i, k, i1, j, l, j1)) {
|
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) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = this.getType(k1, l1, i2);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (block == Blocks.FIRE || block == Blocks.LAVA || block == Blocks.STATIONARY_LAVA) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(AxisAlignedBB axisalignedbb, Material material, Entity entity) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (!this.b(i, k, i1, j, l, j1)) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
boolean flag = false;
|
2012-10-25 05:53:23 +02:00
|
|
|
Vec3D vec3d = this.getVec3DPool().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) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = this.getType(k1, l1, i2);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (block.getMaterial() == material) {
|
|
|
|
double d0 = (double) ((float) (l1 + 1) - BlockFluids.b(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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (vec3d.b() > 0.0D && entity.aC()) {
|
2012-10-25 05:53:23 +02:00
|
|
|
vec3d = vec3d.a();
|
2011-04-20 22:47:26 +02:00
|
|
|
double d1 = 0.014D;
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
entity.motX += vec3d.c * d1;
|
|
|
|
entity.motY += vec3d.d * d1;
|
|
|
|
entity.motZ += vec3d.e * d1;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
vec3d.b.release(vec3d); // CraftBukkit - pop it - we're done
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(AxisAlignedBB axisalignedbb, Material material) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
for (int k1 = i; k1 < j; ++k1) {
|
|
|
|
for (int l1 = k; l1 < l; ++l1) {
|
|
|
|
for (int i2 = i1; i2 < j1; ++i2) {
|
2013-11-04 14:07:38 +01:00
|
|
|
if (this.getType(k1, l1, i2).getMaterial() == material) {
|
2011-02-07 06:56:07 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean b(AxisAlignedBB axisalignedbb, Material material) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(axisalignedbb.a);
|
|
|
|
int j = MathHelper.floor(axisalignedbb.d + 1.0D);
|
|
|
|
int k = MathHelper.floor(axisalignedbb.b);
|
|
|
|
int l = MathHelper.floor(axisalignedbb.e + 1.0D);
|
|
|
|
int i1 = MathHelper.floor(axisalignedbb.c);
|
|
|
|
int j1 = MathHelper.floor(axisalignedbb.f + 1.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
for (int k1 = i; k1 < j; ++k1) {
|
|
|
|
for (int l1 = k; l1 < l; ++l1) {
|
|
|
|
for (int i2 = i1; i2 < j1; ++i2) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = this.getType(k1, l1, i2);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (block.getMaterial() == material) {
|
2011-02-07 06:56:07 +01:00
|
|
|
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-10-25 05:53:23 +02:00
|
|
|
public Explosion explode(Entity entity, double d0, double d1, double d2, float f, boolean flag) {
|
|
|
|
return this.createExplosion(entity, d0, d1, d2, f, false, flag);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
|
2011-02-07 06:56:07 +01:00
|
|
|
Explosion explosion = new Explosion(this, entity, d0, d1, d2, f);
|
|
|
|
|
|
|
|
explosion.a = flag;
|
2012-10-25 05:53:23 +02:00
|
|
|
explosion.b = flag1;
|
2011-02-07 06:56:07 +01:00
|
|
|
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;
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
Vec3D vec3d2 = vec3d.b.create(0, 0, 0); // CraftBukkit
|
2011-02-07 06:56:07 +01:00
|
|
|
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;
|
|
|
|
|
2012-08-12 00:27:27 +02:00
|
|
|
if (this.a(vec3d2.b(d3, d4, d5), vec3d) == null) { // CraftBukkit
|
2011-02-07 06:56:07 +01:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
vec3d2.b.release(vec3d2); // CraftBukkit
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (this.getType(i, j, k) == Blocks.FIRE) {
|
2011-05-26 14:48:22 +02:00
|
|
|
this.a(entityhuman, 1004, i, j, k, 0);
|
2013-03-13 23:33:27 +01:00
|
|
|
this.setAir(i, j, k);
|
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) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (j >= 0 && j < 256) {
|
|
|
|
TileEntity tileentity = null;
|
|
|
|
int l;
|
|
|
|
TileEntity tileentity1;
|
|
|
|
|
|
|
|
if (this.N) {
|
|
|
|
for (l = 0; l < this.a.size(); ++l) {
|
|
|
|
tileentity1 = (TileEntity) this.a.get(l);
|
|
|
|
if (!tileentity1.r() && tileentity1.x == i && tileentity1.y == j && tileentity1.z == k) {
|
|
|
|
tileentity = tileentity1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (tileentity == null) {
|
|
|
|
Chunk chunk = this.getChunkAt(i >> 4, k >> 4);
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (chunk != null) {
|
|
|
|
tileentity = chunk.e(i & 15, j, k & 15);
|
|
|
|
}
|
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (tileentity == null) {
|
|
|
|
for (l = 0; l < this.a.size(); ++l) {
|
|
|
|
tileentity1 = (TileEntity) this.a.get(l);
|
|
|
|
if (!tileentity1.r() && 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
|
|
|
}
|
2013-03-13 23:33:27 +01:00
|
|
|
|
|
|
|
return tileentity;
|
|
|
|
} else {
|
|
|
|
return null;
|
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) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (tileentity != null && !tileentity.r()) {
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.N) {
|
2011-06-30 00:02:25 +02:00
|
|
|
tileentity.x = i;
|
|
|
|
tileentity.y = j;
|
|
|
|
tileentity.z = k;
|
2013-03-13 23:33:27 +01:00
|
|
|
Iterator iterator = this.a.iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
TileEntity tileentity1 = (TileEntity) iterator.next();
|
|
|
|
|
|
|
|
if (tileentity1.x == i && tileentity1.y == j && tileentity1.z == k) {
|
2013-11-04 14:07:38 +01:00
|
|
|
tileentity1.s();
|
2013-03-13 23:33:27 +01:00
|
|
|
iterator.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a.add(tileentity);
|
2011-06-30 00:02:25 +02:00
|
|
|
} else {
|
2012-07-29 09:33:13 +02: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);
|
|
|
|
}
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void p(int i, int j, int k) {
|
2011-06-30 00:02:25 +02:00
|
|
|
TileEntity tileentity = this.getTileEntity(i, j, k);
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (tileentity != null && this.N) {
|
2013-11-04 14:07:38 +01:00
|
|
|
tileentity.s();
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a.remove(tileentity);
|
2011-06-30 00:02:25 +02:00
|
|
|
} else {
|
|
|
|
if (tileentity != null) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a.remove(tileentity);
|
2012-01-14 21:03:48 +01:00
|
|
|
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-07-29 09:33:13 +02:00
|
|
|
this.b.add(tileentity);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean q(int i, int j, int k) {
|
|
|
|
AxisAlignedBB axisalignedbb = this.getType(i, j, k).a(this, i, j, k);
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
return axisalignedbb != null && axisalignedbb.b() >= 1.0D;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public static boolean a(IBlockAccess iblockaccess, int i, int j, int k) {
|
|
|
|
Block block = iblockaccess.getType(i, j, k);
|
|
|
|
int l = iblockaccess.getData(i, j, k);
|
2012-11-06 13:05:28 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
return block.getMaterial().k() && block.d() ? true : (block instanceof BlockStairs ? (l & 4) == 4 : (block instanceof BlockStepAbstract ? (l & 8) == 8 : (block instanceof BlockHopper ? true : (block instanceof BlockSnow ? (l & 7) == 7 : false))));
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean c(int i, int j, int k, boolean flag) {
|
2011-11-20 09:01:14 +01:00
|
|
|
if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) {
|
|
|
|
Chunk chunk = this.chunkProvider.getOrCreateChunk(i >> 4, k >> 4);
|
|
|
|
|
|
|
|
if (chunk != null && !chunk.isEmpty()) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = this.getType(i, j, k);
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
return block.getMaterial().k() && block.d();
|
2011-11-20 09:01:14 +01:00
|
|
|
} else {
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public void A() {
|
2011-02-07 06:56:07 +01:00
|
|
|
int i = this.a(1.0F);
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (i != this.j) {
|
|
|
|
this.j = i;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void setSpawnFlags(boolean flag, boolean flag1) {
|
|
|
|
this.allowMonsters = flag;
|
|
|
|
this.allowAnimals = flag1;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void doTick() {
|
2013-04-27 11:40:05 +02:00
|
|
|
this.o();
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
private void a() {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.worldData.hasStorm()) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.n = 1.0F;
|
2011-06-27 00:25:01 +02:00
|
|
|
if (this.worldData.isThundering()) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.p = 1.0F;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-04-27 11:40:05 +02:00
|
|
|
protected void o() {
|
2013-07-01 13:03:00 +02:00
|
|
|
if (!this.worldProvider.g) {
|
2013-11-04 14:07:38 +01:00
|
|
|
if (!this.isStatic) {
|
|
|
|
int i = this.worldData.getThunderDuration();
|
2011-04-20 22:47:26 +02:00
|
|
|
|
|
|
|
if (i <= 0) {
|
2013-11-04 14:07:38 +01:00
|
|
|
if (this.worldData.isThundering()) {
|
|
|
|
this.worldData.setThunderDuration(this.random.nextInt(12000) + 3600);
|
|
|
|
} else {
|
|
|
|
this.worldData.setThunderDuration(this.random.nextInt(168000) + 12000);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
--i;
|
|
|
|
this.worldData.setThunderDuration(i);
|
|
|
|
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-26 01:47:25 +02:00
|
|
|
}
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
this.o = this.p;
|
|
|
|
if (this.worldData.isThundering()) {
|
|
|
|
this.p = (float) ((double) this.p + 0.01D);
|
2011-04-20 22:47:26 +02:00
|
|
|
} else {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.p = (float) ((double) this.p - 0.01D);
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
2011-04-26 01:47:25 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
this.p = MathHelper.a(this.p, 0.0F, 1.0F);
|
|
|
|
int j = this.worldData.getWeatherDuration();
|
|
|
|
|
|
|
|
if (j <= 0) {
|
|
|
|
if (this.worldData.hasStorm()) {
|
|
|
|
this.worldData.setWeatherDuration(this.random.nextInt(12000) + 12000);
|
|
|
|
} else {
|
|
|
|
this.worldData.setWeatherDuration(this.random.nextInt(168000) + 12000);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
--j;
|
|
|
|
this.worldData.setWeatherDuration(j);
|
|
|
|
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-26 01:47:25 +02:00
|
|
|
}
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
this.m = this.n;
|
|
|
|
if (this.worldData.hasStorm()) {
|
|
|
|
this.n = (float) ((double) this.n + 0.01D);
|
|
|
|
} else {
|
|
|
|
this.n = (float) ((double) this.n - 0.01D);
|
|
|
|
}
|
2011-04-20 22:47:26 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
this.n = MathHelper.a(this.n, 0.0F, 1.0F);
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected void B() {
|
2012-03-01 11:49:23 +01:00
|
|
|
// this.chunkTickList.clear(); // CraftBukkit - removed
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.a("buildList");
|
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) {
|
2013-03-25 05:22:32 +01:00
|
|
|
// CraftBukkit start - Don't tick chunks queued for unload
|
2012-08-04 09:22:57 +02:00
|
|
|
ChunkProviderServer chunkProviderServer = ((WorldServer) entityhuman.world).chunkProviderServer;
|
2012-08-18 01:53:59 +02:00
|
|
|
if (chunkProviderServer.unloadQueue.contains(l + j, i1 + k)) {
|
2012-08-04 09:22:57 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
this.chunkTickList.add(org.bukkit.craftbukkit.util.LongHash.toLong(l + j, i1 + k)); // CraftBukkit
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.b();
|
2013-11-04 14:07:38 +01:00
|
|
|
if (this.L > 0) {
|
|
|
|
--this.L;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.a("playerCheckLight");
|
2012-03-01 11:49:23 +01:00
|
|
|
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;
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
this.t(j, k, j1);
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.b();
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(int i, int j, Chunk chunk) {
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.c("moodSound");
|
2013-11-04 14:07:38 +01:00
|
|
|
if (this.L == 0 && !this.isStatic) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.k = this.k * 3 + 1013904223;
|
|
|
|
int k = this.k >> 2;
|
2012-03-01 11:49:23 +01:00
|
|
|
int l = k & 15;
|
|
|
|
int i1 = k >> 8 & 15;
|
2013-11-04 14:07:38 +01:00
|
|
|
int j1 = k >> 16 & 255;
|
|
|
|
Block block = chunk.getType(l, j1, i1);
|
2012-03-01 11:49:23 +01:00
|
|
|
|
|
|
|
l += i;
|
|
|
|
i1 += j;
|
2013-11-04 14:07:38 +01:00
|
|
|
if (block.getMaterial() == Material.AIR && this.j(l, j1, i1) <= this.random.nextInt(8) && this.b(EnumSkyBlock.SKY, l, j1, i1) <= 0) {
|
2012-03-01 11:49:23 +01:00
|
|
|
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);
|
2013-11-04 14:07:38 +01:00
|
|
|
this.L = this.random.nextInt(12000) + 6000;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.c("checkLight");
|
2012-07-29 09:33:13 +02:00
|
|
|
chunk.o();
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void g() {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.B();
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-04-20 22:47:26 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean r(int i, int j, int k) {
|
2013-03-13 23:33:27 +01:00
|
|
|
return this.d(i, j, k, false);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean s(int i, int j, int k) {
|
2013-03-13 23:33:27 +01:00
|
|
|
return this.d(i, j, k, true);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean d(int i, int j, int k, boolean flag) {
|
2012-03-01 11:49:23 +01:00
|
|
|
BiomeBase biomebase = this.getBiome(i, k);
|
2013-11-04 14:07:38 +01:00
|
|
|
float f = biomebase.a(i, j, k);
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (f > 0.15F) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (j >= 0 && j < 256 && this.b(EnumSkyBlock.BLOCK, i, j, k) < 10) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = this.getType(i, j, k);
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if ((block == Blocks.STATIONARY_WATER || block == Blocks.WATER) && this.getData(i, j, k) == 0) {
|
2011-11-20 09:01:14 +01:00
|
|
|
if (!flag) {
|
|
|
|
return true;
|
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
boolean flag1 = true;
|
2011-06-17 20:48:20 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (flag1 && this.getType(i - 1, j, k).getMaterial() != Material.WATER) {
|
2011-11-20 09:01:14 +01:00
|
|
|
flag1 = false;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (flag1 && this.getType(i + 1, j, k).getMaterial() != Material.WATER) {
|
2011-11-20 09:01:14 +01:00
|
|
|
flag1 = false;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (flag1 && this.getType(i, j, k - 1).getMaterial() != Material.WATER) {
|
2011-11-20 09:01:14 +01:00
|
|
|
flag1 = false;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (flag1 && this.getType(i, j, k + 1).getMaterial() != Material.WATER) {
|
2011-11-20 09:01:14 +01:00
|
|
|
flag1 = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!flag1) {
|
|
|
|
return true;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean e(int i, int j, int k, boolean flag) {
|
2012-03-01 11:49:23 +01:00
|
|
|
BiomeBase biomebase = this.getBiome(i, k);
|
2013-11-04 14:07:38 +01:00
|
|
|
float f = biomebase.a(i, j, k);
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (f > 0.15F) {
|
|
|
|
return false;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (!flag) {
|
|
|
|
return true;
|
2011-11-20 09:01:14 +01:00
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (j >= 0 && j < 256 && this.b(EnumSkyBlock.BLOCK, i, j, k) < 10) {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = this.getType(i, j, k);
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (block.getMaterial() == Material.AIR && Blocks.SNOW.canPlace(this, i, j, k)) {
|
2011-11-20 09:01:14 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean t(int i, int j, int k) {
|
|
|
|
boolean flag = false;
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
if (!this.worldProvider.g) {
|
2013-11-04 14:07:38 +01:00
|
|
|
flag |= this.c(EnumSkyBlock.SKY, i, j, k);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
flag |= this.c(EnumSkyBlock.BLOCK, i, j, k);
|
|
|
|
return flag;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
private int a(int i, int j, int k, EnumSkyBlock enumskyblock) {
|
2013-11-04 14:07:38 +01:00
|
|
|
if (enumskyblock == EnumSkyBlock.SKY && this.i(i, j, k)) {
|
2013-03-13 23:33:27 +01:00
|
|
|
return 15;
|
2011-09-15 02:23:52 +02:00
|
|
|
} else {
|
2013-11-04 14:07:38 +01:00
|
|
|
Block block = this.getType(i, j, k);
|
|
|
|
int l = enumskyblock == EnumSkyBlock.SKY ? 0 : block.m();
|
|
|
|
int i1 = block.k();
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (i1 >= 15 && block.m() > 0) {
|
|
|
|
i1 = 1;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (i1 < 1) {
|
|
|
|
i1 = 1;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (i1 >= 15) {
|
2013-03-13 23:33:27 +01:00
|
|
|
return 0;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (l >= 14) {
|
|
|
|
return l;
|
2013-03-13 23:33:27 +01:00
|
|
|
} else {
|
2013-11-04 14:07:38 +01:00
|
|
|
for (int j1 = 0; j1 < 6; ++j1) {
|
|
|
|
int k1 = i + Facing.b[j1];
|
|
|
|
int l1 = j + Facing.c[j1];
|
|
|
|
int i2 = k + Facing.d[j1];
|
|
|
|
int j2 = this.b(enumskyblock, k1, l1, i2) - i1;
|
|
|
|
|
|
|
|
if (j2 > l) {
|
|
|
|
l = j2;
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (l >= 14) {
|
|
|
|
return l;
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
return l;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean c(EnumSkyBlock enumskyblock, int i, int j, int k) {
|
|
|
|
if (!this.areChunksLoaded(i, j, k, 17)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2011-09-15 02:23:52 +02:00
|
|
|
int l = 0;
|
|
|
|
int i1 = 0;
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.a("getBrightness");
|
2012-07-29 09:33:13 +02:00
|
|
|
int j1 = this.b(enumskyblock, i, j, k);
|
2013-03-13 23:33:27 +01:00
|
|
|
int k1 = this.a(i, j, k, enumskyblock);
|
|
|
|
int l1;
|
2011-09-15 02:23:52 +02:00
|
|
|
int i2;
|
|
|
|
int j2;
|
|
|
|
int k2;
|
|
|
|
int l2;
|
|
|
|
int i3;
|
|
|
|
int j3;
|
|
|
|
int k3;
|
2012-07-29 09:33:13 +02:00
|
|
|
int l3;
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (k1 > j1) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.I[i1++] = 133152;
|
2013-03-13 23:33:27 +01:00
|
|
|
} else if (k1 < j1) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.I[i1++] = 133152 | j1 << 18;
|
2011-09-15 02:23:52 +02:00
|
|
|
|
|
|
|
while (l < i1) {
|
2013-11-04 14:07:38 +01:00
|
|
|
l1 = this.I[l++];
|
2013-03-13 23:33:27 +01:00
|
|
|
i2 = (l1 & 63) - 32 + i;
|
|
|
|
j2 = (l1 >> 6 & 63) - 32 + j;
|
|
|
|
k2 = (l1 >> 12 & 63) - 32 + k;
|
|
|
|
l2 = l1 >> 18 & 15;
|
|
|
|
i3 = this.b(enumskyblock, i2, j2, k2);
|
|
|
|
if (i3 == l2) {
|
|
|
|
this.b(enumskyblock, i2, j2, k2, 0);
|
|
|
|
if (l2 > 0) {
|
|
|
|
j3 = MathHelper.a(i2 - i);
|
|
|
|
l3 = MathHelper.a(j2 - j);
|
|
|
|
k3 = MathHelper.a(k2 - k);
|
|
|
|
if (j3 + l3 + k3 < 17) {
|
|
|
|
for (int i4 = 0; i4 < 6; ++i4) {
|
|
|
|
int j4 = i2 + Facing.b[i4];
|
|
|
|
int k4 = j2 + Facing.c[i4];
|
|
|
|
int l4 = k2 + Facing.d[i4];
|
2013-11-04 14:07:38 +01:00
|
|
|
int i5 = Math.max(1, this.getType(j4, k4, l4).k());
|
2013-03-13 23:33:27 +01:00
|
|
|
|
|
|
|
i3 = this.b(enumskyblock, j4, k4, l4);
|
2013-11-04 14:07:38 +01:00
|
|
|
if (i3 == l2 - i5 && i1 < this.I.length) {
|
|
|
|
this.I[i1++] = j4 - i + 32 | k4 - j + 32 << 6 | l4 - k + 32 << 12 | l2 - i5 << 18;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
l = 0;
|
|
|
|
}
|
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.b();
|
2012-10-25 05:53:23 +02:00
|
|
|
this.methodProfiler.a("checkedPosition < toCheckCount");
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
while (l < i1) {
|
2013-11-04 14:07:38 +01:00
|
|
|
l1 = this.I[l++];
|
2013-03-13 23:33:27 +01:00
|
|
|
i2 = (l1 & 63) - 32 + i;
|
|
|
|
j2 = (l1 >> 6 & 63) - 32 + j;
|
|
|
|
k2 = (l1 >> 12 & 63) - 32 + k;
|
|
|
|
l2 = this.b(enumskyblock, i2, j2, k2);
|
|
|
|
i3 = this.a(i2, j2, k2, enumskyblock);
|
|
|
|
if (i3 != l2) {
|
|
|
|
this.b(enumskyblock, i2, j2, k2, i3);
|
|
|
|
if (i3 > l2) {
|
|
|
|
j3 = Math.abs(i2 - i);
|
|
|
|
l3 = Math.abs(j2 - j);
|
|
|
|
k3 = Math.abs(k2 - k);
|
2013-11-04 14:07:38 +01:00
|
|
|
boolean flag = i1 < this.I.length - 6;
|
2013-03-13 23:33:27 +01:00
|
|
|
|
|
|
|
if (j3 + l3 + k3 < 17 && flag) {
|
|
|
|
if (this.b(enumskyblock, i2 - 1, j2, k2) < i3) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.I[i1++] = i2 - 1 - i + 32 + (j2 - j + 32 << 6) + (k2 - k + 32 << 12);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.b(enumskyblock, i2 + 1, j2, k2) < i3) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.I[i1++] = i2 + 1 - i + 32 + (j2 - j + 32 << 6) + (k2 - k + 32 << 12);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.b(enumskyblock, i2, j2 - 1, k2) < i3) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.I[i1++] = i2 - i + 32 + (j2 - 1 - j + 32 << 6) + (k2 - k + 32 << 12);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.b(enumskyblock, i2, j2 + 1, k2) < i3) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.I[i1++] = i2 - i + 32 + (j2 + 1 - j + 32 << 6) + (k2 - k + 32 << 12);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.b(enumskyblock, i2, j2, k2 - 1) < i3) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.I[i1++] = i2 - i + 32 + (j2 - j + 32 << 6) + (k2 - 1 - k + 32 << 12);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
if (this.b(enumskyblock, i2, j2, k2 + 1) < i3) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.I[i1++] = i2 - i + 32 + (j2 - j + 32 << 6) + (k2 + 1 - k + 32 << 12);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2012-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.b();
|
2013-11-04 14:07:38 +01:00
|
|
|
return true;
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
public boolean a(boolean flag) {
|
2012-07-29 09:33:13 +02:00
|
|
|
return false;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public List a(Chunk chunk, boolean flag) {
|
2012-07-29 09:33:13 +02:00
|
|
|
return null;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-01-12 16:27:39 +01:00
|
|
|
public List getEntities(Entity entity, AxisAlignedBB axisalignedbb) {
|
2013-03-13 23:33:27 +01:00
|
|
|
return this.getEntities(entity, axisalignedbb, (IEntitySelector) null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List getEntities(Entity entity, AxisAlignedBB axisalignedbb, IEntitySelector ientityselector) {
|
|
|
|
ArrayList arraylist = new ArrayList();
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor((axisalignedbb.a - 2.0D) / 16.0D);
|
|
|
|
int j = MathHelper.floor((axisalignedbb.d + 2.0D) / 16.0D);
|
|
|
|
int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D);
|
|
|
|
int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
|
|
|
for (int i1 = i; i1 <= j; ++i1) {
|
|
|
|
for (int j1 = k; j1 <= l; ++j1) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.isChunkLoaded(i1, j1)) {
|
2013-03-13 23:33:27 +01:00
|
|
|
this.getChunkAt(i1, j1).a(entity, axisalignedbb, arraylist, ientityselector);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
return arraylist;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public List a(Class oclass, AxisAlignedBB axisalignedbb) {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.a(oclass, axisalignedbb, (IEntitySelector) null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List a(Class oclass, AxisAlignedBB axisalignedbb, IEntitySelector ientityselector) {
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor((axisalignedbb.a - 2.0D) / 16.0D);
|
|
|
|
int j = MathHelper.floor((axisalignedbb.d + 2.0D) / 16.0D);
|
|
|
|
int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D);
|
|
|
|
int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D);
|
2011-02-07 06:56:07 +01:00
|
|
|
ArrayList arraylist = new ArrayList();
|
|
|
|
|
|
|
|
for (int i1 = i; i1 <= j; ++i1) {
|
|
|
|
for (int j1 = k; j1 <= l; ++j1) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.isChunkLoaded(i1, j1)) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.getChunkAt(i1, j1).a(oclass, axisalignedbb, arraylist, ientityselector);
|
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;
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
|
|
|
Entity entity2 = (Entity) list.get(i);
|
2012-03-01 11:49:23 +01:00
|
|
|
|
|
|
|
if (entity2 != entity) {
|
2012-07-29 09:33:13 +02:00
|
|
|
double d1 = entity.e(entity2);
|
2012-03-01 11:49:23 +01:00
|
|
|
|
|
|
|
if (d1 <= d0) {
|
|
|
|
entity1 = entity2;
|
|
|
|
d0 = d1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return entity1;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public abstract Entity getEntity(int i);
|
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
public void b(int i, int j, int k, TileEntity tileentity) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.isLoaded(i, j, k)) {
|
2012-03-01 11:49:23 +01:00
|
|
|
this.getChunkAtWorldCoords(i, k).e();
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a(Class oclass) {
|
|
|
|
int i = 0;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
for (int j = 0; j < this.entityList.size(); ++j) {
|
|
|
|
Entity entity = (Entity) this.entityList.get(j);
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2013-05-02 19:06:55 +02:00
|
|
|
// CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs
|
2013-07-01 13:03:00 +02:00
|
|
|
if (entity instanceof EntityInsentient) {
|
|
|
|
EntityInsentient entityinsentient = (EntityInsentient) entity;
|
2013-07-09 01:43:37 +02:00
|
|
|
if (entityinsentient.isTypeNotPersistent() && entityinsentient.isPersistent()) {
|
2013-05-02 19:06:55 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oclass.isAssignableFrom(entity.getClass())) {
|
2013-11-04 14:07:38 +01:00
|
|
|
// if ((!(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) && oclass.isAssignableFrom(entity.getClass())) {
|
|
|
|
// CraftBukkit end
|
2011-02-07 06:56:07 +01:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(List list) {
|
2011-03-20 21:18:38 +01:00
|
|
|
// CraftBukkit start
|
2013-11-04 14:07:38 +01:00
|
|
|
// this.entityList.addAll(list);
|
2011-03-20 21:18:38 +01:00
|
|
|
Entity entity = null;
|
2013-11-04 14:07:38 +01:00
|
|
|
|
2011-02-07 06:56:07 +01:00
|
|
|
for (int i = 0; i < list.size(); ++i) {
|
2011-03-20 21:18:38 +01:00
|
|
|
entity = (Entity) list.get(i);
|
2011-06-18 05:36:35 +02:00
|
|
|
if (entity == null) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-04-20 19:05:14 +02:00
|
|
|
this.entityList.add(entity);
|
2011-03-20 21:18:38 +01:00
|
|
|
// CraftBukkit end
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a((Entity) list.get(i));
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(List list) {
|
2012-10-25 05:53:23 +02:00
|
|
|
this.f.addAll(list);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean mayPlace(Block block, int i, int j, int k, boolean flag, int l, Entity entity, ItemStack itemstack) {
|
|
|
|
Block block1 = this.getType(i, j, k);
|
|
|
|
AxisAlignedBB axisalignedbb = flag ? null : block.a(this, i, j, k);
|
2011-02-07 10:26:12 +01:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
// CraftBukkit start - store default return
|
|
|
|
boolean defaultReturn = axisalignedbb != null && !this.a(axisalignedbb, entity) ? false : (block1.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : block1.getMaterial().isReplaceable() && block.canPlace(this, i, j, k, l, itemstack));
|
2011-02-07 10:26:12 +01:00
|
|
|
|
2011-05-14 16:29:42 +02:00
|
|
|
// CraftBukkit start
|
2013-12-02 00:42:26 +01:00
|
|
|
BlockCanBuildEvent event = new BlockCanBuildEvent(this.getWorld().getBlockAt(i, j, k), CraftMagicNumbers.getId(block), defaultReturn);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.getServer().getPluginManager().callEvent(event);
|
2011-02-07 10:26:12 +01:00
|
|
|
|
|
|
|
return event.isBuildable();
|
|
|
|
// CraftBukkit end
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
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-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.a("pathfind");
|
2011-04-20 19:05:14 +02:00
|
|
|
int i = MathHelper.floor(entity.locX);
|
2012-03-01 11:49:23 +01:00
|
|
|
int j = MathHelper.floor(entity.locY + 1.0D);
|
2011-04-20 19:05:14 +02:00
|
|
|
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;
|
2013-03-20 21:09:23 +01:00
|
|
|
ChunkCache chunkcache = new ChunkCache(this, i1, j1, k1, l1, i2, j2, 0);
|
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-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.b();
|
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-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.a("pathfind");
|
2011-04-20 19:05:14 +02:00
|
|
|
int l = MathHelper.floor(entity.locX);
|
|
|
|
int i1 = MathHelper.floor(entity.locY);
|
|
|
|
int j1 = MathHelper.floor(entity.locZ);
|
2011-02-07 06:56:07 +01:00
|
|
|
int k1 = (int) (f + 8.0F);
|
|
|
|
int l1 = l - k1;
|
|
|
|
int i2 = i1 - k1;
|
|
|
|
int j2 = j1 - k1;
|
|
|
|
int k2 = l + k1;
|
|
|
|
int l2 = i1 + k1;
|
|
|
|
int i3 = j1 + k1;
|
2013-03-20 21:09:23 +01:00
|
|
|
ChunkCache chunkcache = new ChunkCache(this, l1, i2, j2, k2, l2, i3, 0);
|
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-09-10 06:19:28 +02:00
|
|
|
this.methodProfiler.b();
|
2011-11-20 09:01:14 +01:00
|
|
|
return pathentity;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public int getBlockPower(int i, int j, int k, int l) {
|
2013-11-04 14:07:38 +01:00
|
|
|
return this.getType(i, j, k).c(this, i, j, k, l);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public int getBlockPower(int i, int j, int k) {
|
|
|
|
byte b0 = 0;
|
|
|
|
int l = Math.max(b0, this.getBlockPower(i, j - 1, k, 0));
|
|
|
|
|
|
|
|
if (l >= 15) {
|
|
|
|
return l;
|
|
|
|
} else {
|
|
|
|
l = Math.max(l, this.getBlockPower(i, j + 1, k, 1));
|
|
|
|
if (l >= 15) {
|
|
|
|
return l;
|
|
|
|
} else {
|
|
|
|
l = Math.max(l, this.getBlockPower(i, j, k - 1, 2));
|
|
|
|
if (l >= 15) {
|
|
|
|
return l;
|
|
|
|
} else {
|
|
|
|
l = Math.max(l, this.getBlockPower(i, j, k + 1, 3));
|
|
|
|
if (l >= 15) {
|
|
|
|
return l;
|
|
|
|
} else {
|
|
|
|
l = Math.max(l, this.getBlockPower(i - 1, j, k, 4));
|
|
|
|
if (l >= 15) {
|
|
|
|
return l;
|
|
|
|
} else {
|
|
|
|
l = Math.max(l, this.getBlockPower(i + 1, j, k, 5));
|
|
|
|
return l >= 15 ? l : l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean isBlockFacePowered(int i, int j, int k, int l) {
|
|
|
|
return this.getBlockFacePower(i, j, k, l) > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getBlockFacePower(int i, int j, int k, int l) {
|
2013-11-04 14:07:38 +01:00
|
|
|
return this.getType(i, j, k).r() ? this.getBlockPower(i, j, k) : this.getType(i, j, k).b(this, i, j, k, l);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isBlockIndirectlyPowered(int i, int j, int k) {
|
2013-03-13 23:33:27 +01:00
|
|
|
return this.getBlockFacePower(i, j - 1, k, 0) > 0 ? true : (this.getBlockFacePower(i, j + 1, k, 1) > 0 ? true : (this.getBlockFacePower(i, j, k - 1, 2) > 0 ? true : (this.getBlockFacePower(i, j, k + 1, 3) > 0 ? true : (this.getBlockFacePower(i - 1, j, k, 4) > 0 ? true : this.getBlockFacePower(i + 1, j, k, 5) > 0))));
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getHighestNeighborSignal(int i, int j, int k) {
|
|
|
|
int l = 0;
|
|
|
|
|
|
|
|
for (int i1 = 0; i1 < 6; ++i1) {
|
|
|
|
int j1 = this.getBlockFacePower(i + Facing.b[i1], j + Facing.c[i1], k + Facing.d[i1], i1);
|
|
|
|
|
|
|
|
if (j1 >= 15) {
|
|
|
|
return 15;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j1 > l) {
|
|
|
|
l = j1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return l;
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
public EntityHuman findNearbyPlayer(Entity entity, double d0) {
|
2011-11-30 00:17:43 +01:00
|
|
|
return this.findNearbyPlayer(entity.locX, entity.locY, entity.locZ, d0);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +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;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
for (int i = 0; i < this.players.size(); ++i) {
|
|
|
|
EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
|
2013-03-25 05:22:32 +01:00
|
|
|
// CraftBukkit start - Fixed an NPE
|
2011-06-19 06:53:45 +02:00
|
|
|
if (entityhuman1 == null || entityhuman1.dead) {
|
2011-06-18 05:36:35 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +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);
|
2013-03-25 05:22:32 +01:00
|
|
|
// CraftBukkit start - Fixed an NPE
|
2012-07-29 09:33:13 +02:00
|
|
|
if (entityhuman1 == null || entityhuman1.dead) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-01-08 01:12:38 +01:00
|
|
|
|
2012-12-20 05:03:52 +01:00
|
|
|
if (!entityhuman1.abilities.isInvulnerable && entityhuman1.isAlive()) {
|
2011-11-20 09:01:14 +01:00
|
|
|
double d5 = entityhuman1.e(d0, d1, d2);
|
2012-10-25 05:53:23 +02:00
|
|
|
double d6 = d3;
|
2011-11-20 09:01:14 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (entityhuman1.isSneaking()) {
|
|
|
|
d6 = d3 * 0.800000011920929D;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entityhuman1.isInvisible()) {
|
2013-11-04 14:07:38 +01:00
|
|
|
float f = entityhuman1.bC();
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
if (f < 0.1F) {
|
|
|
|
f = 0.1F;
|
|
|
|
}
|
|
|
|
|
|
|
|
d6 *= (double) (0.7F * f);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((d3 < 0.0D || d5 < d6 * d6) && (d4 == -1.0D || d5 < d4)) {
|
2011-11-20 09:01:14 +01:00
|
|
|
d4 = d5;
|
|
|
|
entityhuman = entityhuman1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return entityhuman;
|
|
|
|
}
|
|
|
|
|
2011-03-31 22:40:00 +02:00
|
|
|
public EntityHuman a(String s) {
|
2011-04-20 19:05:14 +02:00
|
|
|
for (int i = 0; i < this.players.size(); ++i) {
|
2013-07-01 13:03:00 +02:00
|
|
|
if (s.equals(((EntityHuman) this.players.get(i)).getName())) {
|
2011-04-20 19:05:14 +02:00
|
|
|
return (EntityHuman) this.players.get(i);
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void F() throws ExceptionWorldConflict { // CraftBukkit - added throws
|
2011-11-30 00:17:43 +01:00
|
|
|
this.dataManager.checkSession();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public long getSeed() {
|
2011-06-27 00:25:01 +02:00
|
|
|
return this.worldData.getSeed();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public long getTime() {
|
2012-01-14 21:03:48 +01:00
|
|
|
return this.worldData.getTime();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public long getDayTime() {
|
|
|
|
return this.worldData.getDayTime();
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public void setDayTime(long i) {
|
|
|
|
this.worldData.setDayTime(i);
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public ChunkCoordinates getSpawn() {
|
|
|
|
return new ChunkCoordinates(this.worldData.c(), this.worldData.d(), this.worldData.e());
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void x(int i, int j, int k) {
|
|
|
|
this.worldData.setSpawn(i, j, k);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public IChunkProvider K() {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.chunkProvider;
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void playNote(int i, int j, int k, Block block, int l, int i1) {
|
|
|
|
block.a(this, i, j, k, l, i1);
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public IDataManager getDataManager() {
|
|
|
|
return this.dataManager;
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public WorldData getWorldData() {
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.worldData;
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public GameRules getGameRules() {
|
|
|
|
return this.worldData.getGameRules();
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void everyoneSleeping() {}
|
2011-02-23 03:37:56 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
// CraftBukkit start
|
2011-04-11 20:48:31 +02:00
|
|
|
// Calls the method that checks to see if players are sleeping
|
|
|
|
// Called by CraftPlayer.setPermanentSleeping()
|
|
|
|
public void checkSleepStatus() {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (!this.isStatic) {
|
|
|
|
this.everyoneSleeping();
|
2011-04-11 20:48:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public float h(float f) {
|
2013-11-04 14:07:38 +01:00
|
|
|
return (this.o + (this.p - this.o) * f) * this.j(f);
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public float j(float f) {
|
2012-10-25 05:53:23 +02:00
|
|
|
return this.m + (this.n - this.m) * f;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean O() {
|
2013-03-13 23:33:27 +01:00
|
|
|
return (double) this.h(1.0F) > 0.9D;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean P() {
|
|
|
|
return (double) this.j(1.0F) > 0.2D;
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
|
2013-09-19 20:25:08 +02:00
|
|
|
public boolean isRainingAt(int i, int j, int k) {
|
2013-11-04 14:07:38 +01:00
|
|
|
if (!this.P()) {
|
2011-04-20 22:47:26 +02:00
|
|
|
return false;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (!this.i(i, j, k)) {
|
2011-04-20 22:47:26 +02:00
|
|
|
return false;
|
2012-10-25 05:53:23 +02:00
|
|
|
} else if (this.h(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
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
return biomebase.d() ? false : (this.e(i, j, k, false) ? false : biomebase.e());
|
2011-04-20 22:47:26 +02:00
|
|
|
}
|
|
|
|
}
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean z(int i, int j, int k) {
|
2012-03-01 11:49:23 +01:00
|
|
|
BiomeBase biomebase = this.getBiome(i, k);
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
return biomebase.f();
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void a(String s, PersistentBase persistentbase) {
|
|
|
|
this.worldMaps.a(s, persistentbase);
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public PersistentBase 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) {
|
2011-06-27 00:25:01 +02:00
|
|
|
return this.worldMaps.a(s);
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void b(int i, int j, int k, int l, int i1) {
|
2013-03-13 23:33:27 +01:00
|
|
|
for (int j1 = 0; j1 < this.u.size(); ++j1) {
|
|
|
|
((IWorldAccess) this.u.get(j1)).a(i, j, k, l, i1);
|
2012-10-25 05:53:23 +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-12-20 05:03:52 +01:00
|
|
|
try {
|
2013-03-13 23:33:27 +01:00
|
|
|
for (int j1 = 0; j1 < this.u.size(); ++j1) {
|
|
|
|
((IWorldAccess) this.u.get(j1)).a(entityhuman, i, j, k, l, i1);
|
2012-12-20 05:03:52 +01:00
|
|
|
}
|
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.a(throwable, "Playing level event");
|
|
|
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Level event being played");
|
|
|
|
|
|
|
|
crashreportsystemdetails.a("Block coordinates", CrashReportSystemDetails.a(j, k, l));
|
|
|
|
crashreportsystemdetails.a("Event source", entityhuman);
|
|
|
|
crashreportsystemdetails.a("Event type", Integer.valueOf(i));
|
|
|
|
crashreportsystemdetails.a("Event data", Integer.valueOf(i1));
|
|
|
|
throw new ReportedException(crashreport);
|
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;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public int R() {
|
2013-07-01 13:03:00 +02:00
|
|
|
return this.worldProvider.g ? 128 : 256;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public Random A(int i, int j, int k) {
|
2011-11-30 00:17:43 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public ChunkPosition b(String s, int i, int j, int k) {
|
2013-11-04 14:07:38 +01:00
|
|
|
return this.K().findNearestMapFeature(this, s, i, j, k);
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
public CrashReportSystemDetails a(CrashReport crashreport) {
|
|
|
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Affected level", 1);
|
|
|
|
|
|
|
|
crashreportsystemdetails.a("Level name", (this.worldData == null ? "????" : this.worldData.getName()));
|
|
|
|
crashreportsystemdetails.a("All players", (Callable) (new CrashReportPlayers(this)));
|
|
|
|
crashreportsystemdetails.a("Chunk stats", (Callable) (new CrashReportChunkStats(this)));
|
|
|
|
|
|
|
|
try {
|
|
|
|
this.worldData.a(crashreportsystemdetails);
|
|
|
|
} catch (Throwable throwable) {
|
|
|
|
crashreportsystemdetails.a("Level Data Unobtainable", throwable);
|
|
|
|
}
|
|
|
|
|
|
|
|
return crashreportsystemdetails;
|
2011-11-20 09:01:14 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void d(int i, int j, int k, int l, int i1) {
|
2013-03-13 23:33:27 +01:00
|
|
|
for (int j1 = 0; j1 < this.u.size(); ++j1) {
|
|
|
|
IWorldAccess iworldaccess = (IWorldAccess) this.u.get(j1);
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
iworldaccess.b(i, j, k, l, i1);
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
2011-07-13 06:06:07 +02:00
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
public Vec3DPool getVec3DPool() {
|
2012-12-20 05:03:52 +01:00
|
|
|
return this.J;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public Calendar V() {
|
2012-11-06 13:05:28 +01:00
|
|
|
if (this.getTime() % 600L == 0L) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.K.setTimeInMillis(MinecraftServer.ap());
|
2012-11-06 13:05:28 +01:00
|
|
|
}
|
|
|
|
|
2012-12-20 05:03:52 +01:00
|
|
|
return this.K;
|
2012-10-25 05:53:23 +02:00
|
|
|
}
|
2013-03-13 23:33:27 +01:00
|
|
|
|
|
|
|
public Scoreboard getScoreboard() {
|
|
|
|
return this.scoreboard;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void f(int i, int j, int k, Block block) {
|
|
|
|
for (int l = 0; l < 4; ++l) {
|
|
|
|
int i1 = i + Direction.a[l];
|
|
|
|
int j1 = k + Direction.b[l];
|
|
|
|
Block block1 = this.getType(i1, j, j1);
|
|
|
|
|
|
|
|
if (Blocks.REDSTONE_COMPARATOR_OFF.e(block1)) {
|
|
|
|
block1.doPhysics(this, i1, j, j1, block);
|
|
|
|
} else if (block1.r()) {
|
|
|
|
i1 += Direction.a[l];
|
|
|
|
j1 += Direction.b[l];
|
|
|
|
Block block2 = this.getType(i1, j, j1);
|
|
|
|
|
|
|
|
if (Blocks.REDSTONE_COMPARATOR_OFF.e(block2)) {
|
|
|
|
block2.doPhysics(this, i1, j, j1, block);
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public float b(double d0, double d1, double d2) {
|
2013-11-04 14:07:38 +01:00
|
|
|
return this.B(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2));
|
2013-07-01 13:03:00 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public float B(int i, int j, int k) {
|
2013-07-01 13:03:00 +02:00
|
|
|
float f = 0.0F;
|
2013-11-04 14:07:38 +01:00
|
|
|
boolean flag = this.difficulty == EnumDifficulty.HARD;
|
2013-07-01 13:03:00 +02:00
|
|
|
|
|
|
|
if (this.isLoaded(i, j, k)) {
|
|
|
|
float f1 = this.x();
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
f += MathHelper.a((float) this.getChunkAtWorldCoords(i, k).s / 3600000.0F, 0.0F, 1.0F) * (flag ? 1.0F : 0.75F);
|
2013-07-01 13:03:00 +02:00
|
|
|
f += f1 * 0.25F;
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (this.difficulty == EnumDifficulty.EASY || this.difficulty == EnumDifficulty.PEACEFUL) {
|
|
|
|
f *= (float) this.difficulty.a() / 2.0F;
|
2013-07-01 13:03:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return MathHelper.a(f, 0.0F, flag ? 1.5F : 1.0F);
|
|
|
|
}
|
2013-11-04 14:07:38 +01:00
|
|
|
|
|
|
|
public void X() {
|
|
|
|
Iterator iterator = this.u.iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
IWorldAccess iworldaccess = (IWorldAccess) iterator.next();
|
|
|
|
|
|
|
|
iworldaccess.b();
|
|
|
|
}
|
|
|
|
}
|
2011-02-07 06:56:07 +01:00
|
|
|
}
|