diff --git a/common/forge_at.cfg b/common/forge_at.cfg index e9c82df56..8b54a4e16 100644 --- a/common/forge_at.cfg +++ b/common/forge_at.cfg @@ -81,7 +81,9 @@ default aaf.d #FD:AnvilChunkLoader/field_75825_d # ChunkProviderServer.currentChunkLoader default im.e #FD:ChunkProviderServer/field_73247_e # PlayerManager -default ik.a(IIZ)Lil; #MD:PlayerManager/func_72690_a #getOrCreateChunkWatcher +public ik.a(IIZ)Lil; #MD:PlayerManager/func_72690_a #getOrCreateChunkWatcher +# PlayerInstance +public il #CL:PlayerInstance # World public-f xv.C #FD:World/field_72982_D #villageCollectionObj public xv.H #FD:World/field_72993_I #activeChunkSet diff --git a/common/net/minecraftforge/event/world/ChunkWatchEvent.java b/common/net/minecraftforge/event/world/ChunkWatchEvent.java new file mode 100644 index 000000000..a64987550 --- /dev/null +++ b/common/net/minecraftforge/event/world/ChunkWatchEvent.java @@ -0,0 +1,29 @@ +package net.minecraftforge.event.world; + +import net.minecraft.src.ChunkCoordIntPair; +import net.minecraft.src.EntityPlayerMP; +import net.minecraft.src.PlayerInstance; +import net.minecraft.src.WorldServer; +import net.minecraftforge.event.Event; + +public class ChunkWatchEvent extends Event +{ + public final ChunkCoordIntPair chunk; + public final EntityPlayerMP player; + + public ChunkWatchEvent(ChunkCoordIntPair chunk, EntityPlayerMP player) + { + this.chunk = chunk; + this.player = player; + } + + public static class Watch extends ChunkWatchEvent + { + public Watch(ChunkCoordIntPair chunk, EntityPlayerMP player) { super(chunk, player); } + } + + public static class UnWatch extends ChunkWatchEvent + { + public UnWatch(ChunkCoordIntPair chunkLocation, EntityPlayerMP player) { super(chunkLocation, player); } + } +} diff --git a/patches/common/net/minecraft/src/EntityPlayerMP.java.patch b/patches/common/net/minecraft/src/EntityPlayerMP.java.patch index eeaa463d0..389172979 100644 --- a/patches/common/net/minecraft/src/EntityPlayerMP.java.patch +++ b/patches/common/net/minecraft/src/EntityPlayerMP.java.patch @@ -1,16 +1,17 @@ --- ../src_base/common/net/minecraft/src/EntityPlayerMP.java +++ ../src_work/common/net/minecraft/src/EntityPlayerMP.java -@@ -8,6 +8,9 @@ +@@ -8,6 +8,10 @@ import java.util.LinkedList; import java.util.List; import net.minecraft.server.MinecraftServer; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.PlayerDropsEvent; ++import net.minecraftforge.event.world.ChunkWatchEvent; public class EntityPlayerMP extends EntityPlayer implements ICrafting { -@@ -80,18 +83,10 @@ +@@ -80,18 +84,10 @@ par4ItemInWorldManager.thisPlayerMP = this; this.theItemInWorldManager = par4ItemInWorldManager; this.renderDistance = par1MinecraftServer.getConfigurationManager().getViewDistance(); @@ -30,7 +31,7 @@ this.setLocationAndAngles((double)var6 + 0.5D, (double)var8, (double)var7 + 0.5D, 0.0F, 0.0F); this.mcServer = par1MinecraftServer; -@@ -188,7 +183,10 @@ +@@ -188,7 +184,10 @@ if (var9 != null && this.worldObj.blockExists(var9.chunkXPos << 4, 0, var9.chunkZPos << 4)) { var6.add(this.worldObj.getChunkFromChunkCoords(var9.chunkXPos, var9.chunkZPos)); @@ -42,7 +43,15 @@ } } -@@ -253,11 +251,29 @@ +@@ -209,6 +208,7 @@ + { + Chunk var10 = (Chunk)var11.next(); + this.getServerForPlayer().getEntityTracker().func_85172_a(this, var10); ++ MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.Watch(var10.getChunkCoordIntPair(), this)); + } + } + } +@@ -253,11 +253,29 @@ */ public void onDeath(DamageSource par1DamageSource) { diff --git a/patches/common/net/minecraft/src/PlayerInstance.java.patch b/patches/common/net/minecraft/src/PlayerInstance.java.patch index dbb5cb342..0d4bcdfd0 100644 --- a/patches/common/net/minecraft/src/PlayerInstance.java.patch +++ b/patches/common/net/minecraft/src/PlayerInstance.java.patch @@ -1,6 +1,29 @@ --- ../src_base/common/net/minecraft/src/PlayerInstance.java +++ ../src_work/common/net/minecraft/src/PlayerInstance.java -@@ -137,7 +137,10 @@ +@@ -3,9 +3,12 @@ + import java.util.ArrayList; + import java.util.List; + ++import net.minecraftforge.common.MinecraftForge; ++import net.minecraftforge.event.world.ChunkWatchEvent; ++ + public class PlayerInstance + { +- private final List playersInChunk; ++ public final List playersInChunk; + + /** note: this is final */ + private final ChunkCoordIntPair chunkLocation; +@@ -48,6 +51,8 @@ + par1EntityPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet51MapChunk(PlayerManager.getWorldServer(this.myManager).getChunkFromChunkCoords(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos), true, 0)); + this.playersInChunk.remove(par1EntityPlayerMP); + par1EntityPlayerMP.loadedChunks.remove(this.chunkLocation); ++ ++ MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.UnWatch(chunkLocation, par1EntityPlayerMP)); + + if (this.playersInChunk.isEmpty()) + { +@@ -137,7 +142,10 @@ if ((this.field_73260_f & 1 << var3) != 0) { var4 = var3 << 4;