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


Java ChunkPos.asLong方法代碼示例

本文整理匯總了Java中net.minecraft.util.math.ChunkPos.asLong方法的典型用法代碼示例。如果您正苦於以下問題:Java ChunkPos.asLong方法的具體用法?Java ChunkPos.asLong怎麽用?Java ChunkPos.asLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.util.math.ChunkPos的用法示例。


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

示例1: provideChunk

import net.minecraft.util.math.ChunkPos; //導入方法依賴的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: isInStructure

import net.minecraft.util.math.ChunkPos; //導入方法依賴的package包/類
public boolean isInStructure(World world, String structure, BlockPos pos) {
    int dimension = world.provider.getDimension();
    ChunkPos cp = new ChunkPos(pos);
    long cplong = ChunkPos.asLong(cp.chunkXPos, cp.chunkZPos);
    StructureCacheEntry entry = new StructureCacheEntry(structure, dimension, cplong);
    if (structureCache.containsKey(entry)) {
        return structureCache.get(entry);
    }

    MapGenStructureData data = (MapGenStructureData) world.getPerWorldStorage().getOrLoadData(MapGenStructureData.class, structure);
    if (data == null) {
        return false;
    }

    Set<Long> longs = parseStructureData(data);
    for (Long l : longs) {
        structureCache.put(new StructureCacheEntry(structure, dimension, l), true);
    }
    if (structureCache.containsKey(entry)) {
        return true;
    } else {
        structureCache.put(entry, false);
        return false;
    }
}
 
開發者ID:McJty,項目名稱:InControl,代碼行數:26,代碼來源:StructureCache.java

示例3: getLoadedChunk

import net.minecraft.util.math.ChunkPos; //導入方法依賴的package包/類
@Override
public Chunk getLoadedChunk(int x, int z) {
	long i = ChunkPos.asLong(x, z);
	Chunk chunk = id2ChunkMap.get(i);

	if (chunk != null) {
		chunk.unloadQueued = false;
	}

	return chunk;
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:12,代碼來源:VolatileChunkProvider.java

示例4: loadChunk

import net.minecraft.util.math.ChunkPos; //導入方法依賴的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

示例5: getLoadedChunk

import net.minecraft.util.math.ChunkPos; //導入方法依賴的package包/類
@Nullable
public Chunk getLoadedChunk(int x, int z)
{
    long i = ChunkPos.asLong(x, z);
    Chunk chunk = (Chunk)this.id2ChunkMap.get(i);

    if (chunk != null)
    {
        chunk.unloaded = false;
    }

    return chunk;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:14,代碼來源:ChunkProviderServer.java

示例6: provideChunk

import net.minecraft.util.math.ChunkPos; //導入方法依賴的package包/類
public Chunk provideChunk(int x, int z)
{
    Chunk chunk = this.loadChunk(x, z);

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

        try
        {
            chunk = this.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", this.chunkGenerator);
            throw new ReportedException(crashreport);
        }

        this.id2ChunkMap.put(i, chunk);
        chunk.onChunkLoad();
        chunk.populateChunk(this, this.chunkGenerator);
    }

    return chunk;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:30,代碼來源:ChunkProviderServer.java

示例7: loadChunk

import net.minecraft.util.math.ChunkPos; //導入方法依賴的package包/類
@Nullable
public Chunk loadChunk(int x, int z, Runnable runnable)
{
    Chunk chunk = this.getLoadedChunk(x, z);
    if (chunk == null)
    {
        long pos = ChunkPos.asLong(x, z);
        chunk = net.minecraftforge.common.ForgeChunkManager.fetchDormantChunk(pos, this.worldObj);
        if (chunk != null || !(this.chunkLoader instanceof net.minecraft.world.chunk.storage.AnvilChunkLoader))
        {
            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, this.worldObj.provider.getDimension());
            if (chunk == null) chunk = this.loadChunkFromFile(x, z);

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

            loadingChunks.remove(pos);
        }
        else
        {
            net.minecraft.world.chunk.storage.AnvilChunkLoader loader = (net.minecraft.world.chunk.storage.AnvilChunkLoader) this.chunkLoader;
            if (runnable == null)
                chunk = net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(this.worldObj, loader, this, x, z);
            else if (loader.chunkExists(this.worldObj, x, z))
            {
                // We can only use the async queue for already generated chunks
                net.minecraftforge.common.chunkio.ChunkIOExecutor.queueChunkLoad(this.worldObj, loader, this, x, z, runnable);
                return null;
            }
        }
    }

    // If we didn't load the chunk async and have a callback run it now
    if (runnable != null) runnable.run();
    return chunk;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:41,代碼來源:ChunkProviderServer.java


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