Added chunk instance to ChunkWatchEvent (#4805)

This commit is contained in:
TheCyberBrick authored and LexManos committed 2018-04-01 00:07:01 -07:00
1 parent 1fcff02b67
commit 11e623bf4d
3 files changed
+81 -5

No files matched your search

@@ -23,30 +23,49 @@ import net.minecraft.server.management.PlayerChunkMapEntry;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
/**
* ChunkWatchEvent is fired when an event involving a chunk being watched occurs.<br>
* If a method utilizes this {@link Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* {@link #chunk} contains the ChunkCoordIntPair of the Chunk this event is affecting.<br>
* {@link #chunk} contains the ChunkPos of the Chunk this event is affecting.<br>
* {@link #player} contains the EntityPlayer that is involved with this chunk being watched. <br>
* {@link #chunkInstance} contains the instance of the Chunk. <br>
* <br>
* The {@link #player}'s world may not be the same as the world of the chunk
* when the player is teleporting to another dimension.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
public class ChunkWatchEvent extends Event
public class ChunkWatchEvent extends Event //TODO: extend ChunkEvent in 1.13
{
@Deprecated //TODO: Remove in 1.13
private final ChunkPos chunk;
private final EntityPlayerMP player;
private final Chunk chunkInstance;
@Deprecated //TODO: Remove in 1.13
public ChunkWatchEvent(ChunkPos chunk, EntityPlayerMP player)
{
this.chunk = chunk;
this.player = player;
this.chunkInstance = null;
}
public ChunkWatchEvent(Chunk chunk, EntityPlayerMP player)
{
this.chunk = chunk.getPos();
this.player = player;
this.chunkInstance = chunk;
}
@Deprecated //TODO: Remove in 1.13
public ChunkPos getChunk()
{
return chunk;
@@ -57,6 +76,16 @@ public class ChunkWatchEvent extends Event
return player;
}
/**
* The affected chunk.
* @return The affected chunk.
*/
@Nullable
public Chunk getChunkInstance()
{
return chunkInstance;
}
/**
* ChunkWatchEvent.Watch is fired when an EntityPlayer begins watching a chunk.<br>
* This event is fired when a chunk is added to the watched chunks of an EntityPlayer in
@@ -70,7 +99,10 @@ public class ChunkWatchEvent extends Event
**/
public static class Watch extends ChunkWatchEvent
{
@Deprecated //TODO: Remove in 1.13
public Watch(ChunkPos chunk, EntityPlayerMP player) { super(chunk, player); }
public Watch(Chunk chunk, EntityPlayerMP player) { super(chunk, player); }
}
/**
@@ -86,6 +118,9 @@ public class ChunkWatchEvent extends Event
**/
public static class UnWatch extends ChunkWatchEvent
{
@Deprecated //TODO: Remove in 1.13
public UnWatch(ChunkPos chunkLocation, EntityPlayerMP player) { super(chunkLocation, player); }
public UnWatch(Chunk chunk, EntityPlayerMP player) { super(chunk, player); }
}
}