Files
MinecraftForge/patches/minecraft/net/minecraft/server/management/PlayerChunkMapEntry.java.patch
T

153 lines
7.3 KiB
Diff

--- ../src-base/minecraft/net/minecraft/server/management/PlayerChunkMapEntry.java
+++ ../src-work/minecraft/net/minecraft/server/management/PlayerChunkMapEntry.java
@@ -32,12 +32,21 @@
private int field_187288_h;
private long field_187289_i;
private boolean field_187290_j;
+ private Runnable loadedRunnable = new Runnable()
+ {
+ public void run()
+ {
+ PlayerChunkMapEntry.this.field_187286_f = PlayerChunkMapEntry.this.field_187282_b.func_72688_a().func_72863_F().func_186028_c(PlayerChunkMapEntry.this.field_187284_d.field_77276_a, PlayerChunkMapEntry.this.field_187284_d.field_77275_b);
+ PlayerChunkMapEntry.this.loading = false;
+ }
+ };
+ private boolean loading = true;
public PlayerChunkMapEntry(PlayerChunkMap p_i1518_1_, int p_i1518_2_, int p_i1518_3_)
{
this.field_187282_b = p_i1518_1_;
this.field_187284_d = new ChunkPos(p_i1518_2_, p_i1518_3_);
- this.field_187286_f = p_i1518_1_.func_72688_a().func_72863_F().func_186028_c(p_i1518_2_, p_i1518_3_);
+ p_i1518_1_.func_72688_a().func_72863_F().loadChunk(p_i1518_2_, p_i1518_3_, this.loadedRunnable);
}
public ChunkPos func_187264_a()
@@ -63,6 +72,8 @@
if (this.field_187290_j)
{
this.func_187278_c(p_187276_1_);
+ // chunk watch event - the chunk is ready
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkWatchEvent.Watch(this.field_187286_f, p_187276_1_));
}
}
}
@@ -71,6 +82,20 @@
{
if (this.field_187283_c.contains(p_187277_1_))
{
+ // If we haven't loaded yet don't load the chunk just so we can clean it up
+ if (this.field_187286_f == null)
+ {
+ this.field_187283_c.remove(p_187277_1_);
+
+ if (this.field_187283_c.isEmpty())
+ {
+ if (this.loading) net.minecraftforge.common.chunkio.ChunkIOExecutor.dropQueuedChunkLoad(this.field_187282_b.func_72688_a(), this.field_187284_d.field_77276_a, this.field_187284_d.field_77275_b, this.loadedRunnable);
+ this.field_187282_b.func_187305_b(this);
+ }
+
+ return;
+ }
+
if (this.field_187290_j)
{
p_187277_1_.field_71135_a.func_147359_a(new SPacketUnloadChunk(this.field_187284_d.field_77276_a, this.field_187284_d.field_77275_b));
@@ -78,6 +103,8 @@
this.field_187283_c.remove(p_187277_1_);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkWatchEvent.UnWatch(this.field_187286_f, p_187277_1_));
+
if (this.field_187283_c.isEmpty())
{
this.field_187282_b.func_187305_b(this);
@@ -87,6 +114,7 @@
public boolean func_187268_a(boolean p_187268_1_)
{
+ if (this.loading) return false;
if (this.field_187286_f != null)
{
return true;
@@ -125,12 +153,15 @@
this.field_187287_g = 0;
this.field_187288_h = 0;
this.field_187290_j = true;
+ if (this.field_187283_c.isEmpty()) return true; // Forge: fix MC-120780
Packet<?> packet = new SPacketChunkData(this.field_187286_f, 65535);
for (EntityPlayerMP entityplayermp : this.field_187283_c)
{
entityplayermp.field_71135_a.func_147359_a(packet);
this.field_187282_b.func_72688_a().func_73039_n().func_85172_a(entityplayermp, this.field_187286_f);
+ // chunk watch event - delayed to here as the chunk wasn't ready in addPlayer
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkWatchEvent.Watch(this.field_187286_f, entityplayermp));
}
return true;
@@ -169,7 +200,7 @@
this.field_187288_h |= 1 << (p_187265_2_ >> 4);
- if (this.field_187287_g < 64)
+ //Forge; Cache everything, so always run
{
short short1 = (short)(p_187265_1_ << 12 | p_187265_3_ << 8 | p_187265_2_);
@@ -180,7 +211,8 @@
return;
}
}
-
+ if (this.field_187287_g == this.field_187285_e.length)
+ this.field_187285_e = java.util.Arrays.copyOf(this.field_187285_e, this.field_187285_e.length << 1);
this.field_187285_e[this.field_187287_g++] = short1;
}
}
@@ -197,6 +229,7 @@
}
}
+ @SuppressWarnings("unused")
public void func_187280_d()
{
if (this.field_187290_j && this.field_187286_f != null)
@@ -210,28 +243,32 @@
int k = (this.field_187285_e[0] >> 8 & 15) + this.field_187284_d.field_77275_b * 16;
BlockPos blockpos = new BlockPos(i, j, k);
this.func_187267_a(new SPacketBlockChange(this.field_187282_b.func_72688_a(), blockpos));
+ net.minecraft.block.state.IBlockState state = this.field_187282_b.func_72688_a().func_180495_p(blockpos);
- if (this.field_187282_b.func_72688_a().func_180495_p(blockpos).func_177230_c().func_149716_u())
+ if (state.func_177230_c().hasTileEntity(state))
{
this.func_187273_a(this.field_187282_b.func_72688_a().func_175625_s(blockpos));
}
}
- else if (this.field_187287_g == 64)
+ else if (this.field_187287_g >= net.minecraftforge.common.ForgeModContainer.clumpingThreshold)
{
this.func_187267_a(new SPacketChunkData(this.field_187286_f, this.field_187288_h));
+ //TODO: FDix Mojang's fuckup to modded by combining all TE data into the chunk data packet... seriously... packet size explosion!
}
else
{
this.func_187267_a(new SPacketMultiBlockChange(this.field_187287_g, this.field_187285_e, this.field_187286_f));
-
+ //} Keep this in the else until we figure out a fix for mojang's derpitude on the data packet so we don't double send crap.
+ //{// Forge: Send only the tile entities that are updated, Adding this brace lets us keep the indent and the patch small
for (int l = 0; l < this.field_187287_g; ++l)
{
int i1 = (this.field_187285_e[l] >> 12 & 15) + this.field_187284_d.field_77276_a * 16;
int j1 = this.field_187285_e[l] & 255;
int k1 = (this.field_187285_e[l] >> 8 & 15) + this.field_187284_d.field_77275_b * 16;
BlockPos blockpos1 = new BlockPos(i1, j1, k1);
+ net.minecraft.block.state.IBlockState state = this.field_187282_b.func_72688_a().func_180495_p(blockpos1);
- if (this.field_187282_b.func_72688_a().func_180495_p(blockpos1).func_177230_c().func_149716_u())
+ if (state.func_177230_c().hasTileEntity(state))
{
this.func_187273_a(this.field_187282_b.func_72688_a().func_175625_s(blockpos1));
}