当前位置: 首页>>代码示例>>Java>>正文


Java Chunk.onLoad方法代码示例

本文整理汇总了Java中net.minecraft.world.chunk.Chunk.onLoad方法的典型用法代码示例。如果您正苦于以下问题:Java Chunk.onLoad方法的具体用法?Java Chunk.onLoad怎么用?Java Chunk.onLoad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.world.chunk.Chunk的用法示例。


在下文中一共展示了Chunk.onLoad方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: provideChunk

import net.minecraft.world.chunk.Chunk; //导入方法依赖的package包/类
@Override
public Chunk provideChunk(int x, int z) {
	Chunk chunk = this.loadChunk(x, z);

	if (chunk == null) {
		long i = ChunkPos.asLong(x, z);

		try {
			chunk = ((IChunkProvider) chunkGenerator).provideChunk(x, z);
		}
		catch (Throwable throwable) {
			CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception generating new chunk");
			CrashReportCategory crashreportcategory = crashreport.makeCategory("Chunk to be generated");
			crashreportcategory.addCrashSection("Location",
					String.format("%d,%d", new Object[] { Integer.valueOf(x), Integer.valueOf(z) }));
			crashreportcategory.addCrashSection("Position hash", Long.valueOf(i));
			crashreportcategory.addCrashSection("Generator", chunkGenerator);
			throw new ReportedException(crashreport);
		}

		id2ChunkMap.put(i, chunk);
		chunk.onLoad();
	}

	return chunk;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:27,代码来源:VolatileChunkProvider.java

示例2: loadChunk

import net.minecraft.world.chunk.Chunk; //导入方法依赖的package包/类
@Nullable
public Chunk loadChunk(int x, int z, Runnable runnable) {
	Chunk chunk = getLoadedChunk(x, z);
	if (chunk == null) {
		long pos = ChunkPos.asLong(x, z);
		chunk = net.minecraftforge.common.ForgeChunkManager.fetchDormantChunk(pos, worldObj);
		if (chunk != null) {
			if (!loadingChunks.add(pos)) {
				net.minecraftforge.fml.common.FMLLog.bigWarning(
						"There is an attempt to load a chunk (%d,%d) in dimension %d that is already being loaded. This will cause weird chunk breakages.",
						x, z, worldObj.provider.getDimension());
			}

			if (chunk != null) {
				id2ChunkMap.put(ChunkPos.asLong(x, z), chunk);
				chunk.onLoad();
				chunk.populate(this, chunkGenerator);
			}

			loadingChunks.remove(pos);
		}
	}

	// If we didn't load the chunk async and have a callback run it now
	if (runnable != null) {
		runnable.run();
	}
	return chunk;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:30,代码来源:VolatileChunkProvider.java


注:本文中的net.minecraft.world.chunk.Chunk.onLoad方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。