Java Code Examples for net.minecraft.world.World#getTopSolidOrLiquidBlock()
The following examples show how to use
net.minecraft.world.World#getTopSolidOrLiquidBlock() .
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: NH_QuarryPopulator.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 5 votes |
public void generateQuarry(World world, Random rand, int chunkX, int chunkZ) { int x = chunkX * 16 + 8; int z = chunkZ * 16 + 8; if(canGen(world, rand, x, z)) { int y = world.getTopSolidOrLiquidBlock(x, z) - 3; if(WorldPlugin.getBlock(world, x, y, z) == Blocks.dirt) { quarry.generate(world, rand, x, y, z); } } }
Example 2
Source File: BlockElectricMushroom.java From AdvancedRocketry with MIT License | 5 votes |
@Override public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { if(!world.isRemote && Configuration.electricPlantsSpawnLightning && world.isRaining() && world.getBiome(pos) == AdvancedRocketryBiomes.stormLandsBiome) { int lightningX = pos.getX() + rand.nextInt(24) - 12; int lightningZ = pos.getZ() + rand.nextInt(24) - 12; BlockPos lightning = new BlockPos(lightningX, 0, lightningZ ); lightning = world.getTopSolidOrLiquidBlock(lightning); world.addWeatherEffect(new EntityLightningBolt(world, lightning.getX(), lightning.getY(), lightning.getZ(), true)); } }
Example 3
Source File: WorldGenLooseRockHex.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@Override public void generate(Random random, IslandMap map, Center closest, World world) { super.generate(random, map, closest, world); if(world.provider.getDimension() != 0) return; int chance, height; BlockPos bp; Material mat; int amountOfRocks = 25; if(closest.hasAttribute(Attribute.River)) amountOfRocks -= 10; if(mcElev(closest.getHighestNeighbor().getElevation()) - mcElev(closest.getElevation()) > 10 ) amountOfRocks += 10; for(int i = 0; i < amountOfRocks; i++) { Point p = new Point(centerX-20+random.nextInt(42), centerZ-20+random.nextInt(42)); if(p.distanceSq(centerPos.getX(), centerPos.getZ()) < 400) { BlockPos pos = new BlockPos(p.getX(), 0, p.getZ()); pos = world.getTopSolidOrLiquidBlock(pos); IBlockState state = world.getBlockState(pos.down()); if(Core.isTerrain(state) && !Core.isWater(world.getBlockState(pos))) Core.setBlock(world, TFCBlocks.LooseRocks.getStateFromMeta(map.getParams().getSurfaceRock().getMeta()), pos, 2); } } }
Example 4
Source File: WorldGenPortalsHex.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@Override public void generate(Random random, IslandMap map, Center closest, World world) { super.generate(random, map, closest, world); if(world.provider.getDimension() == 0) { if(closest != null && closest.hasAttribute(Attribute.Portal)) { PortalAttribute attr = (PortalAttribute) closest.getAttribute(Attribute.Portal); Point p = new Point(centerX, centerZ); BlockPos bp = centerPos; /* * This should hopefully prevent stacking portals from occuring if the world saves but the islandmap does not */ if(findPortal(world, bp.add(0, map.convertHeightToMC(closest.elevation)+Global.SEALEVEL, 0)) != null) { return; } bp = world.getTopSolidOrLiquidBlock(bp); BlockPos portalPos = bp; BuildPortalSchem(world, closest, portalPos, map, false); //Once we generate the portal structure, just end this generator. //We dont want to potentially generate it 256 times return; } } }
Example 5
Source File: AuraEffects.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void doBlockEffect(ChunkCoordinates originTile, ChunkCoordinates selectedBlock, World world) { int highestY = world.getTopSolidOrLiquidBlock(selectedBlock.posX, selectedBlock.posZ); EntityLightningBolt entityLightning = new EntityLightningBolt(world, selectedBlock.posX + 0.5, highestY, selectedBlock.posZ + 0.5); world.addWeatherEffect(entityLightning); }
Example 6
Source File: WorldGenGrassHex.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public void generate(Random random, IslandMap map, Center closest, World world) { super.generate(random, map, closest, world); if(world.provider.getDimension() != 0) return; IBlockState state = TFCBlocks.Vegetation.getDefaultState(); Moisture cMoisture; float rand, m; //Place grass for(int x = -22; x <= 22; x++) { for(int z = -22; z < 22; z++) { Point p = new Point(centerX+x, centerZ+z); if(p.distanceSq(centerPos.getX(), centerPos.getZ()) < 400) { BlockPos bp = new BlockPos(p.getX(), 0, p.getZ()); bp = world.getTopSolidOrLiquidBlock(bp); if(world.getBlockState(bp).getBlock() != Blocks.AIR || closest.biome == BiomeType.BEACH) { continue; } if(!map.getParams().hasFeature(Feature.Desert) && Core.isStone(world.getBlockState(bp.down())) && random.nextInt(3) == 0) { Core.setBlock(world, TFCBlocks.VegDesert.getDefaultState().withProperty(BlockVegDesert.META_PROPERTY, DesertVegType.ShortGrassSparse), bp, 2); } else if(Core.isGrass(world.getBlockState(bp.down()))) { boolean genGrass = false; if(closest.biome == BiomeType.MARSH || closest.biome == BiomeType.LAKE || closest.biome == BiomeType.SWAMP) genGrass = random.nextFloat() < 0.75; else genGrass = random.nextFloat() < 0.25; if(genGrass) { cMoisture = closest.getMoisture(); rand = random.nextFloat(); VegType vt = VegType.Grass; if(iMoisture == Moisture.LOW) { continue; } else if(iMoisture == Moisture.MEDIUM) { rand = random.nextFloat(); if(rand < 0.25) vt = VegType.ShortGrass; else if(rand < 0.5) vt = VegType.ShorterGrass; } else if(iMoisture.isGreaterThanOrEqual(Moisture.HIGH)) { rand = random.nextFloat(); if(rand < 0.25) vt = VegType.ShortGrass; else if(rand < 0.35) vt = VegType.ShorterGrass; } boolean tall = rand > cMoisture.getInverse()*2; if(map.getParams().getIslandTemp().isWarmerThanOrEqual(ClimateTemp.SUBTROPICAL) && iMoisture.isGreaterThanOrEqual(Moisture.VERYHIGH)) { if(vt == VegType.Grass) vt = VegType.GrassLush; else if(vt == VegType.ShortGrass) vt = VegType.ShortGrassLush; else if(vt == VegType.ShorterGrass) vt = VegType.ShorterGrassLush; if(cMoisture.isGreaterThanOrEqual(Moisture.HIGH)) { if(random.nextFloat() < cMoisture.getMoisture()) { tall = false; vt = VegType.Toquilla; } } } if(closest.hasMarker(Marker.Clearing) && iMoisture.isGreaterThanOrEqual(Moisture.VERYHIGH) && tall) { Core.setBlock(world, state.withProperty(BlockVegetation.META_PROPERTY, VegType.DoubleGrassBottomLush), bp, 2); Core.setBlock(world, state.withProperty(BlockVegetation.META_PROPERTY, VegType.DoubleGrassTopLush), bp.up(), 2); } else if(closest.hasMarker(Marker.Clearing) && iMoisture.isGreaterThanOrEqual(Moisture.MEDIUM) && tall) { Core.setBlock(world, state.withProperty(BlockVegetation.META_PROPERTY, VegType.DoubleGrassBottom), bp, 2); Core.setBlock(world, state.withProperty(BlockVegetation.META_PROPERTY, VegType.DoubleGrassTop), bp.up(), 2); } else { Core.setBlock(world, state.withProperty(BlockVegetation.META_PROPERTY, vt), bp, 2); } } } } } } }
Example 7
Source File: WorldGenTreesHex.java From TFC2 with GNU General Public License v3.0 | 4 votes |
protected TreeReturn gen(Random random, World world, Center c, IslandMap m, String wood) { tsm = TreeRegistry.instance.managerFromString(wood); tc = TreeRegistry.instance.treeFromString(wood); if(tsm == null || tc.equals("")) { TFC.log.info("Can't locate :" + wood); return new TreeReturn(TreeReturnEnum.None, 0); } BlockPos genPos = centerPos.add(-20+random.nextInt(41), 0, -20+random.nextInt(41)); if(genPos.distanceSq(centerPos) > 400)//20*20 return new TreeReturn(TreeReturnEnum.None, 0); genPos = world.getTopSolidOrLiquidBlock(genPos); int growthStage = 0; if(m.getParams().getIslandMoisture().isGreaterThan(Moisture.LOW) && !m.getParams().hasFeature(Feature.Desert)) { if(c.getMoisture().isGreaterThan(Moisture.MEDIUM) && m.getParams().getIslandMoisture().isGreaterThan(Moisture.MEDIUM)) { growthStage = random.nextInt(3); } else if(c.getMoisture().isGreaterThan(Moisture.LOW)) { growthStage = random.nextInt(2); } } TreeReturnEnum grown = TreeReturnEnum.None; for(;growthStage >= 0 && grown == TreeReturnEnum.None; growthStage--) { schem = tsm.getRandomSchematic(random, growthStage); if( schem != null && canGrowHere(world, genPos.down(), schem, Math.max(growthStage, 1))) { if(buildTree(schem, tc, world, random, genPos, c)) { grown = TreeReturnEnum.fromSize(growthStage); } } } return new TreeReturn(grown, schem.getBaseCount()); }