Java Code Examples for net.minecraft.world.chunk.ChunkPrimer#getBlockState()
The following examples show how to use
net.minecraft.world.chunk.ChunkPrimer#getBlockState() .
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: MapGenRavineExt.java From AdvancedRocketry with MIT License | 6 votes |
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()); } } } }
Example 2
Source File: ChunkProviderTofu.java From TofuCraftReload with MIT License | 5 votes |
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); } } } }
Example 3
Source File: WorldGenSwampTree.java From AdvancedRocketry with MIT License | 5 votes |
private IBlockState getBlock(BlockPos pos, Block block, ChunkPrimer blocks) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); if(x > 15 || x < 0 || z > 15 || z < 0 || y < 0 || y > 255) return Blocks.AIR.getDefaultState(); return blocks.getBlockState(x, y, z); }
Example 4
Source File: ChunkProviderSurface.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/** * This is for stripping a chunk of all but ore and BEDROCK for easier testing. */ protected void stripChunk(ChunkPrimer primer) { Point p; Center closestCenter; IBlockState state; for(int x = 0; x < 16; x++) { for(int z = 0; z < 16; z++) { p = new Point(x, z); closestCenter = this.getHex(p); int hexElev = this.getHexElevation(closestCenter, p); if(closestCenter.hasAnyMarkersOf(Marker.Coast, Marker.Ocean)) continue; for(int y = hexElev; y >= 0; y--) { state = primer.getBlockState(x, y, z); if(state.getBlock() != TFCBlocks.Ore && state.getBlock() != Blocks.BEDROCK && state.getBlock() != Blocks.WOOL) { primer.setBlockState(x, y, z, Blocks.AIR.getDefaultState()); } } } } }
Example 5
Source File: ChunkProviderTofu.java From TofuCraftReload with MIT License | 4 votes |
private void buildSurfaces(ChunkPrimer primer) { int l; IBlockState iblockstate, iblockstate1, desertstone; for (int i = 0; i < 16; ++i) { for (int j = 0; j < 16; ++j) { l = -1; Biome biome = this.biomesForGeneration[j + i * 16]; iblockstate = biome.topBlock; iblockstate1 = biome.fillerBlock; desertstone = BlockLoader.tofuTerrain.getDefaultState(); for (int i1 = 127; i1 >= 0; --i1) { IBlockState iblockstate2 = primer.getBlockState(i, i1, j); if (iblockstate2.getMaterial() == Material.AIR) { l = -3; } else if (iblockstate2.getBlock() == BlockLoader.tofuTerrain) { if (l <= -1) { if (l == -3) { primer.setBlockState(i, i1, j, iblockstate); } else { primer.setBlockState(i, i1, j, iblockstate1); } l += 1; } else if (l > 0) { --l; primer.setBlockState(i, i1, j, desertstone); } } } } } }
Example 6
Source File: MapGenTofuCaves.java From TofuCraftReload with MIT License | 4 votes |
private boolean isTopBlock(ChunkPrimer data, int x, int y, int z, int chunkX, int chunkZ) { net.minecraft.world.biome.Biome biome = world.getBiome(new BlockPos(x + chunkX * 16, 0, z + chunkZ * 16)); IBlockState state = data.getBlockState(x, y, z); return (isExceptionBiome(biome) ? state.getBlock() == Blocks.GRASS : state.getBlock() == biome.topBlock); }
Example 7
Source File: BiomeCanyon.java From CommunityMod with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) { int i = worldIn.getSeaLevel(); IBlockState iblockstate = this.topBlock; IBlockState iblockstate1 = this.fillerBlock; int j = -1; int k = (int) (noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D); int l = x & 15; int i1 = z & 15; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int j1 = 255; j1 >= 0; --j1) { if (j1 <= rand.nextInt(5)) { chunkPrimerIn.setBlockState(i1, j1, l, BEDROCK); } else { IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l); if (iblockstate2.getMaterial() == Material.AIR) { j = -1; } else if (iblockstate2.getBlock() == Blocks.STONE) { if (j == -1) { if (k <= 0) { iblockstate = AIR; iblockstate1 = STONE; } else if (j1 >= i - 4 && j1 <= i + 1) { iblockstate = this.topBlock; iblockstate1 = this.fillerBlock; } if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) { if (this.getTemperature(blockpos$mutableblockpos.setPos(x, j1, z)) < 0.15F) { iblockstate = ICE; } else { iblockstate = WATER; } } j = k; if (j1 >= i - 1) { chunkPrimerIn.setBlockState(i1, j1, l, iblockstate); } else if (j1 < i - 7 - k) { iblockstate = AIR; iblockstate1 = STONE; chunkPrimerIn.setBlockState(i1, j1, l, GRAVEL); } else { chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1); } } else if (j > 0) { --j; chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1); if (j == 0 && iblockstate1.getBlock() == Blocks.SAND && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate1 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? RED_SANDSTONE : SANDSTONE; } if (j == 0 && iblockstate == redRock && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate = redRock; } if (j == 0 && iblockstate1 == redRock && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate1 = redRock; } } } } } }
Example 8
Source File: BiomeCragCliffs.java From CommunityMod with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) { int i = worldIn.getSeaLevel(); IBlockState iblockstate = this.topBlock; IBlockState iblockstate1 = this.fillerBlock; int j = -1; int k = (int) (noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D); int l = x & 15; int i1 = z & 15; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int j1 = 255; j1 >= 0; --j1) { if (j1 <= rand.nextInt(5)) { chunkPrimerIn.setBlockState(i1, j1, l, BEDROCK); } else { IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l); if (iblockstate2.getMaterial() == Material.AIR) { j = -1; } else if (iblockstate2.getBlock() == Blocks.STONE) { if (j == -1) { if (k <= 0) { iblockstate = AIR; iblockstate1 = STONE; } else if (j1 >= i - 4 && j1 <= i + 1) { iblockstate = this.topBlock; iblockstate1 = this.fillerBlock; } if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) { if (this.getTemperature(blockpos$mutableblockpos.setPos(x, j1, z)) < 0.15F) { iblockstate = ICE; } else { iblockstate = WATER; } } j = k; if (j1 >= i - 1) { chunkPrimerIn.setBlockState(i1, j1, l, iblockstate); } else if (j1 < i - 7 - k) { iblockstate = AIR; iblockstate1 = STONE; chunkPrimerIn.setBlockState(i1, j1, l, GRAVEL); } else { chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1); } } else if (j > 0) { --j; chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1); if (j == 0 && iblockstate1.getBlock() == Blocks.SAND && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate1 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? RED_SANDSTONE : SANDSTONE; } if (j == 0 && iblockstate == blueRock && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate = blueRock; } if (j == 0 && iblockstate1 == blueRock && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate1 = blueRock; } } } } } }
Example 9
Source File: BiomeCanyon.java From Traverse-Legacy-1-12-2 with MIT License | 4 votes |
@Override public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) { int i = worldIn.getSeaLevel(); IBlockState iblockstate = this.topBlock; IBlockState iblockstate1 = this.fillerBlock; int j = -1; int k = (int) (noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D); int l = x & 15; int i1 = z & 15; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int j1 = 255; j1 >= 0; --j1) { if (j1 <= rand.nextInt(5)) { chunkPrimerIn.setBlockState(i1, j1, l, BEDROCK); } else { IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l); if (iblockstate2.getMaterial() == Material.AIR) { j = -1; } else if (iblockstate2.getBlock() == Blocks.STONE) { if (j == -1) { if (k <= 0) { iblockstate = AIR; iblockstate1 = STONE; } else if (j1 >= i - 4 && j1 <= i + 1) { iblockstate = this.topBlock; iblockstate1 = this.fillerBlock; } if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) { if (this.getTemperature(blockpos$mutableblockpos.setPos(x, j1, z)) < 0.15F) { iblockstate = ICE; } else { iblockstate = WATER; } } j = k; if (j1 >= i - 1) { chunkPrimerIn.setBlockState(i1, j1, l, iblockstate); } else if (j1 < i - 7 - k) { iblockstate = AIR; iblockstate1 = STONE; chunkPrimerIn.setBlockState(i1, j1, l, GRAVEL); } else { chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1); } } else if (j > 0) { --j; chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1); if (j == 0 && iblockstate1.getBlock() == Blocks.SAND && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate1 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? RED_SANDSTONE : SANDSTONE; } if (j == 0 && iblockstate == redRock && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate = redRock; } if (j == 0 && iblockstate1 == redRock && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate1 = redRock; } } } } } }
Example 10
Source File: BiomeCragCliffs.java From Traverse-Legacy-1-12-2 with MIT License | 4 votes |
@Override public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) { int i = worldIn.getSeaLevel(); IBlockState iblockstate = this.topBlock; IBlockState iblockstate1 = this.fillerBlock; int j = -1; int k = (int) (noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D); int l = x & 15; int i1 = z & 15; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int j1 = 255; j1 >= 0; --j1) { if (j1 <= rand.nextInt(5)) { chunkPrimerIn.setBlockState(i1, j1, l, BEDROCK); } else { IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l); if (iblockstate2.getMaterial() == Material.AIR) { j = -1; } else if (iblockstate2.getBlock() == Blocks.STONE) { if (j == -1) { if (k <= 0) { iblockstate = AIR; iblockstate1 = STONE; } else if (j1 >= i - 4 && j1 <= i + 1) { iblockstate = this.topBlock; iblockstate1 = this.fillerBlock; } if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) { if (this.getTemperature(blockpos$mutableblockpos.setPos(x, j1, z)) < 0.15F) { iblockstate = ICE; } else { iblockstate = WATER; } } j = k; if (j1 >= i - 1) { chunkPrimerIn.setBlockState(i1, j1, l, iblockstate); } else if (j1 < i - 7 - k) { iblockstate = AIR; iblockstate1 = STONE; chunkPrimerIn.setBlockState(i1, j1, l, GRAVEL); } else { chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1); } } else if (j > 0) { --j; chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1); if (j == 0 && iblockstate1.getBlock() == Blocks.SAND && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate1 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? RED_SANDSTONE : SANDSTONE; } if (j == 0 && iblockstate == blueRock && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate = blueRock; } if (j == 0 && iblockstate1 == blueRock && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate1 = blueRock; } } } } } }
Example 11
Source File: MapGenCrater.java From AdvancedRocketry with MIT License | 4 votes |
@Override protected void recursiveGenerate(World world, int chunkX, int chunkZ, int p_180701_4_, int p_180701_5_, ChunkPrimer chunkPrimerIn) { if(rand.nextInt(chancePerChunk) == Math.abs(chunkX) % chancePerChunk && rand.nextInt(chancePerChunk) == Math.abs(chunkZ) % chancePerChunk) { int radius = rand.nextInt(56) + 8; //64; 8 -> 64 //TODO: make hemisphere from surface and line the side with ore of some kind int depth = radius*radius; int xCoord = -chunkX + p_180701_4_; int zCoord = -chunkZ + p_180701_5_; for(int x = 15; x >= 0; x--) { for(int z = 15; z >= 0; z--) { for(int y = 254; y >= 0; y--) { if(chunkPrimerIn.getBlockState(x, y, z) != Blocks.AIR.getDefaultState()) { //&& chunkPrimerIn.getBlockState(x, y, z).isOpaqueCube()) { int count = ( depth - ( ((xCoord*16)+x)*((xCoord*16)+x) + ((zCoord*16)+z)*((zCoord*16)+z) ) )/(radius*2); for(int dist = 0; dist < count; dist++) { if(y-dist > 2) chunkPrimerIn.setBlockState(x, y-dist, z, Blocks.AIR.getDefaultState()); } int ridgeSize = 12; if(count <= 0 && count > -2*ridgeSize) { for(int dist = 0; dist < ((ridgeSize*ridgeSize) - (count+ridgeSize)*(count+ridgeSize))/(ridgeSize*2); dist++) { if(y + dist < 255) chunkPrimerIn.setBlockState(x, y + dist, z, world.getBiome(new BlockPos(chunkX*16,0, chunkZ*16)).topBlock); } } if(count > 1 && (y-count > 2)) chunkPrimerIn.setBlockState(x, y - count, z, world.getBiome(new BlockPos(chunkX*16,0, chunkZ*16)).topBlock); break; } } } } } }
Example 12
Source File: MapGenGeode.java From AdvancedRocketry with MIT License | 4 votes |
@Override protected void recursiveGenerate(World world, int chunkX, int chunkZ, int p_180701_4_, int p_180701_5_, ChunkPrimer chunkPrimerIn) { if(rand.nextInt(chancePerChunk) == Math.abs(chunkX) % chancePerChunk || rand.nextInt(chancePerChunk) == Math.abs(chunkZ) % chancePerChunk) { int radius = rand.nextInt(Configuration.geodeVariation) + Configuration.geodeBaseSize - (Configuration.geodeVariation/2); //24; 24 -> 48 //TODO: make hemisphere from surface and line the side with ore of some kind int depth = radius*radius; int xCoord = -chunkX + p_180701_4_; int zCoord = -chunkZ + p_180701_5_; BlockPos pos = new BlockPos(chunkX*16, 0, chunkZ*16); int avgY = (int) ((world.getBiome(pos).getBaseHeight() + 2) *32) - 3*radius/4; for(int x = 15; x >= 0; x--) { for(int z = 15; z >= 0; z--) { int index; for(int y = 255; y >= 0; y--) { index = (x * 16 + z) * 256 + y; if(chunkPrimerIn.getBlockState(x, y, z) != Blocks.AIR.getDefaultState()) break; } int count = ( depth - ( ((xCoord*16)+x)*((xCoord*16)+x) + ((zCoord*16)+z)*((zCoord*16)+z) ) )/(radius*2); //Check for IOB exceptions early, in case it generates near bedrock or something if(avgY-count < 1 || avgY+count > 255) continue; //Clears air for the ceiling for(int dist = -count; dist < Math.min(count,3); dist++) { index = (x * 16 + z) * 256 + avgY -dist; chunkPrimerIn.setBlockState(x, avgY - dist, z, Blocks.AIR.getDefaultState()); } if(count >= 0) { if(count > 4) { int size = rand.nextInt(4) + 4; //Generates ore hanging from the ceiling if( x % 4 > 0 && z % 4 > 0) { for(int i = 1; i < size; i++) chunkPrimerIn.setBlockState(x, avgY + count - i, z, ores.get((x/4 + z/4) % ores.size()).getBlockState()); } else { size -=2; for(int i = 1; i < size; i++) { chunkPrimerIn.setBlockState(x, avgY + count - i, z, Blocks.STONE.getDefaultState()); } } //Generates ore in the floor if( (x+2) % 4 > 0 && (z+2) % 4 > 0) { for(int i = 1; i < size; i++) chunkPrimerIn.setBlockState(x, avgY - count + i, z, ores.get((x/4 + z/4) % ores.size()).getBlockState()); } } chunkPrimerIn.setBlockState(x, avgY - count, z, AdvancedRocketryBlocks.blocksGeode.getDefaultState()); chunkPrimerIn.setBlockState(x, avgY + count, z, AdvancedRocketryBlocks.blocksGeode.getDefaultState()); } } } } }
Example 13
Source File: ChunkProviderCavePlanet.java From AdvancedRocketry with MIT License | 4 votes |
public void buildSurfaces(int p_185937_1_, int p_185937_2_, ChunkPrimer primer) { if (!net.minecraftforge.event.ForgeEventFactory.onReplaceBiomeBlocks(this, p_185937_1_, p_185937_2_, primer, this.world)) return; int i = this.world.getSeaLevel() + 1; double d0 = 0.03125D; this.slowsandNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.slowsandNoise, p_185937_1_ * 16, p_185937_2_ * 16, 0, 16, 16, 1, 0.03125D, 0.03125D, 1.0D); this.gravelNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.gravelNoise, p_185937_1_ * 16, 109, p_185937_2_ * 16, 16, 1, 16, 0.03125D, 1.0D, 0.03125D); this.depthBuffer = this.netherrackExculsivityNoiseGen.generateNoiseOctaves(this.depthBuffer, p_185937_1_ * 16, p_185937_2_ * 16, 0, 16, 16, 1, 0.0625D, 0.0625D, 0.0625D); for (int j = 0; j < 16; ++j) { for (int k = 0; k < 16; ++k) { boolean flag = this.slowsandNoise[j + k * 16] + this.rand.nextDouble() * 0.2D > 0.0D; boolean flag1 = this.gravelNoise[j + k * 16] + this.rand.nextDouble() * 0.2D > 0.0D; int l = (int)(this.depthBuffer[j + k * 16] / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D); int i1 = -1; IBlockState iblockstate = this.fillblock; IBlockState iblockstate1 = this.fillblock; for (int j1 = 127; j1 >= 0; --j1) { IBlockState iblockstate2 = primer.getBlockState(k, j1, j); if (iblockstate2.getBlock() != null && iblockstate2.getMaterial() != Material.AIR) { if (iblockstate2 == fillblock) { if (i1 == -1) { if (l <= 0) { iblockstate = AIR; iblockstate1 = this.fillblock; } else if (j1 >= i - 4 && j1 <= i + 1) { iblockstate = this.fillblock; iblockstate1 = this.fillblock; } if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) { iblockstate = oceanBlock; } i1 = l; if (j1 >= i - 1) { primer.setBlockState(k, j1, j, iblockstate); } else { primer.setBlockState(k, j1, j, iblockstate1); } } else if (i1 > 0) { --i1; primer.setBlockState(k, j1, j, iblockstate1); } } } else { i1 = -1; } } } } }
Example 14
Source File: ChunkProviderSurface.java From TFC2 with GNU General Public License v3.0 | 4 votes |
private boolean isAir(ChunkPrimer chunkprimer, BlockPos pos) { if(pos.getX() < 0 || pos.getX() > 15 || pos.getZ() < 0 || pos.getZ() > 15 || pos.getY() < 0 || pos.getY() > 255) return false; return chunkprimer.getBlockState(pos.getX(), pos.getY(), pos.getZ()) == Blocks.AIR.getDefaultState(); }
Example 15
Source File: ChunkProviderSurface.java From TFC2 with GNU General Public License v3.0 | 4 votes |
public IBlockState getState(ChunkPrimer primer, BlockPos pos) { if(pos.getX() >= 0 && pos.getY() >= 0 && pos.getZ() >= 0 && pos.getX() < 16 && pos.getY() < 256 && pos.getZ() < 16) return primer.getBlockState(pos.getX(), pos.getY(), pos.getZ()); return Blocks.AIR.getDefaultState(); }