Add Chunk Watch and UnWatch events.
This commit is contained in:
parent
5cb03bc07d
commit
f1e3481c0a
4 changed files with 69 additions and 6 deletions
|
@ -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
|
||||
|
|
29
common/net/minecraftforge/event/world/ChunkWatchEvent.java
Normal file
29
common/net/minecraftforge/event/world/ChunkWatchEvent.java
Normal file
|
@ -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); }
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue