net.minecraft.world.chunk.storage.ExtendedBlockStorage Java Examples

The following examples show how to use net.minecraft.world.chunk.storage.ExtendedBlockStorage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PhysRenderChunk.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
public PhysRenderChunk(PhysicsObject toRender, Chunk chunk) {
    this.toRender = toRender;
    this.chunk = chunk;
    for (int i = 0; i < 16; i++) {
        ExtendedBlockStorage storage = this.chunk.storageArrays[i];
        if (storage != null) {
            IVSRenderChunk renderChunk;
            // Support old graphics cards that can't use VBOs.
            if (OpenGlHelper.useVbo()) {
                renderChunk = new RenderLayerVBO(this.chunk, i * 16, i * 16 + 15, this);
            } else {
                renderChunk = new RenderLayerDisplayList(this.chunk, i * 16, i * 16 + 15, this);
            }
            renderChunks[i] = renderChunk;
        }
    }
}
 
Example #2
Source File: MobileChunk.java    From archimedes-ships with MIT License 6 votes vote down vote up
public MobileChunk(World world, EntityShip entityship)
{
	worldObj = world;
	entityShip = entityship;
	blockStorageMap = new HashMap<ChunkPosition, ExtendedBlockStorage>(1);
	chunkTileEntityMap = new HashMap<ChunkPosition, TileEntity>(2);
	
	isChunkLoaded = false;
	isModified = false;
	
	boundsInit = false;
	minX = minY = minZ = maxX = maxY = maxZ = -1;
	blockCount = 0;
	
	creationSpotBiome = BiomeGenBase.ocean;
}
 
Example #3
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getBrightness(ExtendedBlockStorage section, int x, int y, int z) {
    int combined = getCombinedId4Data(section, x, y, z);
    if (combined == 0) {
        return 0;
    }
    Block block = Block.getBlockById(FaweCache.getId(combined));
    return block.getLightValue();
}
 
Example #4
Source File: MobileChunk.java    From archimedes-ships with MIT License 5 votes vote down vote up
public boolean setBlockMetadata(int x, int y, int z, int meta)
{
	ExtendedBlockStorage storage = getBlockStorage(x, y, z);
	if (storage == null) return false;
	
	int currentmeta = storage.getExtBlockMetadata(x, y & 15, z);
	if (currentmeta == meta)
	{
		return false;
	}
	
	setChunkModified();
	storage.setExtBlockMetadata(x & 15, y & 15, z & 15, meta);
	Block block = storage.getBlockByExtId(x & 15, y & 15, z & 15);
	
	if (block != null && block.hasTileEntity(meta))
	{
		TileEntity tileentity = getTileEntity(x, y, z);
		
		if (tileentity != null)
		{
			tileentity.updateContainingBlockInfo();
			tileentity.blockMetadata = meta;
		}
	}
	
	return true;
}
 
Example #5
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) {
    IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15);
    Block block = ibd.getBlock();
    int id = Block.getIdFromBlock(block);
    if (FaweCache.hasData(id)) {
        return (id << 4) + block.getMetaFromState(ibd);
    } else {
        return id << 4;
    }
}
 
Example #6
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean removeSectionLighting(ExtendedBlockStorage section, int layer, boolean sky) {
    if (section != null) {
        section.setBlocklightArray(new NibbleArray());
        if (sky) {
            section.setSkylightArray(new NibbleArray());
        }
    }
    return section != null;
}
 
Example #7
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean removeSectionLighting(ExtendedBlockStorage section, int layer, boolean sky) {
    if (section != null) {
        section.setBlocklightArray(new NibbleArray());
        if (sky) {
            section.setSkylightArray(new NibbleArray());
        }
    }
    return section != null;
}
 
Example #8
Source File: SpongeQueue_1_11.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean removeSectionLighting(ExtendedBlockStorage section, int layer, boolean sky) {
    if (section != null) {
        section.setBlocklightArray(new NibbleArray());
        if (sky) {
            section.setSkylightArray(new NibbleArray());
        }
    }
    return section != null;
}
 
Example #9
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean removeSectionLighting(ExtendedBlockStorage section, int layer, boolean sky) {
    if (section != null) {
        section.setBlocklightArray(new NibbleArray(4096, 4));
        if (sky) {
            section.setSkylightArray(new NibbleArray(4096, 4));
        }
    }
    return section != null;
}
 
Example #10
Source File: MobileChunk.java    From archimedes-ships with MIT License 5 votes vote down vote up
/**
 * Return the metadata corresponding to the given coordinates inside a chunk.
 */
@Override
public int getBlockMetadata(int x, int y, int z)
{
	ExtendedBlockStorage storage = getBlockStorage(x, y, z);
	if (storage == null) return 0;
	return storage.getExtBlockMetadata(x & 15, y & 15, z & 15);
}
 
Example #11
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
    Chunk chunk = ((ChunkProviderServer)world.getChunkProvider()).id2ChunkMap.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(cx, cz));
    if (chunk != null) {
        return chunk.getBlockStorageArray();
    }
    return null;
}
 
Example #12
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public void setCount(int tickingBlockCount, int nonEmptyBlockCount, ExtendedBlockStorage section) throws NoSuchFieldException, IllegalAccessException {
    Class<? extends ExtendedBlockStorage> clazz = section.getClass();
    Field fieldTickingBlockCount = clazz.getDeclaredField("field_76683_c"); // tickRefCount
    Field fieldNonEmptyBlockCount = clazz.getDeclaredField("field_76682_b"); // blockRefCount
    fieldTickingBlockCount.setAccessible(true);
    fieldNonEmptyBlockCount.setAccessible(true);
    fieldTickingBlockCount.set(section, tickingBlockCount);
    fieldNonEmptyBlockCount.set(section, nonEmptyBlockCount);
}
 
Example #13
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setFullbright(ExtendedBlockStorage[] sections) {
    for (int i = 0; i < sections.length; i++) {
        ExtendedBlockStorage section = sections[i];
        if (section != null) {
            byte[] bytes = section.getSkylightArray().data;
            Arrays.fill(bytes, (byte) 255);
        }
    }
}
 
Example #14
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setFullbright(ExtendedBlockStorage[] sections) {
    for (int i = 0; i < sections.length; i++) {
        ExtendedBlockStorage section = sections[i];
        if (section != null) {
            byte[] bytes = section.getSkylightArray().getData();
            Arrays.fill(bytes, (byte) 255);
        }
    }
}
 
Example #15
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setFullbright(ExtendedBlockStorage[] sections) {
    for (int i = 0; i < sections.length; i++) {
        ExtendedBlockStorage section = sections[i];
        if (section != null) {
            byte[] bytes = section.getSkylightArray().getData();
            Arrays.fill(bytes, (byte) 255);
        }
    }
}
 
Example #16
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getOpacity(ExtendedBlockStorage section, int x, int y, int z) {
    int combined = getCombinedId4Data(section, x, y, z);
    if (combined == 0) {
        return 0;
    }
    Block block = Block.getBlockById(FaweCache.getId(combined));
    return block.getLightOpacity();
}
 
Example #17
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
    Chunk chunk = world.getChunkProvider().getLoadedChunk(cx, cz);
    if (chunk != null) {
        return chunk.getBlockStorageArray();
    }
    return null;
}
 
Example #18
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
    Chunk chunk = (Chunk) ((ChunkProviderServer)world.getChunkProvider()).loadedChunkHashMap.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(cx, cz));
    if (chunk != null) {
        return chunk.getBlockStorageArray();
    }
    return null;
}
 
Example #19
Source File: SpongeQueue_1_12.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
    Chunk chunk = world.getChunkProvider().getLoadedChunk(cx, cz);
    if (chunk != null) {
        return chunk.getBlockStorageArray();
    }
    return null;
}
 
Example #20
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getOpacity(ExtendedBlockStorage section, int x, int y, int z) {
    int combined = getCombinedId4Data(section, x, y, z);
    if (combined == 0) {
        return 0;
    }
    Block block = Block.getBlockById(FaweCache.getId(combined));
    return block.getLightOpacity();
}
 
Example #21
Source File: MobileChunk.java    From archimedes-ships with MIT License 5 votes vote down vote up
@Override
public Block getBlock(int x, int y, int z)
{
	ExtendedBlockStorage storage = getBlockStorage(x, y, z);
	if (storage == null) return Blocks.air;
	return storage.getBlockByExtId(x & 15, y & 15, z & 15);
}
 
Example #22
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
    Chunk chunk = world.getChunkProvider().getLoadedChunk(cx, cz);
    if (chunk != null) {
        return chunk.getBlockStorageArray();
    }
    return null;
}
 
Example #23
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) {
    IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15);
    Block block = ibd.getBlock();
    int id = Block.getIdFromBlock(block);
    if (FaweCache.hasData(id)) {
        return (id << 4) + block.getMetaFromState(ibd);
    } else {
        return id << 4;
    }
}
 
Example #24
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
    Chunk chunk = world.getChunkProvider().getLoadedChunk(cx, cz);
    if (chunk != null) {
        return chunk.getBlockStorageArray();
    }
    return null;
}
 
Example #25
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean removeSectionLighting(ExtendedBlockStorage section, int layer, boolean sky) {
    if (section != null) {
        section.setBlockLight(new NibbleArray());
        if (sky) {
            section.setSkyLight(new NibbleArray());
        }
    }
    return section != null;
}
 
Example #26
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setFullbright(ExtendedBlockStorage[] sections) {
    for (int i = 0; i < sections.length; i++) {
        ExtendedBlockStorage section = sections[i];
        if (section != null) {
            byte[] bytes = section.getSkyLight().getData();
            Arrays.fill(bytes, (byte) 255);
        }
    }
}
 
Example #27
Source File: SpongeQueue_1_12.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public void setCount(int tickingBlockCount, int nonEmptyBlockCount, ExtendedBlockStorage section) throws NoSuchFieldException, IllegalAccessException {
    fieldTickingBlockCount.set(section, tickingBlockCount);
    fieldNonEmptyBlockCount.set(section, nonEmptyBlockCount);
}
 
Example #28
Source File: SpongeQueue_1_12.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ExtendedBlockStorage getCachedSection(ExtendedBlockStorage[] ExtendedBlockStorages, int cy) {
    return ExtendedBlockStorages[cy];
}
 
Example #29
Source File: SpongeQueue_1_12.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public void setPalette(ExtendedBlockStorage section, BlockStateContainer palette) throws NoSuchFieldException, IllegalAccessException {
    Field fieldSection = ExtendedBlockStorage.class.getDeclaredField("data");
    fieldSection.setAccessible(true);
    fieldSection.set(section, palette);
}
 
Example #30
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int getSkyLight(ExtendedBlockStorage section, int x, int y, int z) {
    return section.getSkyLight(x & 15, y & 15, z & 15);
}