本文整理汇总了Java中net.minecraftforge.event.world.ChunkWatchEvent类的典型用法代码示例。如果您正苦于以下问题:Java ChunkWatchEvent类的具体用法?Java ChunkWatchEvent怎么用?Java ChunkWatchEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChunkWatchEvent类属于net.minecraftforge.event.world包,在下文中一共展示了ChunkWatchEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChunkWatchedByPlayer
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
@SubscribeEvent
public void onChunkWatchedByPlayer(ChunkWatchEvent event)
{
if (!event.player.worldObj.isRemote)
{
//get all the TileEntities in the chunk
Chunk c = event.player.worldObj.getChunkFromChunkCoords(event.chunk.chunkXPos, event.chunk.chunkZPos);
int nt = 0;
for (Object t : c.chunkTileEntityMap.values())
{
if (t instanceof TileEntityGX)
{
nt++;
}
}
if (nt>0)
{
System.out.println(event.player.getDisplayName()+" is watching chunk with "+nt+" TileEntityGX tile entities");
}
}
}
示例2: onChunkWatch
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
@SubscribeEvent
public static void onChunkWatch(ChunkWatchEvent.Watch event)
{
IChunkLevel chunkLevel = getChunkLevel(event.getPlayer().getEntityWorld(), event.getChunk());
LootSlashConquer.network.sendTo(new PacketUpdateChunkLevel(chunkLevel.getChunkPos().x, chunkLevel.getChunkPos().z, chunkLevel.getChunkLevel()), event.getPlayer());
}
示例3: onChunkWatch
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
@SubscribeEvent
public static void onChunkWatch(ChunkWatchEvent.Watch e)
{
try
{
GlobalChunkPos pos = new GlobalChunkPos(e.getChunk().x, e.getChunk().z, e.getPlayer().dimension);
NetworkManager.sendTo(new CPacketSyncSif(pos, PurMag.INSTANCE.sif_storage.get(pos)), e.getPlayer());
}
catch (Exception ex)
{
PurMag.INSTANCE.log.error("Can't sync the SIF chunk data with player!", ex);
}
}
示例4: onChunkUnWatch
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
@SubscribeEvent
public static void onChunkUnWatch(ChunkWatchEvent.UnWatch e)
{
try
{
GlobalChunkPos pos = new GlobalChunkPos(e.getChunk().x, e.getChunk().z, e.getPlayer().dimension);
NetworkManager.sendTo(new CPacketDesyncSif(pos), e.getPlayer());
}
catch (Exception ex)
{
PurMag.INSTANCE.log.error("Can't desync the SIF chunk data with player!", ex);
}
}
示例5: playerWatchesChunk
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
@SubscribeEvent
public void playerWatchesChunk(ChunkWatchEvent.Watch event) {
Chunk chunk = event.player.worldObj.getChunkFromChunkCoords(event.chunk.chunkXPos, event.chunk.chunkZPos);
IExtraChunkData ecd = (IExtraChunkData) chunk;
FlatChunkLayer layer = ecd.getFlatLayer();
if (layer.isEmpty()) return;
SyncWrite sw = new SyncWrite();
layer.iterate(sw);
send(event.player, build(sw.finish()));
}
示例6: onPlayWatchChunk
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayWatchChunk(ChunkWatchEvent.Watch event)
{
Chunk chunk = event.player.worldObj.getChunkFromChunkCoords(event.chunk.chunkXPos, event.chunk.chunkZPos);
BioSystem bioSystem = BioSystemHandler.getBioSystem(event.player.worldObj, chunk);
if (bioSystem != null)
{
NetworkHandler.INSTANCE.sendTo(new MessageBioSystemUpdate(bioSystem), event.player);
}
}
示例7: removePlayer
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
public void removePlayer(EntityPlayerMP par1EntityPlayerMP)
{
if (this.playersInChunk.contains(par1EntityPlayerMP))
{
Chunk chunk = PlayerManager.getWorldServer(this.thePlayerManager).getChunkFromChunkCoords(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos);
par1EntityPlayerMP.playerNetServerHandler.sendPacketToPlayer(new Packet51MapChunk(chunk, true, 0));
this.playersInChunk.remove(par1EntityPlayerMP);
par1EntityPlayerMP.loadedChunks.remove(this.chunkLocation);
MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.UnWatch(chunkLocation, par1EntityPlayerMP));
if (this.playersInChunk.isEmpty())
{
long i = (long)this.chunkLocation.chunkXPos + 2147483647L | (long)this.chunkLocation.chunkZPos + 2147483647L << 32;
this.increaseInhabitedTime(chunk);
PlayerManager.getChunkWatchers(this.thePlayerManager).remove(i);
PlayerManager.getChunkWatcherList(this.thePlayerManager).remove(this);
if (this.numberOfTilesToUpdate > 0)
{
PlayerManager.getChunkWatchersWithPlayers(this.thePlayerManager).remove(this);
}
this.thePlayerManager.getWorldServer().theChunkProviderServer.unloadChunksIfNotNearSpawn(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos);
}
}
}
示例8: watchChunk
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
@SubscribeEvent
public void watchChunk(ChunkWatchEvent.Watch event) {
registrant.register(event.player.worldObj, event.chunk.chunkXPos, event.chunk.chunkZPos);
}
示例9: unwatchChunk
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
@SubscribeEvent
public void unwatchChunk(ChunkWatchEvent.UnWatch event) {
registrant.unregister(event.chunk.chunkXPos, event.chunk.chunkZPos);
}
示例10: onChunkWatch
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
@SubscribeEvent
public void onChunkWatch(ChunkWatchEvent.Watch event) {
long index = ChunkPos2Index(event.chunk.chunkXPos, event.chunk.chunkZPos);
VintageTG.packetPipeline.sendTo(new ChunkPutNbt(index, VintageTG.proxy.getChunkNbt(index)), event.player);
}
示例11: onChunkUnWatch
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
@SubscribeEvent
public void onChunkUnWatch(ChunkWatchEvent.UnWatch event) {
long index = ChunkPos2Index(event.chunk.chunkXPos, event.chunk.chunkZPos);
VintageTG.packetPipeline.sendTo(new ChunkRemoveNbt(index), event.player);
}
示例12: onChunkWatch
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
@SubscribeEvent
public void onChunkWatch(ChunkWatchEvent.Watch event) {
long index = ChunkPos2Index(event.chunk.chunkXPos, event.chunk.chunkZPos);
VintageCraft.packetPipeline.sendTo(new ChunkPutNbtPacket(index, VintageCraft.proxy.getChunkNbt(index)), event.player);
}
示例13: onChunkUnWatch
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
@SubscribeEvent
public void onChunkUnWatch(ChunkWatchEvent.UnWatch event) {
long index = ChunkPos2Index(event.chunk.chunkXPos, event.chunk.chunkZPos);
VintageCraft.packetPipeline.sendTo(new ChunkRemoveNbtPacket(index), event.player);
}
示例14: UnloadChunk
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
@SubscribeEvent
public void UnloadChunk(ChunkWatchEvent.UnWatch event) {
//FMLLog.info("UnloadChunk at (%s,%s) for %s", event.chunk.chunkXPos, event.chunk.chunkZPos, event.player.getDisplayName());
}
示例15: onUpdate
import net.minecraftforge.event.world.ChunkWatchEvent; //导入依赖的package包/类
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
this.theItemInWorldManager.updateBlockRemoving();
--this.initialInvulnerability;
this.openContainer.detectAndSendChanges();
if (!this.worldObj.isRemote && !ForgeHooks.canInteractWith(this, this.openContainer))
{
this.closeScreen();
this.openContainer = this.inventoryContainer;
}
while (!this.destroyedItemsNetCache.isEmpty())
{
int i = Math.min(this.destroyedItemsNetCache.size(), 127);
int[] aint = new int[i];
Iterator iterator = this.destroyedItemsNetCache.iterator();
int j = 0;
while (iterator.hasNext() && j < i)
{
aint[j++] = ((Integer)iterator.next()).intValue();
iterator.remove();
}
this.playerNetServerHandler.sendPacketToPlayer(new Packet29DestroyEntity(aint));
}
if (!this.loadedChunks.isEmpty())
{
ArrayList arraylist = new ArrayList();
Iterator iterator1 = this.loadedChunks.iterator();
ArrayList arraylist1 = new ArrayList();
while (iterator1.hasNext() && arraylist.size() < 5)
{
ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)iterator1.next();
iterator1.remove();
if (chunkcoordintpair != null && this.worldObj.blockExists(chunkcoordintpair.chunkXPos << 4, 0, chunkcoordintpair.chunkZPos << 4))
{
arraylist.add(this.worldObj.getChunkFromChunkCoords(chunkcoordintpair.chunkXPos, chunkcoordintpair.chunkZPos));
//BugFix: 16 makes it load an extra chunk, which isn't associated with a player, which makes it not unload unless a player walks near it.
//ToDo: Find a way to efficiently clean abandoned chunks.
//arraylist1.addAll(((WorldServer)this.worldObj).getAllTileEntityInBox(chunkcoordintpair.chunkXPos * 16, 0, chunkcoordintpair.chunkZPos * 16, chunkcoordintpair.chunkXPos * 16 + 16, 256, chunkcoordintpair.chunkZPos * 16 + 16));
arraylist1.addAll(((WorldServer)this.worldObj).getAllTileEntityInBox(chunkcoordintpair.chunkXPos * 16, 0, chunkcoordintpair.chunkZPos * 16, chunkcoordintpair.chunkXPos * 16 + 15, 256, chunkcoordintpair.chunkZPos * 16 + 15));
}
}
if (!arraylist.isEmpty())
{
this.playerNetServerHandler.sendPacketToPlayer(new Packet56MapChunks(arraylist));
Iterator iterator2 = arraylist1.iterator();
while (iterator2.hasNext())
{
TileEntity tileentity = (TileEntity)iterator2.next();
this.sendTileEntityToPlayer(tileentity);
}
iterator2 = arraylist.iterator();
while (iterator2.hasNext())
{
Chunk chunk = (Chunk)iterator2.next();
this.getServerForPlayer().getEntityTracker().func_85172_a(this, chunk);
MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.Watch(chunk.getChunkCoordIntPair(), this));
}
}
}
if (this.field_143005_bX > 0L && this.mcServer.func_143007_ar() > 0 && MinecraftServer.getSystemTimeMillis() - this.field_143005_bX > (long)(this.mcServer.func_143007_ar() * 1000 * 60))
{
this.playerNetServerHandler.kickPlayerFromServer("You have been idle for too long!");
}
}