1
0
Fork 0

remove repeat code,add Entity snapshot code

kcx-1614
聪聪 2017-06-25 19:09:23 +08:00
parent 93dbb7cca5
commit 597d028218
1 changed files with 69 additions and 64 deletions

View File

@ -110,7 +110,7 @@
protected final int DIST_HASH_MAGIC = 1013904223;
public float prevRainingStrength;
public float rainingStrength;
@@ -100,26 +151,88 @@
@@ -100,30 +151,93 @@
public int lastLightningBolt;
public EnumDifficulty difficultySetting;
public Random rand = new Random();
@ -206,7 +206,12 @@
private static final String __OBFID = "CL_00000140";
public boolean restoringBlockSnapshots = false;
public boolean captureBlockSnapshots = false;
@@ -166,6 +279,27 @@
public ArrayList<net.minecraftforge.common.util.BlockSnapshot> capturedBlockSnapshots = new ArrayList<net.minecraftforge.common.util.BlockSnapshot>();
+ public ArrayList<net.minecraftforge.common.util.EntitySnapshot> capturedEntityItemSnapshots=new ArrayList<net.minecraftforge.common.util.EntitySnapshot>();
public BiomeGenBase getBiomeGenForCoords(final int p_72807_1_, final int p_72807_2_)
{
@@ -166,6 +280,27 @@
return this.provider.worldChunkMgr;
}
@ -234,7 +239,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 +313,12 @@
@@ -179,6 +314,12 @@
this.worldInfo = new WorldInfo(p_i45368_4_, p_i45368_2_);
this.provider = p_i45368_3_;
perWorldStorage = new MapStorage((ISaveHandler)null);
@ -247,7 +252,7 @@
}
// Broken up so that the WorldClient gets the chance to set the mapstorage object before the dimension initializes
@@ -207,8 +347,175 @@
@@ -207,8 +348,175 @@
this.calculateInitialWeather();
}
@ -423,7 +428,7 @@
this.ambientTickCountdown = this.rand.nextInt(12000);
this.spawnHostileMobs = true;
this.spawnPeacefulMobs = true;
@@ -216,7 +523,6 @@
@@ -216,7 +524,6 @@
this.lightUpdateBlockList = new int[32768];
this.saveHandler = p_i45369_1_;
this.theProfiler = p_i45369_5_;
@ -431,7 +436,7 @@
this.worldInfo = p_i45369_1_.loadWorldInfo();
if (p_i45369_4_ != null)
@@ -235,13 +541,26 @@
@@ -235,13 +542,26 @@
if (this.worldInfo == null)
{
this.worldInfo = new WorldInfo(p_i45369_3_, p_i45369_2_);
@ -458,7 +463,7 @@
this.chunkProvider = this.createChunkProvider();
if (this instanceof WorldServer)
@@ -294,6 +613,7 @@
@@ -294,6 +614,7 @@
this.calculateInitialSkylight();
this.calculateInitialWeather();
}
@ -466,7 +471,7 @@
private static MapStorage s_mapStorage;
private static ISaveHandler s_savehandler;
@@ -336,6 +656,18 @@
@@ -336,6 +657,18 @@
public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_)
{
@ -485,7 +490,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 +736,7 @@
@@ -404,7 +737,7 @@
}
}
@ -494,7 +499,7 @@
{
return this.chunkProvider.chunkExists(p_72916_1_, p_72916_2_);
}
@@ -421,6 +753,27 @@
@@ -421,6 +754,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_)
{
@ -522,30 +527,18 @@
if (p_147465_1_ >= -30000000 && p_147465_3_ >= -30000000 && p_147465_1_ < 30000000 && p_147465_3_ < 30000000)
{
if (p_147465_2_ < 0)
@@ -448,8 +801,22 @@
this.capturedBlockSnapshots.add(blockSnapshot);
}
@@ -450,7 +804,9 @@
+ // Cauldron start - capture blockstates
+ net.minecraftforge.common.util.BlockSnapshot blocksnapshot = null;
+ if (this.captureBlockSnapshots)
+ {
+ blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(this, p_147465_1_, p_147465_2_, p_147465_3_, p_147465_6_);
+ this.capturedBlockSnapshots.add(blocksnapshot);
+ }
+
boolean flag = chunk.func_150807_a(p_147465_1_ & 15, p_147465_2_, p_147465_3_ & 15, p_147465_4_, p_147465_5_);
+ if (!flag && this.captureBlockSnapshots)
+ {
+ this.capturedBlockSnapshots.remove(blocksnapshot);
+ }
- if (!flag && blockSnapshot != null)
+ // Cauldron end
+
if (!flag && blockSnapshot != null)
+ if (!flag && this.captureBlockSnapshots && blockSnapshot != null)
{
this.capturedBlockSnapshots.remove(blockSnapshot);
@@ -460,6 +827,7 @@
blockSnapshot = null;
@@ -460,6 +816,7 @@
this.func_147451_t(p_147465_1_, p_147465_2_, p_147465_3_);
this.theProfiler.endSection();
@ -553,7 +546,7 @@
if (flag && blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates
{
// Modularize client and physic updates
@@ -496,6 +864,19 @@
@@ -496,6 +853,19 @@
public int getBlockMetadata(int p_72805_1_, int p_72805_2_, int p_72805_3_)
{
@ -573,7 +566,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 +892,7 @@
@@ -511,7 +881,7 @@
Chunk chunk = this.getChunkFromChunkCoords(p_72805_1_ >> 4, p_72805_3_ >> 4);
p_72805_1_ &= 15;
p_72805_3_ &= 15;
@ -582,7 +575,7 @@
}
}
else
@@ -610,6 +991,12 @@
@@ -610,6 +980,12 @@
public void notifyBlockChange(int p_147444_1_, int p_147444_2_, int p_147444_3_, Block p_147444_4_)
{
@ -595,7 +588,7 @@
this.notifyBlocksOfNeighborChange(p_147444_1_, p_147444_2_, p_147444_3_, p_147444_4_);
}
@@ -694,6 +1081,21 @@
@@ -694,6 +1070,21 @@
try
{
@ -617,7 +610,7 @@
block.onNeighborBlockChange(this, p_147460_1_, p_147460_2_, p_147460_3_, p_147460_4_);
}
catch (Throwable throwable1)
@@ -1307,6 +1709,13 @@
@@ -1307,8 +1698,24 @@
public boolean spawnEntityInWorld(Entity p_72838_1_)
{
@ -629,9 +622,21 @@
+ {
+ if (!p_72838_1_.entityAllowedToSpawn()) return false; // Cauldron
// 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;
- if (!this.isRemote && (p_72838_1_ == null || (p_72838_1_ instanceof net.minecraft.entity.item.EntityItem && this.restoringBlockSnapshots))) return false;
+ if(!this.isRemote){
+ if(p_72838_1_==null)
+ return false;
+ if(p_72838_1_ instanceof net.minecraft.entity.item.EntityItem&&this.restoringBlockSnapshots)
+ return false;
+ if(this.captureBlockSnapshots){
+ this.capturedEntityItemSnapshots.add(new net.minecraftforge.common.util.EntitySnapshot(this,p_72838_1_,spawnReason));
+ return true;
+ }
+ }
@@ -1319,23 +1728,99 @@
int i = MathHelper.floor_double(p_72838_1_.posX / 16.0D);
int j = MathHelper.floor_double(p_72838_1_.posZ / 16.0D);
@@ -1319,23 +1726,99 @@
flag = true;
}
@ -733,7 +738,7 @@
return true;
}
}
@@ -1346,6 +1831,8 @@
@@ -1346,6 +1829,8 @@
{
((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(p_72923_1_);
}
@ -742,7 +747,7 @@
}
public void onEntityRemoved(Entity p_72847_1_)
@@ -1354,6 +1841,8 @@
@@ -1354,6 +1839,8 @@
{
((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(p_72847_1_);
}
@ -751,7 +756,7 @@
}
public void removeEntity(Entity p_72900_1_)
@@ -1397,6 +1886,19 @@
@@ -1397,6 +1884,19 @@
}
this.loadedEntityList.remove(p_72973_1_);
@ -771,7 +776,7 @@
this.onEntityRemoved(p_72973_1_);
}
@@ -1408,40 +1910,58 @@
@@ -1408,40 +1908,58 @@
public List getCollidingBoundingBoxes(Entity p_72945_1_, AxisAlignedBB p_72945_2_)
{
this.collidingBoundingBoxes.clear();
@ -844,7 +849,7 @@
for (int j2 = 0; j2 < list.size(); ++j2)
{
@@ -1797,11 +2317,22 @@
@@ -1797,11 +2315,22 @@
Entity entity;
CrashReport crashreport;
CrashReportCategory crashreportcategory;
@ -867,7 +872,7 @@
try
{
++entity.ticksExisted;
@@ -1862,10 +2393,14 @@
@@ -1862,10 +2391,14 @@
this.unloadedEntityList.clear();
this.theProfiler.endStartSection("regular");
@ -885,7 +890,7 @@
if (entity.ridingEntity != null)
{
@@ -1884,7 +2419,9 @@
@@ -1884,7 +2417,9 @@
{
try
{
@ -895,7 +900,7 @@
}
catch (Throwable throwable1)
{
@@ -1916,30 +2453,85 @@
@@ -1916,30 +2451,85 @@
{
this.getChunkFromChunkCoords(j, l).removeEntity(entity);
}
@ -988,7 +993,7 @@
crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity");
crashreportcategory = crashreport.makeCategory("Block entity being ticked");
tileentity.func_145828_a(crashreportcategory);
@@ -1955,23 +2547,13 @@
@@ -1955,23 +2545,13 @@
}
}
}
@ -1017,7 +1022,7 @@
if (!this.field_147483_b.isEmpty())
{
for (Object tile : field_147483_b)
@@ -1981,6 +2563,7 @@
@@ -1981,6 +2561,7 @@
this.loadedTileEntityList.removeAll(this.field_147483_b);
this.field_147483_b.clear();
}
@ -1025,7 +1030,7 @@
this.field_147481_N = false;
@@ -2016,17 +2599,23 @@
@@ -2016,17 +2597,23 @@
this.addedTileEntityList.clear();
}
@ -1052,7 +1057,7 @@
}
public void updateEntity(Entity p_72870_1_)
@@ -2036,21 +2625,36 @@
@@ -2036,21 +2623,36 @@
public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_)
{
@ -1091,7 +1096,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 +2738,7 @@
@@ -2134,6 +2736,7 @@
p_72866_1_.riddenByEntity = null;
}
}
@ -1099,7 +1104,7 @@
}
}
@@ -2570,7 +3175,7 @@
@@ -2570,7 +3173,7 @@
return;
}
@ -1108,7 +1113,7 @@
{
if (this.field_147481_N)
{
@@ -2612,6 +3217,9 @@
@@ -2612,6 +3215,9 @@
public void func_147457_a(TileEntity p_147457_1_)
{
@ -1118,7 +1123,7 @@
this.field_147483_b.add(p_147457_1_);
}
@@ -2718,7 +3326,15 @@
@@ -2718,7 +3324,15 @@
if (i <= 0)
{
@ -1135,7 +1140,7 @@
}
}
@@ -2754,7 +3370,15 @@
@@ -2754,7 +3368,15 @@
if (j <= 0)
{
@ -1152,7 +1157,7 @@
}
}
@@ -2777,8 +3401,41 @@
@@ -2777,8 +3399,41 @@
protected void setActivePlayerChunksAndCheckLight()
{
this.activeChunkSet.clear();
@ -1195,7 +1200,7 @@
int i;
EntityPlayer entityplayer;
int j;
@@ -2788,17 +3445,28 @@
@@ -2788,17 +3443,28 @@
for (i = 0; i < this.playerEntities.size(); ++i)
{
entityplayer = (EntityPlayer)this.playerEntities.get(i);
@ -1230,7 +1235,7 @@
}
this.theProfiler.endSection();
@@ -2810,7 +3478,7 @@
@@ -2810,7 +3476,7 @@
this.theProfiler.startSection("playerCheckLight");
@ -1239,7 +1244,7 @@
{
i = this.rand.nextInt(this.playerEntities.size());
entityplayer = (EntityPlayer)this.playerEntities.get(i);
@@ -3034,9 +3702,9 @@
@@ -3034,9 +3700,9 @@
}
}
@ -1251,7 +1256,7 @@
{
return false;
}
@@ -3166,6 +3834,16 @@
@@ -3166,6 +3832,16 @@
}
}
@ -1268,7 +1273,7 @@
this.theProfiler.endSection();
return true;
}
@@ -3284,8 +3962,21 @@
@@ -3284,8 +3960,21 @@
{
Entity entity = (Entity)this.loadedEntityList.get(j);
@ -1291,7 +1296,7 @@
++i;
}
}
@@ -3298,6 +3989,7 @@
@@ -3298,6 +3987,7 @@
for (int i = 0; i < p_72868_1_.size(); ++i)
{
Entity entity = (Entity)p_72868_1_.get(i);
@ -1299,7 +1304,7 @@
if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this)))
{
loadedEntityList.add(entity);
@@ -3314,8 +4006,17 @@
@@ -3314,8 +4004,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_);
@ -1318,7 +1323,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 +4165,12 @@
@@ -3464,6 +4163,12 @@
for (int i = 0; i < this.playerEntities.size(); ++i)
{
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
@ -1331,7 +1336,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 +4196,12 @@
@@ -3489,7 +4194,12 @@
for (int i = 0; i < this.playerEntities.size(); ++i)
{
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
@ -1345,7 +1350,7 @@
if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive())
{
double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_);
@@ -3660,6 +4372,18 @@
@@ -3660,6 +4370,18 @@
public void updateAllPlayersSleepingFlag() {}
@ -1364,7 +1369,7 @@
public float getWeightedThunderStrength(float p_72819_1_)
{
return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_);
@@ -3932,8 +4656,8 @@
@@ -3932,8 +4654,8 @@
*/
public void addTileEntity(TileEntity entity)
{
@ -1375,7 +1380,7 @@
{
dest.add(entity);
}
@@ -4029,4 +4753,122 @@
@@ -4029,4 +4751,122 @@
}
return count;
}