當前位置: 首頁>>代碼示例>>Java>>正文


Java ChunkEvent類代碼示例

本文整理匯總了Java中net.minecraftforge.event.world.ChunkEvent的典型用法代碼示例。如果您正苦於以下問題:Java ChunkEvent類的具體用法?Java ChunkEvent怎麽用?Java ChunkEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ChunkEvent類屬於net.minecraftforge.event.world包,在下文中一共展示了ChunkEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onChunkLoad

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
@SubscribeEvent
public void onChunkLoad(ChunkEvent.Load event)
{
	if(event.getChunk() != null && !event.world.isRemote)
	{
		int x = event.getChunk().xPosition;
		int z = event.getChunk().zPosition;

		IChunkProvider cProvider = event.getChunk().worldObj.getChunkProvider();
		Chunk[] neighbors = new Chunk[5];

		neighbors[0] = event.getChunk();

		if(cProvider.chunkExists(x + 1, z)) neighbors[1] = cProvider.provideChunk(x + 1, z);
		if(cProvider.chunkExists(x - 1, z)) neighbors[2] = cProvider.provideChunk(x - 1, z);
		if(cProvider.chunkExists(x, z + 1)) neighbors[3] = cProvider.provideChunk(x, z + 1);
		if(cProvider.chunkExists(x, z - 1)) neighbors[4] = cProvider.provideChunk(x, z - 1);

		for(Chunk c : neighbors)
		{
			refreshChunk(c);
		}
	}
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:25,代碼來源:TransmitterNetworkRegistry.java

示例2: chunkLoadedEvent

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
@SubscribeEvent
public void chunkLoadedEvent(ChunkEvent.Load event) {

	Map map = event.getChunk().chunkTileEntityMap;
	Iterator<Entry> iter = map.entrySet().iterator();

	try {
		while(iter.hasNext()) {
			Object obj = iter.next().getValue();

			if(obj instanceof TilePipe) {
				((TilePipe)obj).markForUpdate();
			}
		}
	} catch ( ConcurrentModificationException e) {
		AdvancedRocketry.logger.warn("You have been visited by the rare pepe.. I mean error of pipes not loading, this is not good, some pipe systems may not work right away.  But it's better than a corrupt world");
	}

}
 
開發者ID:zmaster587,項目名稱:AdvancedRocketry,代碼行數:20,代碼來源:CableTickHandler.java

示例3: onChunkLoad

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
public void onChunkLoad()
{
    this.isChunkLoaded = true;
    this.worldObj.func_147448_a(this.chunkTileEntityMap.values());

    for (int i = 0; i < this.entityLists.length; ++i)
    {
        Iterator iterator = this.entityLists[i].iterator();

        while (iterator.hasNext())
        {
            Entity entity = (Entity)iterator.next();
            entity.onChunkLoad();
        }

        this.worldObj.addLoadedEntities(this.entityLists[i]);
    }
    MinecraftForge.EVENT_BUS.post(new ChunkEvent.Load(this));
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:20,代碼來源:Chunk.java

示例4: onChunkUnload

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
public void onChunkUnload()
{
    this.isChunkLoaded = false;
    Iterator iterator = this.chunkTileEntityMap.values().iterator();

    while (iterator.hasNext())
    {
        TileEntity tileentity = (TileEntity)iterator.next();
        this.worldObj.func_147457_a(tileentity);
    }

    for (int i = 0; i < this.entityLists.length; ++i)
    {
        this.worldObj.unloadEntities(this.entityLists[i]);
    }
    MinecraftForge.EVENT_BUS.post(new ChunkEvent.Unload(this));
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:18,代碼來源:Chunk.java

示例5: onChunkLoad

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
/**
 * Called when this Chunk is loaded by the ChunkProvider
 */
public void onChunkLoad()
{
    this.isChunkLoaded = true;
    this.worldObj.addTileEntity(this.chunkTileEntityMap.values());

    for (int i = 0; i < this.entityLists.length; ++i)
    {
        Iterator iterator = this.entityLists[i].iterator();

        while (iterator.hasNext())
        {
            Entity entity = (Entity)iterator.next();
            entity.onChunkLoad();
        }

        this.worldObj.addLoadedEntities(this.entityLists[i]);
    }
    MinecraftForge.EVENT_BUS.post(new ChunkEvent.Load(this));
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:23,代碼來源:Chunk.java

示例6: onChunkUnload

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
/**
 * Called when this Chunk is unloaded by the ChunkProvider
 */
public void onChunkUnload()
{
    this.isChunkLoaded = false;
    Iterator iterator = this.chunkTileEntityMap.values().iterator();

    while (iterator.hasNext())
    {
        TileEntity tileentity = (TileEntity)iterator.next();
        this.worldObj.markTileEntityForDespawn(tileentity);
    }

    for (int i = 0; i < this.entityLists.length; ++i)
    {
        this.worldObj.unloadEntities(this.entityLists[i]);
    }
    MinecraftForge.EVENT_BUS.post(new ChunkEvent.Unload(this));
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:21,代碼來源:Chunk.java

示例7: onChunkLoad

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
@ForgeSubscribe
public void onChunkLoad(ChunkEvent.Load event)
{
	if(event.getChunk() != null && !event.world.isRemote)
	{
		int x = event.getChunk().xPosition;
		int z = event.getChunk().zPosition;

		IChunkProvider cProvider = event.getChunk().worldObj.getChunkProvider();
		Chunk[] neighbors = new Chunk[5];

		neighbors[0] = event.getChunk();

		if(cProvider.chunkExists(x + 1, z)) neighbors[1] = cProvider.provideChunk(x + 1, z);
		if(cProvider.chunkExists(x - 1, z)) neighbors[2] = cProvider.provideChunk(x - 1, z);
		if(cProvider.chunkExists(x, z + 1)) neighbors[3] = cProvider.provideChunk(x, z + 1);
		if(cProvider.chunkExists(x, z - 1)) neighbors[4] = cProvider.provideChunk(x, z - 1);

		for(Chunk c : neighbors)
		{
			refreshChunk(c);
		}
	}
}
 
開發者ID:4Space,項目名稱:4-Space-Legacy,代碼行數:25,代碼來源:TransmitterNetworkRegistry.java

示例8: onChunkLoad

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
@ForgeSubscribe
public void onChunkLoad(ChunkEvent.Load event)
{
	if (event.getChunk() != null)
	{
		Collection<?> collection = new ArrayList();
		collection.addAll(event.getChunk().chunkTileEntityMap.values());

		for (Object obj : collection)
		{
			if (obj instanceof TileEntity)
			{
				TileEntity tileEntity = (TileEntity) obj;

				if (tileEntity instanceof INetworkConnection)
				{
					((INetworkConnection) tileEntity).refresh();
				}
			}
		}
	}
}
 
開發者ID:tterrag1098,項目名稱:SimpleTransmutations,代碼行數:23,代碼來源:ConductorChunkInitiate.java

示例9: onChunkLoad

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
@SubscribeEvent
public static void onChunkLoad(ChunkEvent.Load event)
{
	World world = event.getWorld();
	ChunkPos chunkPos = event.getChunk().getPos();
	
	IChunkLevelHolder chunkLevelHolder = getChunkLevelHolder(world);
	
	if (chunkLevelHolder.getChunkLevel(chunkPos) != null) return;
	
	IChunkLevel chunkLevel = new ChunkLevel(world, chunkPos, getAreaLevel(world, chunkPos));
	chunkLevelHolder.setChunkLevel(chunkPos, chunkLevel);
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:14,代碼來源:CapabilityChunkLevel.java

示例10: onChunkUnload

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
@SubscribeEvent
public static void onChunkUnload(ChunkEvent.Unload event)
{
	IChunkLevelHolder chunkLevelHolder = getChunkLevelHolder(event.getWorld());
	
	chunkLevelHolder.removeChunkLevel(event.getChunk().getPos());
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:8,代碼來源:CapabilityChunkLevel.java

示例11: onChunkLoad

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
@SubscribeEvent
public void onChunkLoad(ChunkEvent.Load event) {
    if (event.getWorld().isRemote) {
        return;
    }

    if (RedstoneEther.server() != null)//new world
    {
        RedstoneEther.loadServerWorld(event.getWorld());
        RedstoneEther.server().verifyChunkTransmitters(event.getWorld(), event.getChunk().xPosition, event.getChunk().zPosition);
    }
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:13,代碼來源:WREventHandler.java

示例12: onChunkUnload

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
@SubscribeEvent
public void onChunkUnload(ChunkEvent.Unload event) {
    Chunk chunk = event.getChunk();
    for (int i = 0; i < chunk.getEntityLists().length; ++i) {
        for (Object o : chunk.getEntityLists()[i]) {
            if (o instanceof EntityWirelessTracker)
                ((EntityWirelessTracker) o).onChunkUnload();
        }
    }
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:11,代碼來源:WREventHandler.java

示例13: onChunkLoaded

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
@SubscribeEvent
public void onChunkLoaded(ChunkEvent.Load event)
{
	//Cast needed for the compiler as generic info is erased
	//noinspection RedundantCast
	if (((VCSettings)(VoidApi.config.dataHolder)).recoveryMode)
	{
		return;
	}
	
	if (MC.getSide() != Side.SERVER)
	{
		return;
	}
	
	try
	{
		int dim = event.getWorld().provider.getDimension();
		ChunkPos chunkPos = new ChunkPos(event.getChunk().x, event.getChunk().z);
		if (ChunkUtils.loadedChunks.containsEntry(dim, chunkPos))
		{
			VCLoggers.loggerWarnings.log(LogLevel.Warning, "Chunk %s already exists in a list of loaded chunks but the load event for it got caught! Is the chunk loading twice without unloading first?", event.getChunk().toString());
		}
		else
		{
			ChunkUtils.loadedChunks.put(dim, chunkPos);
			VCLoggers.loggerDebug.log(LogLevel.Debug, "Added chunk %s to the list of loaded chunks.", event.getChunk().toString());
		}
	}
	catch (Exception ex)
	{
		VCLoggers.loggerErrors.log(LogLevel.Error, "Caught an exception when trying to handle ChunkLoadEvent for chunk %s!", ex, event.getChunk().toString());
	}
}
 
開發者ID:V0idWa1k3r,項目名稱:VoidApi,代碼行數:35,代碼來源:VCEventHandler.java

示例14: onChunkUnload

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
@SubscribeEvent
public void onChunkUnload(ChunkEvent.Unload event)
{
	if (MC.getSide() != Side.SERVER)
	{
		return;
	}
	
	try
	{
		int dim = event.getWorld().provider.getDimension();
		ChunkPos chunkPos = new ChunkPos(event.getChunk().x, event.getChunk().z);
		if (!ChunkUtils.loadedChunks.containsEntry(dim, chunkPos))
		{
			VCLoggers.loggerWarnings.log(LogLevel.Warning, "Chunk %s is being unloaded but the load event for it was never caught!", event.getChunk().toString());
		}
		else
		{
			ChunkUtils.loadedChunks.remove(dim, chunkPos);
			VCLoggers.loggerDebug.log(LogLevel.Debug, "Removed chunk %s from the list of loaded chunks.", event.getChunk().toString());
		}
	}
	catch (Exception ex)
	{
		VCLoggers.loggerErrors.log(LogLevel.Error, "Caught an exception when trying to handle ChunkUnloadEvent for chunk %s!", ex, event.getChunk().toString());
	}
}
 
開發者ID:V0idWa1k3r,項目名稱:VoidApi,代碼行數:28,代碼來源:VCEventHandler.java

示例15: onChunkUnload

import net.minecraftforge.event.world.ChunkEvent; //導入依賴的package包/類
@SubscribeEvent
public static void onChunkUnload(ChunkEvent.Unload e)
{
    try
    {
        PurMag.INSTANCE.sif_storage.remove(GlobalChunkPos.fromChunk(e.getChunk()));
    }
    catch (Exception ex)
    {
        PurMag.INSTANCE.log.error("Can't remove the SIP chunk data on chunk unload!", ex);
    }
}
 
開發者ID:PearXTeam,項目名稱:PurificatiMagicae,代碼行數:13,代碼來源:SifEvents.java


注:本文中的net.minecraftforge.event.world.ChunkEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。