1
0
forked from xjboss/KCauldronX

Rollback to the state of .152 build with some critical fixes and updates

This commit is contained in:
Sergey Shatunov
2016-01-04 12:38:37 +07:00
parent 40c95e49c0
commit f722fccdce
38 changed files with 406 additions and 1452 deletions

View File

@ -1,6 +1,6 @@
--- ../src-base/minecraft/net/minecraft/world/World.java
+++ ../src-work/minecraft/net/minecraft/world/World.java
@@ -2,16 +2,21 @@
@@ -2,6 +2,7 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -8,21 +8,15 @@
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Queue;
import java.util.Random;
@@ -12,6 +13,7 @@
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
import net.minecraft.block.Block;
import net.minecraft.block.BlockHopper;
import net.minecraft.block.BlockLiquid;
@@ -23,9 +28,11 @@
@@ -23,9 +25,11 @@
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.entity.Entity;
@ -34,7 +28,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathEntity;
@@ -51,7 +58,6 @@
@@ -51,7 +55,6 @@
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.MapStorage;
import net.minecraft.world.storage.WorldInfo;
@ -42,7 +36,7 @@
import cpw.mods.fml.common.FMLLog;
import com.google.common.collect.ImmutableSetMultimap;
@@ -70,6 +76,55 @@
@@ -70,6 +73,55 @@
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
import net.minecraft.entity.EnumCreatureType;
@ -98,22 +92,16 @@
public abstract class World implements IBlockAccess
{
/**
@@ -82,16 +137,17 @@
public final MapStorage perWorldStorage;
@@ -83,15 +135,14 @@
public boolean scheduledUpdatesAreImmediate;
- public List loadedEntityList = new ArrayList();
public List loadedEntityList = new ArrayList();
- protected List unloadedEntityList = new ArrayList();
- public List loadedTileEntityList = new ArrayList();
- private List addedTileEntityList = new ArrayList();
+ public List unloadedEntityList = new ArrayList(); // Cauldron
public List loadedTileEntityList = new ArrayList();
private List addedTileEntityList = new ArrayList();
- private List field_147483_b = new ArrayList();
+ public Queue<Entity> loadedEntityList_KC = new kcauldron.wrapper.ProcessingQueue<Entity>(new ConcurrentLinkedQueue<Entity>()); // KCauldron
+ public List<Entity> loadedEntityList = new kcauldron.wrapper.QueueToList<Entity>(((kcauldron.wrapper.ProcessingQueue<Entity>)loadedEntityList_KC).unwrap()); // KCauldron
+ public List<Entity> unloadedEntityList = com.google.common.collect.ImmutableList.of(); // KCauldron
+ public Queue<TileEntity> loadedTileEntityList_KC = new kcauldron.wrapper.ProcessingQueue<TileEntity>(new ConcurrentLinkedQueue<TileEntity>()); // KCauldron
+ public List<TileEntity> loadedTileEntityList = new kcauldron.wrapper.QueueToList<TileEntity>(((kcauldron.wrapper.ProcessingQueue<TileEntity>)loadedTileEntityList_KC).unwrap()); // KCauldron
+ private List<TileEntity> addedTileEntityList = new ArrayList<TileEntity>(); // KCauldron
+ public List<TileEntity> field_147483_b = com.google.common.collect.ImmutableList.of(); // KCauldron
+ public List field_147483_b = new ArrayList(); // Cauldron
public List playerEntities = new ArrayList();
public List weatherEffects = new ArrayList();
private long cloudColour = 16777215L;
@ -122,7 +110,7 @@
protected final int DIST_HASH_MAGIC = 1013904223;
public float prevRainingStrength;
public float rainingStrength;
@@ -100,26 +156,87 @@
@@ -100,26 +151,88 @@
public int lastLightningBolt;
public EnumDifficulty difficultySetting;
public Random rand = new Random();
@ -152,6 +140,7 @@
+ public long ticksPerAnimalSpawns;
+ public long ticksPerMonsterSpawns;
+ public boolean populating;
+ private int tickPosition;
+ // CraftBukkit end
+ public Set activeChunkSet = new HashSet(); // Cauldron - protected -> public
private int ambientTickCountdown;
@ -193,7 +182,7 @@
+ // Spigot start
+
+ /** Positions to update */
+ public final gnu.trove.map.hash.TLongShortHashMap activeChunkSet_CB;
+ protected final gnu.trove.map.hash.TLongShortHashMap activeChunkSet_CB;
+ public float growthOdds = 100;
+ protected float modifiedOdds = 100;
+
@ -217,7 +206,7 @@
private static final String __OBFID = "CL_00000140";
public boolean restoringBlockSnapshots = false;
public boolean captureBlockSnapshots = false;
@@ -166,6 +283,26 @@
@@ -166,6 +279,27 @@
return this.provider.worldChunkMgr;
}
@ -230,6 +219,7 @@
+ public final SpigotTimings.WorldTimingsHandler timings; // Spigot
+ private org.spigotmc.TickLimiter entityLimiter; // Spigot
+ private org.spigotmc.TickLimiter tileLimiter; // Spigot
+ private int tileTickPosition; // Spigot
+
+ public CraftWorld getWorld()
+ {
@ -244,7 +234,7 @@
@SideOnly(Side.CLIENT)
public World(ISaveHandler p_i45368_1_, String p_i45368_2_, WorldProvider p_i45368_3_, WorldSettings p_i45368_4_, Profiler p_i45368_5_)
{
@@ -179,6 +316,12 @@
@@ -179,6 +313,12 @@
this.worldInfo = new WorldInfo(p_i45368_4_, p_i45368_2_);
this.provider = p_i45368_3_;
perWorldStorage = new MapStorage((ISaveHandler)null);
@ -257,7 +247,7 @@
}
// Broken up so that the WorldClient gets the chance to set the mapstorage object before the dimension initializes
@@ -207,8 +350,175 @@
@@ -207,8 +347,175 @@
this.calculateInitialWeather();
}
@ -433,7 +423,7 @@
this.ambientTickCountdown = this.rand.nextInt(12000);
this.spawnHostileMobs = true;
this.spawnPeacefulMobs = true;
@@ -216,7 +526,6 @@
@@ -216,7 +523,6 @@
this.lightUpdateBlockList = new int[32768];
this.saveHandler = p_i45369_1_;
this.theProfiler = p_i45369_5_;
@ -441,7 +431,7 @@
this.worldInfo = p_i45369_1_.loadWorldInfo();
if (p_i45369_4_ != null)
@@ -235,13 +544,26 @@
@@ -235,13 +541,26 @@
if (this.worldInfo == null)
{
this.worldInfo = new WorldInfo(p_i45369_3_, p_i45369_2_);
@ -468,17 +458,15 @@
this.chunkProvider = this.createChunkProvider();
if (this instanceof WorldServer)
@@ -293,7 +615,9 @@
@@ -294,6 +613,7 @@
this.calculateInitialSkylight();
this.calculateInitialWeather();
+ if (getServer() != null && world != null) getServer().addWorld(world); // CraftBukkit
}
+ // Cauldron end
private static MapStorage s_mapStorage;
private static ISaveHandler s_savehandler;
@@ -336,6 +660,18 @@
@@ -336,6 +656,18 @@
public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_)
{
@ -497,7 +485,7 @@
if (p_147439_1_ >= -30000000 && p_147439_3_ >= -30000000 && p_147439_1_ < 30000000 && p_147439_3_ < 30000000 && p_147439_2_ >= 0 && p_147439_2_ < 256)
{
Chunk chunk = null;
@@ -404,7 +740,7 @@
@@ -404,7 +736,7 @@
}
}
@ -506,7 +494,7 @@
{
return this.chunkProvider.chunkExists(p_72916_1_, p_72916_2_);
}
@@ -421,6 +757,27 @@
@@ -421,6 +753,27 @@
public boolean setBlock(int p_147465_1_, int p_147465_2_, int p_147465_3_, Block p_147465_4_, int p_147465_5_, int p_147465_6_)
{
@ -534,7 +522,7 @@
if (p_147465_1_ >= -30000000 && p_147465_3_ >= -30000000 && p_147465_1_ < 30000000 && p_147465_3_ < 30000000)
{
if (p_147465_2_ < 0)
@@ -448,8 +805,22 @@
@@ -448,8 +801,22 @@
this.capturedBlockSnapshots.add(blockSnapshot);
}
@ -557,7 +545,7 @@
if (!flag && blockSnapshot != null)
{
this.capturedBlockSnapshots.remove(blockSnapshot);
@@ -460,6 +831,7 @@
@@ -460,6 +827,7 @@
this.func_147451_t(p_147465_1_, p_147465_2_, p_147465_3_);
this.theProfiler.endSection();
@ -565,7 +553,7 @@
if (flag && blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates
{
// Modularize client and physic updates
@@ -496,6 +868,19 @@
@@ -496,6 +864,19 @@
public int getBlockMetadata(int p_72805_1_, int p_72805_2_, int p_72805_3_)
{
@ -585,7 +573,7 @@
if (p_72805_1_ >= -30000000 && p_72805_3_ >= -30000000 && p_72805_1_ < 30000000 && p_72805_3_ < 30000000)
{
if (p_72805_2_ < 0)
@@ -511,7 +896,7 @@
@@ -511,7 +892,7 @@
Chunk chunk = this.getChunkFromChunkCoords(p_72805_1_ >> 4, p_72805_3_ >> 4);
p_72805_1_ &= 15;
p_72805_3_ &= 15;
@ -594,7 +582,7 @@
}
}
else
@@ -610,6 +995,12 @@
@@ -610,6 +991,12 @@
public void notifyBlockChange(int p_147444_1_, int p_147444_2_, int p_147444_3_, Block p_147444_4_)
{
@ -607,7 +595,7 @@
this.notifyBlocksOfNeighborChange(p_147444_1_, p_147444_2_, p_147444_3_, p_147444_4_);
}
@@ -694,6 +1085,21 @@
@@ -694,6 +1081,21 @@
try
{
@ -629,7 +617,7 @@
block.onNeighborBlockChange(this, p_147460_1_, p_147460_2_, p_147460_3_, p_147460_4_);
}
catch (Throwable throwable1)
@@ -1307,6 +1713,13 @@
@@ -1307,6 +1709,13 @@
public boolean spawnEntityInWorld(Entity p_72838_1_)
{
@ -643,7 +631,7 @@
// do not drop any items while restoring blocksnapshots. Prevents dupes
if (!this.isRemote && (p_72838_1_ == null || (p_72838_1_ instanceof net.minecraft.entity.item.EntityItem && this.restoringBlockSnapshots))) return false;
@@ -1319,23 +1732,99 @@
@@ -1319,23 +1728,99 @@
flag = true;
}
@ -739,14 +727,13 @@
- if (MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(p_72838_1_, this)) && !flag) return false;
-
this.getChunkFromChunkCoords(i, j).addEntity(p_72838_1_);
- this.loadedEntityList.add(p_72838_1_);
+ this.loadedEntityList_KC.add(p_72838_1_);
this.loadedEntityList.add(p_72838_1_);
this.onEntityAdded(p_72838_1_);
+ net.minecraftforge.cauldron.CauldronHooks.logEntitySpawn(this, p_72838_1_, spawnReason);
return true;
}
}
@@ -1346,6 +1835,8 @@
@@ -1346,6 +1831,8 @@
{
((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(p_72923_1_);
}
@ -755,7 +742,7 @@
}
public void onEntityRemoved(Entity p_72847_1_)
@@ -1354,6 +1845,8 @@
@@ -1354,6 +1841,8 @@
{
((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(p_72847_1_);
}
@ -764,16 +751,27 @@
}
public void removeEntity(Entity p_72900_1_)
@@ -1396,7 +1889,7 @@
this.getChunkFromChunkCoords(i, j).removeEntity(p_72973_1_);
@@ -1397,6 +1886,19 @@
}
- this.loadedEntityList.remove(p_72973_1_);
+ this.loadedEntityList_KC.remove(p_72973_1_);
this.loadedEntityList.remove(p_72973_1_);
+ // CraftBukkit start - Decrement loop variable field if we've already ticked this entity
+ int index = this.loadedEntityList.indexOf(p_72973_1_);
+
+ if (index != -1)
+ {
+ if (index <= this.tickPosition)
+ {
+ this.tickPosition--;
+ }
+
+ this.loadedEntityList.remove(index);
+ }
+ // CraftBukkit end
this.onEntityRemoved(p_72973_1_);
}
@@ -1408,40 +1901,58 @@
@@ -1408,40 +1910,58 @@
public List getCollidingBoundingBoxes(Entity p_72945_1_, AxisAlignedBB p_72945_2_)
{
this.collidingBoundingBoxes.clear();
@ -846,7 +844,7 @@
for (int j2 = 0; j2 < list.size(); ++j2)
{
@@ -1797,11 +2308,22 @@
@@ -1797,11 +2317,22 @@
Entity entity;
CrashReport crashreport;
CrashReportCategory crashreportcategory;
@ -869,60 +867,25 @@
try
{
++entity.ticksExisted;
@@ -1838,35 +2360,26 @@
}
}
@@ -1862,10 +2393,14 @@
- this.theProfiler.endStartSection("remove");
- this.loadedEntityList.removeAll(this.unloadedEntityList);
- int j;
- int l;
+ this.theProfiler.endStartSection("regular");
this.unloadedEntityList.clear();
this.theProfiler.endStartSection("regular");
+ org.spigotmc.ActivationRange.activateEntities(this); // Spigot
+ timings.entityTick.startTiming(); // Spigot
- for (i = 0; i < this.unloadedEntityList.size(); ++i)
- {
- entity = (Entity)this.unloadedEntityList.get(i);
- j = entity.chunkCoordX;
- l = entity.chunkCoordZ;
-
- if (entity.addedToChunk && this.chunkExists(j, l))
- {
- this.getChunkFromChunkCoords(j, l).removeEntity(entity);
+ Iterator<Entity> entityIterator = loadedEntityList_KC.iterator();
+ for (entityLimiter.initTick(); entityIterator.hasNext() && entityLimiter.shouldContinue();) {
+ entity = entityIterator.next();
+
+ if (entity.markedForRemoval || entity.isDead) {
+ theProfiler.startSection("remove");
+ int x = entity.chunkCoordX;
+ int y = entity.chunkCoordZ;
+ if (entity.addedToChunk && chunkExists(x, y))
+ getChunkFromChunkCoords(x, y).removeEntity(entity);
+ onEntityRemoved(entity);
+ entityIterator.remove();
+ theProfiler.endSection();
+ continue;
}
- }
- for (i = 0; i < this.unloadedEntityList.size(); ++i)
- {
- this.onEntityRemoved((Entity)this.unloadedEntityList.get(i));
- }
-
- this.unloadedEntityList.clear();
- this.theProfiler.endStartSection("regular");
-
- for (i = 0; i < this.loadedEntityList.size(); ++i)
- {
- entity = (Entity)this.loadedEntityList.get(i);
-
+ int entitiesThisCycle = 0;
+ if (tickPosition < 0) tickPosition = 0;
+ for (entityLimiter.initTick(); entitiesThisCycle < loadedEntityList.size() && (entitiesThisCycle % 10 == 0 || entityLimiter.shouldContinue()); tickPosition++, entitiesThisCycle++) {
+ tickPosition = (tickPosition < loadedEntityList.size()) ? tickPosition : 0;
+ entity = (Entity)this.loadedEntityList.get(this.tickPosition);
if (entity.ridingEntity != null)
{
if (!entity.ridingEntity.isDead && entity.ridingEntity.riddenByEntity == entity)
@@ -1884,7 +2397,9 @@
@@ -1884,7 +2419,9 @@
{
try
{
@ -932,27 +895,19 @@
}
catch (Throwable throwable1)
{
@@ -1905,41 +2420,56 @@
@@ -1916,30 +2453,69 @@
{
this.getChunkFromChunkCoords(j, l).removeEntity(entity);
}
-
- this.loadedEntityList.remove(i--);
+ if (this.tickPosition < this.loadedEntityList.size()) // KCauldron
+ this.loadedEntityList.remove(this.tickPosition--); // CraftBukkit - Use field for loop variable
+ else kcauldron.KLog.get().warning("Entity removal desync! " + entity); // KCauldron
this.onEntityRemoved(entity);
}
this.theProfiler.endSection();
- this.theProfiler.startSection("remove");
-
- if (entity.isDead)
- {
- j = entity.chunkCoordX;
- l = entity.chunkCoordZ;
-
- if (entity.addedToChunk && this.chunkExists(j, l))
- {
- this.getChunkFromChunkCoords(j, l).removeEntity(entity);
- }
-
- this.loadedEntityList.remove(i--);
- this.onEntityRemoved(entity);
- }
-
- this.theProfiler.endSection();
}
+ timings.entityTick.stopTiming(); // Spigot
@ -960,44 +915,50 @@
+ timings.tileEntityTick.startTiming(); // Spigot
this.field_147481_N = true;
- Iterator iterator = this.loadedTileEntityList.iterator();
-
- while (iterator.hasNext())
- {
+ // CraftBukkit start - From below, clean up tile entities before ticking them
+ if (!this.field_147483_b.isEmpty())
{
- TileEntity tileentity = (TileEntity)iterator.next();
+ Iterator<TileEntity> tileEntityIterator = loadedTileEntityList_KC.iterator();
+ for (tileLimiter.initTick(); tileEntityIterator.hasNext() && tileLimiter.shouldContinue();) {
+ TileEntity tileentity = tileEntityIterator.next();
+ for (Object tile : field_147483_b)
+ {
+ ((TileEntity) tile).onChunkUnload();
+ }
+ this.loadedTileEntityList.removeAll(this.field_147483_b);
+ this.field_147483_b.clear();
+ }
+ // CraftBukkit end
- if (!tileentity.isInvalid() && tileentity.hasWorldObj() && this.blockExists(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord))
+ int tilesThisCycle = 0;
+ for (tileLimiter.initTick(); tilesThisCycle < loadedTileEntityList.size() && (tilesThisCycle % 10 == 0 || tileLimiter.shouldContinue()); tileTickPosition++, tilesThisCycle++) {
+ tileTickPosition = (tileTickPosition < loadedTileEntityList.size()) ? tileTickPosition : 0;
+ TileEntity tileentity = (TileEntity) this.loadedTileEntityList.get(tileTickPosition);
+
+ // Spigot start
+ if (tileentity == null)
+ {
{
+ getServer().getLogger().severe("Cauldron has detected a null entity and has removed it, preventing a crash");
+ tileEntityIterator.remove();
+ tilesThisCycle--;
+ this.loadedTileEntityList.remove(tileTickPosition--);
+ continue;
+ }
+ // Spigot end
+
+ // KCauldron start
+ if (tileentity.markedForRemoval) {
+ tileentity.onChunkUnload();
+ tileEntityIterator.remove();
+ continue;
+ }
+ // KCauldron end
+
+ if (tileentity.isInvalid()) {
+ tileEntityIterator.remove();
+ tilesThisCycle--;
+ this.loadedTileEntityList.remove(tileTickPosition--);
+ if (this.chunkExists(tileentity.xCoord >> 4, tileentity.zCoord >> 4)) {
+ Chunk chunk = this.getChunkFromChunkCoords(tileentity.xCoord >> 4, tileentity.zCoord >> 4);
+ if (chunk != null) chunk.removeInvalidTileEntity(tileentity.xCoord & 15, tileentity.yCoord, tileentity.zCoord & 15);
+ }
+ continue;
+ }
- if (!tileentity.isInvalid() && tileentity.hasWorldObj() && this.blockExists(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord))
+
+ if (tileentity.hasWorldObj() && CauldronHooks.canTileEntityTick(tileentity, this)
+ && this.blockExists(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord))
{
+ {
try
{
+ tileentity.tickTimer.startTiming(); // Spigot
@ -1011,7 +972,7 @@
crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity");
crashreportcategory = crashreport.makeCategory("Block entity being ticked");
tileentity.func_145828_a(crashreportcategory);
@@ -1955,23 +2485,13 @@
@@ -1955,23 +2531,13 @@
}
}
}
@ -1031,16 +992,16 @@
- }
- }
}
+ this.field_147481_N = false;
+ timings.tileEntityTick.stopTiming(); // Spigot
+ timings.tileEntityPending.startTiming(); // Spigot
+ this.field_147481_N = false;
+
+ /* CraftBukkit start - Moved up
if (!this.field_147483_b.isEmpty())
{
for (Object tile : field_147483_b)
@@ -1981,6 +2501,7 @@
@@ -1981,6 +2547,7 @@
this.loadedTileEntityList.removeAll(this.field_147483_b);
this.field_147483_b.clear();
}
@ -1048,19 +1009,7 @@
this.field_147481_N = false;
@@ -1994,9 +2515,9 @@
if (!tileentity1.isInvalid())
{
- if (!this.loadedTileEntityList.contains(tileentity1))
+ if (!this.loadedTileEntityList_KC.contains(tileentity1))
{
- this.loadedTileEntityList.add(tileentity1);
+ this.loadedTileEntityList_KC.add(tileentity1);
}
}
else
@@ -2016,17 +2537,23 @@
@@ -2016,17 +2583,23 @@
this.addedTileEntityList.clear();
}
@ -1074,7 +1023,7 @@
- List dest = field_147481_N ? addedTileEntityList : loadedTileEntityList;
- for(TileEntity entity : (Collection<TileEntity>)p_147448_1_)
+ // Cauldron start
+ Collection dest = field_147481_N ? addedTileEntityList : loadedTileEntityList_KC; // List -> Collection for CB loadedTileEntityList type change
+ Collection dest = field_147481_N ? addedTileEntityList : loadedTileEntityList; // List -> Collection for CB loadedTileEntityList type change
+ for(Object entity : p_147448_1_)
{
- if(entity.canUpdate()) dest.add(entity);
@ -1087,7 +1036,7 @@
}
public void updateEntity(Entity p_72870_1_)
@@ -2036,21 +2563,33 @@
@@ -2036,21 +2609,33 @@
public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_)
{
@ -1122,7 +1071,7 @@
p_72866_1_.lastTickPosX = p_72866_1_.posX;
p_72866_1_.lastTickPosY = p_72866_1_.posY;
p_72866_1_.lastTickPosZ = p_72866_1_.posZ;
@@ -2134,6 +2673,7 @@
@@ -2134,6 +2719,7 @@
p_72866_1_.riddenByEntity = null;
}
}
@ -1130,16 +1079,7 @@
}
}
@@ -2500,7 +3040,7 @@
@SideOnly(Side.CLIENT)
public String getDebugLoadedEntities()
{
- return "All: " + this.loadedEntityList.size();
+ return "All: " + this.loadedEntityList_KC.size();
}
@SideOnly(Side.CLIENT)
@@ -2570,7 +3110,7 @@
@@ -2570,7 +3156,7 @@
return;
}
@ -1148,35 +1088,7 @@
{
if (this.field_147481_N)
{
@@ -2591,7 +3131,7 @@
}
else
{
- this.loadedTileEntityList.add(p_147455_4_);
+ this.loadedTileEntityList_KC.add(p_147455_4_);
}
}
Chunk chunk = this.getChunkFromChunkCoords(p_147455_1_ >> 4, p_147455_3_ >> 4);
@@ -2612,7 +3152,7 @@
public void func_147457_a(TileEntity p_147457_1_)
{
- this.field_147483_b.add(p_147457_1_);
+ p_147457_1_.markedForRemoval = true;
}
public boolean func_147469_q(int p_147469_1_, int p_147469_2_, int p_147469_3_)
@@ -2666,7 +3206,9 @@
public void tick()
{
+ timings.weatherUpdate.startTiming(); // KCauldron
this.updateWeather();
+ timings.weatherUpdate.stopTiming(); // KCauldron
}
private void calculateInitialWeather()
@@ -2718,7 +3260,15 @@
@@ -2718,7 +3304,15 @@
if (i <= 0)
{
@ -1193,7 +1105,7 @@
}
}
@@ -2754,7 +3304,15 @@
@@ -2754,7 +3348,15 @@
if (j <= 0)
{
@ -1210,7 +1122,7 @@
}
}
@@ -2777,8 +3335,41 @@
@@ -2777,8 +3379,41 @@
protected void setActivePlayerChunksAndCheckLight()
{
this.activeChunkSet.clear();
@ -1253,7 +1165,7 @@
int i;
EntityPlayer entityplayer;
int j;
@@ -2788,17 +3379,28 @@
@@ -2788,17 +3423,28 @@
for (i = 0; i < this.playerEntities.size(); ++i)
{
entityplayer = (EntityPlayer)this.playerEntities.get(i);
@ -1288,7 +1200,7 @@
}
this.theProfiler.endSection();
@@ -2810,7 +3412,7 @@
@@ -2810,7 +3456,7 @@
this.theProfiler.startSection("playerCheckLight");
@ -1297,20 +1209,16 @@
{
i = this.rand.nextInt(this.playerEntities.size());
entityplayer = (EntityPlayer)this.playerEntities.get(i);
@@ -3280,12 +3882,23 @@
{
int i = 0;
- for (int j = 0; j < this.loadedEntityList.size(); ++j)
+ for (Entity entity : loadedEntityList_KC)
@@ -3284,8 +3930,21 @@
{
- Entity entity = (Entity)this.loadedEntityList.get(j);
+ // CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs
+ if (entity instanceof EntityLiving)
+ {
+ EntityLiving entityliving = (EntityLiving) entity;
Entity entity = (Entity)this.loadedEntityList.get(j);
- if ((!(entity instanceof EntityLiving) || !((EntityLiving)entity).isNoDespawnRequired()) && p_72907_1_.isAssignableFrom(entity.getClass()))
+ // CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs
+ if (entity instanceof EntityLiving)
{
+ EntityLiving entityliving = (EntityLiving) entity;
+
+ if (entityliving.canDespawn_CB() && entityliving.isNoDespawnRequired())
+ {
+ continue;
@ -1318,34 +1226,21 @@
+ }
+
+ if (p_72907_1_.isAssignableFrom(entity.getClass()))
{
+ {
+ // if ((!(entity instanceof EntityLiving) || !((EntityLiving)entity).isNoDespawnRequired()) && p_72907_1_.isAssignableFrom(entity.getClass()))
+ // CraftBukkit end
++i;
}
}
@@ -3298,9 +3911,10 @@
@@ -3298,6 +3957,7 @@
for (int i = 0; i < p_72868_1_.size(); ++i)
{
Entity entity = (Entity)p_72868_1_.get(i);
+ if (!entity.entityAllowedToSpawn()) continue;
if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this)))
{
- loadedEntityList.add(entity);
+ loadedEntityList_KC.add(entity);
this.onEntityAdded(entity);
}
}
@@ -3308,14 +3922,25 @@
public void unloadEntities(List p_72828_1_)
{
- this.unloadedEntityList.addAll(p_72828_1_);
+ for (Object o : p_72828_1_) {
+ ((Entity)o).markedForRemoval = true;
+ }
}
loadedEntityList.add(entity);
@@ -3314,8 +3974,17 @@
public boolean canPlaceEntityOnSide(Block p_147472_1_, int p_147472_2_, int p_147472_3_, int p_147472_4_, boolean p_147472_5_, int p_147472_6_, Entity p_147472_7_, ItemStack p_147472_8_)
{
Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_);
@ -1364,7 +1259,7 @@
}
public PathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_)
@@ -3464,6 +4089,12 @@
@@ -3464,6 +4133,12 @@
for (int i = 0; i < this.playerEntities.size(); ++i)
{
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
@ -1377,7 +1272,7 @@
double d5 = entityplayer1.getDistanceSq(p_72977_1_, p_72977_3_, p_72977_5_);
if ((p_72977_7_ < 0.0D || d5 < p_72977_7_ * p_72977_7_) && (d4 == -1.0D || d5 < d4))
@@ -3489,7 +4120,12 @@
@@ -3489,7 +4164,12 @@
for (int i = 0; i < this.playerEntities.size(); ++i)
{
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
@ -1391,21 +1286,7 @@
if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive())
{
double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_);
@@ -3612,11 +4248,11 @@
}
}
- if (!this.loadedEntityList.contains(p_72897_1_))
+ if (!this.loadedEntityList_KC.contains(p_72897_1_))
{
if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(p_72897_1_, this)))
{
- this.loadedEntityList.add(p_72897_1_);
+ this.loadedEntityList_KC.add(p_72897_1_);
}
}
}
@@ -3660,6 +4296,18 @@
@@ -3660,6 +4340,18 @@
public void updateAllPlayersSleepingFlag() {}
@ -1424,29 +1305,18 @@
public float getWeightedThunderStrength(float p_72819_1_)
{
return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_);
@@ -3932,8 +4580,8 @@
@@ -3932,8 +4624,8 @@
*/
public void addTileEntity(TileEntity entity)
{
- List dest = field_147481_N ? addedTileEntityList : loadedTileEntityList;
- if(entity.canUpdate())
+ Collection dest = field_147481_N ? addedTileEntityList : loadedTileEntityList_KC; // Cauldron - List -> Collection for CB loadedTileEntityList type change
+ Collection dest = field_147481_N ? addedTileEntityList : loadedTileEntityList; // Cauldron - List -> Collection for CB loadedTileEntityList type change
+ if (CauldronHooks.canUpdate(entity))
{
dest.add(entity);
}
@@ -4020,13 +4668,82 @@
public int countEntities(EnumCreatureType type, boolean forSpawnCount)
{
int count = 0;
- for (int x = 0; x < loadedEntityList.size(); x++)
+ for (Entity entity : loadedEntityList_KC)
{
- if (((Entity)loadedEntityList.get(x)).isCreatureType(type, forSpawnCount))
+ if (entity.isCreatureType(type, forSpawnCount))
{
count++;
}
@@ -4029,4 +4721,73 @@
}
return count;
}
@ -1464,7 +1334,7 @@
+
+ public boolean isActiveChunk(int x, int z)
+ {
+ return activeChunkSet_CB.containsKey(chunkToKey(x, z)) || getPersistentChunks().containsKey(new ChunkCoordIntPair(x, z));
+ return getPersistentChunks().containsKey(new ChunkCoordIntPair(x, z)) || activeChunkSet_CB.containsKey(chunkToKey(x, z));
+ }
+
+ public boolean isActiveChunk(long key)