Java源码示例:net.minecraft.world.chunk.ChunkPrimer
示例1
private void create(World p_191092_1_, ChunkProviderTofu p_191092_2_, Random p_191092_3_, int p_191092_4_, int p_191092_5_) {
Rotation rotation = Rotation.NONE;
ChunkPrimer chunkprimer = new ChunkPrimer();
p_191092_2_.setBlocksInChunk(p_191092_4_, p_191092_5_, chunkprimer);
int i = 5;
int j = 5;
int k = chunkprimer.findGroundBlockIdx(7, 7);
int l = chunkprimer.findGroundBlockIdx(7, 7 + j);
int i1 = chunkprimer.findGroundBlockIdx(7 + i, 7);
int j1 = chunkprimer.findGroundBlockIdx(7 + i, 7 + j);
int k1 = Math.min(Math.min(k, l), Math.min(i1, j1));
BlockPos blockpos = new BlockPos(p_191092_4_ * 16 + 8, k1, p_191092_5_ * 16 + 8);
List<TofuCastlePiece.TofuCastleTemplate> list = Lists.<TofuCastlePiece.TofuCastleTemplate>newLinkedList();
TofuCastlePiece.generateCore(p_191092_1_.getSaveHandler().getStructureTemplateManager(), blockpos, rotation, list, p_191092_3_);
this.components.addAll(list);
this.updateBoundingBox();
this.isValid = true;
}
示例2
protected void digBlock(ChunkPrimer data, int x, int y, int z, int chunkX, int chunkZ, boolean foundTop, IBlockState state, IBlockState up) {
net.minecraft.world.biome.Biome biome = world.getBiome(new BlockPos(x + chunkX * 16, 0, z + chunkZ * 16));
IBlockState top = biome.topBlock;
IBlockState filler = biome.fillerBlock;
if (this.canReplaceBlock(state, up) || state.getBlock() == top.getBlock() || state.getBlock() == filler.getBlock()) {
if (y - 1 < 10) {
data.setBlockState(x, y, z, BLK_LAVA);
} else {
data.setBlockState(x, y, z, BLK_AIR);
if (foundTop && data.getBlockState(x, y - 1, z).getBlock() == filler.getBlock()) {
data.setBlockState(x, y - 1, z, top.getBlock().getDefaultState());
}
}
}
}
示例3
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
double d0 = GRASS_COLOR_NOISE.getValue((double) x * 0.25D, (double) z * 0.25D);
if (d0 > 0.0D) {
int i = x & 15;
int j = z & 15;
for (int k = 255; k >= 0; --k) {
if (chunkPrimerIn.getBlockState(j, k, i).getMaterial() != Material.AIR) {
if (k == 62 && chunkPrimerIn.getBlockState(j, k, i).getBlock() != Blocks.WATER) {
chunkPrimerIn.setBlockState(j, k, i, WATER);
if (d0 < 0.12D) {
chunkPrimerIn.setBlockState(j, k + 1, i, WATER_LILY);
}
}
break;
}
}
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
示例4
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
double d0 = GRASS_COLOR_NOISE.getValue((double) x * 0.25D, (double) z * 0.25D);
if (d0 > 0.0D) {
int i = x & 15;
int j = z & 15;
for (int k = 255; k >= 0; --k) {
if (chunkPrimerIn.getBlockState(j, k, i).getMaterial() != Material.AIR) {
if (k == 62 && chunkPrimerIn.getBlockState(j, k, i).getBlock() != Blocks.WATER) {
chunkPrimerIn.setBlockState(j, k, i, WATER);
if (d0 < 0.12D) {
chunkPrimerIn.setBlockState(j, k + 1, i, WATER_LILY);
}
}
break;
}
}
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
示例5
@Nonnull
@Override
public Chunk generateChunk(int x, int z)
{
ChunkPrimer chunkprimer = new ChunkPrimer();
// Get a list of blocks to check lighting for, as a "side effect" of
// actually generating the clouds
List<Pair<BlockPos, BlockPos>> litBlocks = generate(x, z, chunkprimer);
Chunk chunk = new Chunk(world, chunkprimer, x, z);
litBlocks.forEach(pair ->
{
BlockPos lower = pair.getFirst();
BlockPos upper = pair.getSecond();
for (int i = 0; i < 15; i++)
{
if (lower.getY() + i > upper.getY()) return;
chunk.setLightFor(EnumSkyBlock.BLOCK, lower.up(i), 15 - i);
}
});
return chunk;
}
示例6
@Nonnull
@Override
public Chunk generateChunk(int x, int z) {
this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
ChunkPrimer chunkprimer = new ChunkPrimer();
generate(x, z, chunkprimer);
Chunk chunk = new Chunk(world, chunkprimer, x, z);
byte[] biomeArray = chunk.getBiomeArray();
for (int i = 0; i < biomeArray.length; ++i) {
biomeArray[i] = (byte) 42;
}
chunk.generateSkylightMap();
return chunk;
}
示例7
@SubscribeEvent
public void onChunkLoad(ChunkEvent.Load event) {
IChunk chunk = event.getChunk();
Map<BlockPos, TileEntity> tiles = null;
if (chunk instanceof ChunkPrimerWrapper) {
chunk = ((ChunkPrimerWrapper) chunk).func_217336_u();
}
if (chunk instanceof Chunk) {
tiles = ((Chunk) chunk).getTileEntityMap();
}
if (chunk instanceof ChunkPrimer) {
tiles = ((ChunkPrimer) chunk).getTileEntities();
}
if (tiles != null) {
for (TileEntity tile : tiles.values()) {
if (tile instanceof IChunkLoadTile) {
((IChunkLoadTile) tile).onChunkLoad();
}
}
}
}
示例8
@Override
public void genTerrainBlocks(World worldIn, Random rand,
ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
super.genTerrainBlocks(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
double d1 = GRASS_COLOR_NOISE.getValue((double)x * 0.25D, (double)z * 0.25D);
x = Math.abs(x % 16);
z = Math.abs(z % 16);
if (d1 > 0.2D)
{
chunkPrimerIn.setBlockState(x, 62, z, Blocks.GRASS.getDefaultState());
for(int y = (int)(61); y > 1; y--) {
if(!chunkPrimerIn.getBlockState(x, y, z).isOpaqueCube())
chunkPrimerIn.setBlockState(x, y, z, Blocks.GRASS.getDefaultState());
else
break;
}
}
}
示例9
protected void digBlock(ChunkPrimer data, int x, int y, int z, int chunkX, int chunkZ, boolean foundTop)
{
net.minecraft.world.biome.Biome biome = world.getBiome(new BlockPos(x + chunkX * 16, 0, z + chunkZ * 16));
IBlockState state = data.getBlockState(x, y, z);
IBlockState top = isExceptionBiome(biome) ? Blocks.GRASS.getDefaultState() : biome.topBlock;
IBlockState filler = isExceptionBiome(biome) ? Blocks.DIRT.getDefaultState() : biome.fillerBlock;
if (state.getBlock() == Blocks.STONE || state.getBlock() == top.getBlock() || state.getBlock() == filler.getBlock() || (fillerBlock != null && state.getBlock() == fillerBlock.getBlock()))
{
if (y - 1 < 10)
{
data.setBlockState(x, y, z, FLOWING_LAVA);
}
else
{
data.setBlockState(x, y, z, AIR);
if (foundTop && data.getBlockState(x, y - 1, z).getBlock() == filler.getBlock())
{
data.setBlockState(x, y - 1, z, top.getBlock().getDefaultState());
}
}
}
}
示例10
/**
* Recursively called by generate()
*/
@Override
protected void recursiveGenerate(World worldIn, int chunkX, int chunkZ, int originalX, int originalZ, ChunkPrimer chunkPrimerIn)
{
if (this.rand.nextInt(50) == 0)
{
double d0 = (double)(chunkX * 16 + this.rand.nextInt(16));
double d1 = (double)(this.rand.nextInt(this.rand.nextInt(40) + 8) + 20);
double d2 = (double)(chunkZ * 16 + this.rand.nextInt(16));
int i = 1;
for (int j = 0; j < 24; ++j)
{
float f = this.rand.nextFloat() * ((float)Math.PI * 2F);
float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F;
float f2 = (this.rand.nextFloat() * 2.0F + this.rand.nextFloat()) * 2.0F;
this.addTunnel(this.rand.nextLong(), originalX, originalZ, chunkPrimerIn, d0, d1, d2, f2, f, f1, 0, 0, 3.0D);
}
}
}
示例11
@Override
public Chunk generateChunk(int p_73154_1_, int p_73154_2_) {
Block[] ablock = new Block[65536];
byte[] abyte = new byte[65536];
ChunkPrimer chunkprimer = new ChunkPrimer();
//ChunkExtendedBiome
Chunk chunk = new Chunk(this.worldObj, chunkprimer, p_73154_1_, p_73154_2_);//new Chunk(this.worldObj, ablock, abyte, p_73154_1_, p_73154_2_);
//TODO: convert back to int
byte[] abyte1 = chunk.getBiomeArray();
Arrays.fill(abyte1, (byte)Biome.getIdForBiome(AdvancedRocketryBiomes.spaceBiome));
chunk.generateSkylightMap();
return chunk;
}
示例12
@Override
public Chunk provideChunk(int chunkX, int chunkZ)
{
worldX = chunkX * 16;
worldZ = chunkZ * 16;
islandChunkX = worldX % MAP_SIZE;
islandChunkZ = worldZ % MAP_SIZE;
mapX = (chunkX >> 8);
mapZ = (chunkZ >> 8);
islandMap = WorldGen.getInstance().getIslandMap(((chunkX*16/8) >> 12), ((chunkZ*16/8) >> 12));
this.rand.setSeed((long)chunkX * 341873128712L + (long)chunkZ * 132897987541L);
ChunkPrimer chunkprimer = new ChunkPrimer();
generateTerrain(chunkprimer);
Chunk chunk = new Chunk(this.worldObj, chunkprimer, chunkX, chunkZ);
chunk.generateSkylightMap();
return chunk;
}
示例13
@Override
public Chunk generateChunk(int x, int z)
{
ChunkPrimer data = new ChunkPrimer();
if(YUNoMakeGoodMap.instance.shouldGenerateNetherFortress(world))
genNetherBridge.generate(world, x, z, data);
else
genNetherBridge.generate(world, x, z, null);
Chunk ret = new Chunk(world, data, x, z);
Biome[] biomes = world.getBiomeProvider().getBiomes(null, x * 16, z * 16, 16, 16);
byte[] ids = ret.getBiomeArray();
for (int i = 0; i < ids.length; ++i)
{
ids[i] = (byte)Biome.getIdForBiome(biomes[i]);
}
ret.generateSkylightMap();
return ret;
}
示例14
@Override public Chunk generateChunk(int x, int z)
{
ChunkPrimer primer = new ChunkPrimer();
if (YUNoMakeGoodMap.instance.shouldGenerateEndCities(this.world))
this.endCityGen.generate(world, x, z, primer);
else
this.endCityGen.generate(world, x, z, null);
Chunk ret = new Chunk(world, primer, x, z);
Biome[] biomes = world.getBiomeProvider().getBiomes(null, x * 16, z * 16, 16, 16);
byte[] ids = ret.getBiomeArray();
for (int i = 0; i < ids.length; ++i)
{
ids[i] = (byte)Biome.getIdForBiome(biomes[i]);
}
ret.generateSkylightMap();
return ret;
}
示例15
public void replaceBiomeBlocks(int x, int z, ChunkPrimer primer, Biome[] biomesIn) {
if (!ForgeEventFactory.onReplaceBiomeBlocks(this, x, z, primer, this.world)) return;
this.depthBuffer = this.surfaceNoise.getRegion(this.depthBuffer, (double) (x * 16), (double) (z * 16), 16, 16, 0.0625D, 0.0625D, 1.0D);
for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 16; ++j) {
Biome biome = biomesIn[j + i * 16];
biome.genTerrainBlocks(this.world, this.rand, primer, x * 16 + i, z * 16 + j, this.depthBuffer[j + i * 16]);
}
}
}
示例16
@Override
public Chunk generateChunk(int x, int z) {
this.chunkX = x;
this.chunkZ = z;
this.rand.setSeed((long) x * 341873128712L + (long) z * 132897987541L);
ChunkPrimer chunkprimer = new ChunkPrimer();
this.biomesForGeneration = this.world.getBiomeProvider().getBiomes(this.biomesForGeneration, x * 16, z * 16, 16, 16);
this.setBlocksInChunk(x, z, chunkprimer);
this.buildSurfaces(chunkprimer);
this.setBedRock(chunkprimer);
this.caveGenerator.generate(this.world, x, z, chunkprimer);
if (this.mapFeaturesEnabled) {
this.mineshaft.generate(this.world, x, z, chunkprimer);
this.villageGenerator.generate(this.world, x, z, chunkprimer);
this.tofuCastle.generate(this.world, x, z, chunkprimer);
}
Chunk chunk = new Chunk(this.world, chunkprimer, x, z);
byte[] abyte = chunk.getBiomeArray();
for (int i = 0; i < abyte.length; ++i) {
abyte[i] = (byte) Biome.getIdForBiome(this.biomesForGeneration[i]);
}
chunk.generateSkylightMap();
return chunk;
}
示例17
private void setBedRock(ChunkPrimer primer) {
for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 16; ++j) {
IBlockState iblockstate2 = primer.getBlockState(i, 1, j);
if (iblockstate2.getBlock() == BlockLoader.tofuTerrain) {
primer.setBlockState(i, 0, j, BEDROCK);
primer.setBlockState(i, 1, j, BEDROCK);
}
}
}
}
示例18
/**
* Recursively called by generate()
*/
protected void recursiveGenerate(World worldIn, int chunkX, int chunkZ, int originalX, int originalZ, ChunkPrimer chunkPrimerIn) {
int i = this.rand.nextInt(this.rand.nextInt(this.rand.nextInt(15) + 1) + 1);
if (this.rand.nextInt(7) != 0) {
i = 0;
}
for (int j = 0; j < i; ++j) {
double d0 = (double) (chunkX * 16 + this.rand.nextInt(16));
double d1 = (double) this.rand.nextInt(this.rand.nextInt(120) + 8);
double d2 = (double) (chunkZ * 16 + this.rand.nextInt(16));
int k = 1;
if (this.rand.nextInt(4) == 0) {
this.addRoom(this.rand.nextLong(), originalX, originalZ, chunkPrimerIn, d0, d1, d2);
k += this.rand.nextInt(4);
}
for (int l = 0; l < k; ++l) {
float f = this.rand.nextFloat() * ((float) Math.PI * 2F);
float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F;
float f2 = this.rand.nextFloat() * 2.0F + this.rand.nextFloat();
if (this.rand.nextInt(10) == 0) {
f2 *= this.rand.nextFloat() * this.rand.nextFloat() * 3.0F + 1.0F;
}
this.addTunnel(this.rand.nextLong(), originalX, originalZ, chunkPrimerIn, d0, d1, d2, f2, f, f1, 0, 0, 1.0D);
}
}
}
示例19
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
if (noiseVal > 1.5D) {
this.topBlock = Blocks.GRASS.getDefaultState();
this.fillerBlock = Blocks.DIRT.getDefaultState();
} else {
this.topBlock = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT);
this.fillerBlock = Blocks.DIRT.getDefaultState();
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
示例20
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
if (noiseVal > 1.6D) {
this.topBlock = Blocks.STONE.getDefaultState();
this.fillerBlock = Blocks.STONE.getDefaultState();
} else {
this.topBlock = Blocks.GRASS.getDefaultState();
this.fillerBlock = Blocks.DIRT.getDefaultState();
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
示例21
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
if (noiseVal > 1D) {
this.topBlock = GRASS;
this.fillerBlock = SAND;
} else {
this.topBlock = SAND;
this.fillerBlock = SAND;
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
示例22
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
if (noiseVal > 1.5D) {
this.topBlock = GRASS;
this.fillerBlock = SAND;
} else {
this.topBlock = SAND;
this.fillerBlock = SAND;
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
示例23
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
if (noiseVal > 1.5D) {
this.topBlock = Blocks.STONE.getDefaultState();
this.fillerBlock = Blocks.STONE.getDefaultState();
} else {
this.topBlock = Blocks.GRASS.getDefaultState();
this.fillerBlock = Blocks.DIRT.getDefaultState();
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
示例24
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
if (noiseVal > 1.5D) {
this.topBlock = Blocks.GRASS.getDefaultState();
this.fillerBlock = Blocks.DIRT.getDefaultState();
} else {
this.topBlock = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT);
this.fillerBlock = Blocks.DIRT.getDefaultState();
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
示例25
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
if (noiseVal > 1.6D) {
this.topBlock = Blocks.STONE.getDefaultState();
this.fillerBlock = Blocks.STONE.getDefaultState();
} else {
this.topBlock = Blocks.GRASS.getDefaultState();
this.fillerBlock = Blocks.DIRT.getDefaultState();
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
示例26
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
if (noiseVal > 1D) {
this.topBlock = GRASS;
this.fillerBlock = SAND;
} else {
this.topBlock = SAND;
this.fillerBlock = SAND;
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
示例27
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
if (noiseVal > 1.5D) {
this.topBlock = GRASS;
this.fillerBlock = SAND;
} else {
this.topBlock = SAND;
this.fillerBlock = SAND;
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
示例28
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
if (noiseVal > 1.5D) {
this.topBlock = Blocks.STONE.getDefaultState();
this.fillerBlock = Blocks.STONE.getDefaultState();
} else {
this.topBlock = Blocks.GRASS.getDefaultState();
this.fillerBlock = Blocks.DIRT.getDefaultState();
}
this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
示例29
private List<Pair<BlockPos, BlockPos>> generate(int chunkX, int chunkZ, ChunkPrimer primer)
{
double[][] upperValues = new double[16][16];
double[][] lowerValues = new double[16][16];
for (int x = 0; x < 16; x++)
{
for (int z = 0; z < 16; z++)
{
upperValues[x][z] = upper.getValue((chunkX * 16 + x) / UPPER_X_SCALE, (chunkZ * 16 + z) / UPPER_Z_SCALE);
lowerValues[x][z] = lower.getValue((chunkX * 16 + x) / LOWER_X_SCALE, (chunkZ * 16 + z) / LOWER_Z_SCALE);
}
}
List<Pair<BlockPos, BlockPos>> litBlocks = new LinkedList<>();
for (int x = 0; x < 16; x++)
{
for (int z = 0; z < 16; z++)
{
int minY = (int) (lowerValues[x][z] * LOWER_Y_SCALE + LOWER_LEVEL);
int maxY = (int) (upperValues[x][z] * UPPER_Y_SCALE + UPPER_LEVEL);
litBlocks.add(new Pair<>(new BlockPos(chunkX * 16 + x, minY, chunkZ * 16 + z), new BlockPos(chunkX * 16 + x, maxY, chunkZ * 16 + z)));
for (int y = minY; y <= maxY; y++)
{
if (y == minY)
primer.setBlockState(x, y, z, ModBlocks.CLOUD.getDefaultState().withProperty(BlockCloud.HAS_LIGHT_VALUE, true));
else
{
// if (y >= minY + 6 && y <= maxY - 6)
// primer.setBlockState(x, y, z,
// ModFluids.LETHE.getActualBlock().getDefaultState());
// else
primer.setBlockState(x, y, z, ModBlocks.CLOUD.getDefaultState());
}
}
}
}
return litBlocks;
}
示例30
/**
* ok so
* this is supposed to work by genning everything below 128
* and then mirroring it over y - 128
* y = y > 128 ? 256 - y : y is the gud code
* idk how to make it work
*/
//0-15 for local, 16*chunk + 0-15 for noise
private void generate(int chunkX, int chunkZ, ChunkPrimer primer) {
//go through x
for (int locX = 0; locX < 16; locX++) {
//go through y (irrelevant of chunk location)
for (int locY = 0; locY < 256; locY++) {
//and now for z
for (int locZ = 0; locZ < 16; locZ++) {
if ((locY <= 64 && locY > 1) || (locY > 192 && locY < 255)) {
primer.setBlockState(locX, locY, locZ, DIRT);
} else if (locY == 1 || locY == 255) {
primer.setBlockState(locX, locY, locZ, BEDROCK);
}
}
//if the noise <1, air, else torikki Grass?
}
}
//mirroring!
for (int locX = 0; locX < 16; locX++) {
for (int locY = 65; locY < 128; locY++) {
for (int locZ = 0; locZ < 16; locZ++) {
if(.5 <noise.getValue(chunkZ, chunkX)){
primer.setBlockState(locX,locY,locZ,DIRT);
}
}
}
}
}