本文整理匯總了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);
}
}
}
示例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");
}
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
}
}
示例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();
}
}
}
}
}
示例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);
}
示例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());
}
示例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);
}
}
示例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();
}
}
}
示例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());
}
}
示例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());
}
}
示例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);
}
}