Java Code Examples for net.minecraft.world.chunk.Chunk#getBlockStorageArray()

The following examples show how to use net.minecraft.world.chunk.Chunk#getBlockStorageArray() . 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: HelperActions.java    From burlapcraft with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static int getBlockId(int x, int y, int z) {
	Chunk chunk = mc.theWorld.getChunkFromChunkCoords(x >> 4, z >> 4);
	chunk.getBlock(x & 0xF, y, z & 0xF);
	int blockId = 0;

	ExtendedBlockStorage[] sa = chunk.getBlockStorageArray();
	if (y >> 4 < sa.length) {
		ExtendedBlockStorage extendedblockstorage = sa[(y >> 4)];

		if (extendedblockstorage != null) {
			int lx = x & 0xF;
			int ly = y & 0xF;
			int lz = z & 0xF;
			blockId = extendedblockstorage.getBlockLSBArray()[(ly << 8
					| lz << 4 | lx)] & 0xFF;
			NibbleArray blockMSBArray = extendedblockstorage
					.getBlockMSBArray();

			if (blockMSBArray != null) {
				blockId |= blockMSBArray.get(lx, ly, lz) << 8;
			}
		}
	}

	return blockId;
}
 
Example 2
Source File: ChunkManager.java    From mapwriter with MIT License 6 votes vote down vote up
public static MwChunk copyToMwChunk(Chunk chunk) {
	
	byte[][] msbArray = new byte[16][];
	byte[][] lsbArray = new byte[16][];
	byte[][] metaArray = new byte[16][];
	byte[][] lightingArray = new byte[16][];
	
	ExtendedBlockStorage[] storageArrays = chunk.getBlockStorageArray();
	if (storageArrays != null) {
		for (ExtendedBlockStorage storage : storageArrays) {
			if (storage != null) {
				int y = (storage.getYLocation() >> 4) & 0xf;
				lsbArray[y] = storage.getBlockLSBArray();
				msbArray[y] = (storage.getBlockMSBArray() != null) ? storage.getBlockMSBArray().data : null;
				metaArray[y] = (storage.getMetadataArray() != null) ? storage.getMetadataArray().data : null;
				lightingArray[y] = (storage.getBlocklightArray() != null) ? storage.getBlocklightArray().data : null;
			}
		}
	}
	
	return new MwChunk(chunk.xPosition, chunk.zPosition, chunk.worldObj.provider.dimensionId,
			msbArray, lsbArray, metaArray, lightingArray, chunk.getBiomeArray());
}
 
Example 3
Source File: BlockUtils.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
public static void setBlockSneaky(World world, int x, int y, int z, Block block) {

        Chunk chunk = world.getChunkFromChunkCoords(x >> 4, z >> 4);
        if (chunk != null) {
            ExtendedBlockStorage ebs = chunk.getBlockStorageArray()[y >> 4];
            if (ebs != null)
                ebs.func_150818_a(x & 15, y & 15, z & 15, block);
        }
    }
 
Example 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ExtendedBlockStorage[] getSections(Chunk chunk) {
    return chunk.getBlockStorageArray();
}
 
Example 12
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ExtendedBlockStorage[] getSections(Chunk chunk) {
    return chunk.getBlockStorageArray();
}
 
Example 13
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ExtendedBlockStorage[] getSections(Chunk chunk) {
    return chunk.getBlockStorageArray();
}
 
Example 14
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ExtendedBlockStorage[] getSections(Chunk chunk) {
    return chunk.getBlockStorageArray();
}
 
Example 15
Source File: PhysicsObject.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
public void detectgetBlockPositions() {
    // int minChunkX = claimedChunks[0][0].x;
    // int minChunkZ = claimedChunks[0][0].z;
    int chunkX, chunkZ, index, x, y, z;
    Chunk chunk;
    ExtendedBlockStorage storage;
    Chunk[][] claimedChunks = claimedChunkCache.getCacheArray();
    int airStateIndex = Block.getStateId(Blocks.AIR.getDefaultState());

    for (chunkX = claimedChunks.length - 1; chunkX > -1; chunkX--) {
        for (chunkZ = claimedChunks[0].length - 1; chunkZ > -1; chunkZ--) {
            chunk = claimedChunks[chunkX][chunkZ];
            if (chunk != null) {
                for (index = 0; index < 16; index++) {
                    storage = chunk.getBlockStorageArray()[index];
                    if (storage != null) {
                        for (y = 0; y < 16; y++) {
                            for (x = 0; x < 16; x++) {
                                for (z = 0; z < 16; z++) {
                                    if (storage.data.storage
                                        .getAt(y << 8 | z << 4 | x)
                                        != airStateIndex) {
                                        BlockPos pos = new BlockPos(chunk.x * 16 + x,
                                            index * 16 + y,
                                            chunk.z * 16 + z);
                                        getBlockPositions().add(pos);
                                        blockPositionsGameTick
                                            .add(this.getBlockPosToIntRelToShip(pos));
                                        voxelFieldAABBMaker
                                            .addVoxel(pos.getX(), pos.getY(), pos.getZ());
                                        if (BlockPhysicsDetails.isBlockProvidingForce(
                                            world().getBlockState(pos), pos, world())) {
                                            getPhysicsProcessor()
                                                .addPotentialActiveForcePos(pos);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

}
 
Example 16
Source File: SpongeQueue_1_12.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ExtendedBlockStorage[] getSections(Chunk chunk) {
    return chunk.getBlockStorageArray();
}
 
Example 17
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ExtendedBlockStorage[] getSections(Chunk chunk) {
    return chunk.getBlockStorageArray();
}
 
Example 18
Source File: SpongeQueue_1_11.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ExtendedBlockStorage[] getSections(Chunk chunk) {
    return chunk.getBlockStorageArray();
}
 
Example 19
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ExtendedBlockStorage[] getSections(Chunk chunk) {
    return chunk.getBlockStorageArray();
}
 
Example 20
Source File: PacketChunkInfo.java    From LookingGlass with GNU General Public License v3.0 4 votes vote down vote up
public static Extracted getMapChunkData(Chunk chunk, boolean includeinit, int subid) {
	int j = 0;
	ExtendedBlockStorage[] aextendedblockstorage = chunk.getBlockStorageArray();
	int k = 0;
	S21PacketChunkData.Extracted extracted = new S21PacketChunkData.Extracted();
	if (dataarray == null || dataarray.length < 196864) {
		dataarray = new byte[196864];
	}
	byte[] abyte = dataarray;

	if (includeinit) {
		chunk.sendUpdates = true;
	}

	int l;

	for (l = 0; l < aextendedblockstorage.length; ++l) {
		if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) && (subid & 1 << l) != 0) {
			extracted.field_150280_b |= 1 << l;

			if (aextendedblockstorage[l].getBlockMSBArray() != null) {
				extracted.field_150281_c |= 1 << l;
				++k;
			}
		}
	}

	for (l = 0; l < aextendedblockstorage.length; ++l) {
		if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) && (subid & 1 << l) != 0) {
			byte[] abyte1 = aextendedblockstorage[l].getBlockLSBArray();
			System.arraycopy(abyte1, 0, abyte, j, abyte1.length);
			j += abyte1.length;
		}
	}

	NibbleArray nibblearray;

	for (l = 0; l < aextendedblockstorage.length; ++l) {
		if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) && (subid & 1 << l) != 0) {
			nibblearray = aextendedblockstorage[l].getMetadataArray();
			System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length);
			j += nibblearray.data.length;
		}
	}

	for (l = 0; l < aextendedblockstorage.length; ++l) {
		if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) && (subid & 1 << l) != 0) {
			nibblearray = aextendedblockstorage[l].getBlocklightArray();
			System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length);
			j += nibblearray.data.length;
		}
	}

	if (!chunk.worldObj.provider.hasNoSky) {
		for (l = 0; l < aextendedblockstorage.length; ++l) {
			if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) && (subid & 1 << l) != 0) {
				nibblearray = aextendedblockstorage[l].getSkylightArray();
				System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length);
				j += nibblearray.data.length;
			}
		}
	}

	if (k > 0) {
		for (l = 0; l < aextendedblockstorage.length; ++l) {
			if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) && aextendedblockstorage[l].getBlockMSBArray() != null && (subid & 1 << l) != 0) {
				nibblearray = aextendedblockstorage[l].getBlockMSBArray();
				System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length);
				j += nibblearray.data.length;
			}
		}
	}

	if (includeinit) {
		byte[] abyte2 = chunk.getBiomeArray();
		System.arraycopy(abyte2, 0, abyte, j, abyte2.length);
		j += abyte2.length;
	}

	extracted.field_150282_a = new byte[j];
	System.arraycopy(abyte, 0, extracted.field_150282_a, 0, j);
	return extracted;
}