public static void createSkyblock(World world, BlockPos pos) { for(int i = 0; i < 3; i++) for(int j = 0; j < 4; j++) for(int k = 0; k < 3; k++) world.setBlockState(pos.add(-1 + i, -1 - j, -1 + k), j == 0 ? Blocks.GRASS.getDefaultState() : Blocks.DIRT.getDefaultState()); world.setBlockState(pos.add(-1, -2, 0), Blocks.FLOWING_WATER.getDefaultState()); world.setBlockState(pos.add(1, 2, 1), ModBlocks.manaFlame.getDefaultState()); ((TileManaFlame) world.getTileEntity(pos.add(1, 2, 1))).setColor(new Color(70 + world.rand.nextInt(185), 70 + world.rand.nextInt(185), 70 + world.rand.nextInt(185)).getRGB()); int[][] rootPositions = new int[][] { { -1, -3, -1 }, { -2, -4, -1 }, { -2, -4, -2 }, { +1, -4, -1 }, { +1, -5, -1 }, { +2, -5, -1 }, { +2, -6, +0 }, { +0, -4, +2 }, { +0, -5, +2 }, { +0, -5, +3 }, { +0, -6, +3 }, }; for(int[] root : rootPositions) world.setBlockState(pos.add(root[0], root[1], root[2]), ModBlocks.root.getDefaultState()); world.setBlockState(pos.down(4), Blocks.BEDROCK.getDefaultState()); }
@Override public void grow(@Nonnull World worldIn, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull IBlockState state) { Blocks.GRASS.grow(worldIn, rand, pos, state); } }
@Override public boolean canGrow(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state, boolean isClient) { return Blocks.GRASS.canGrow(worldIn, pos, state, isClient); }
@Override public boolean canUseBonemeal(@Nonnull World worldIn, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull IBlockState state) { return Blocks.GRASS.canUseBonemeal(worldIn, rand, pos, state); }
public UndergroundBiomeLush() { super(Blocks.GRASS.getDefaultState(), null, null); }
Blocks.GRASS.grow(world, rand, pos, world.getBlockState(pos));
@Override public Surface createSurfaceGenerator(EarthCoverContext context) { return new Surface(context, this, Blocks.GRASS.getDefaultState(), true); }
private static BlockSwapper swapperFromMeta(World world, BlockPos pos, int meta) { switch(meta) { case 1 : return new BlockSwapper(world, pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL)); case 2 : return new BlockSwapper(world, pos, Blocks.MYCELIUM.getDefaultState()); case 3 : return new BlockSwapper(world, pos, ModBlocks.altGrass.getDefaultState().withProperty(BotaniaStateProps.ALTGRASS_VARIANT, AltGrassVariant.DRY)); case 4 : return new BlockSwapper(world, pos, ModBlocks.altGrass.getDefaultState().withProperty(BotaniaStateProps.ALTGRASS_VARIANT, AltGrassVariant.GOLDEN)); case 5 : return new BlockSwapper(world, pos, ModBlocks.altGrass.getDefaultState().withProperty(BotaniaStateProps.ALTGRASS_VARIANT, AltGrassVariant.VIVID)); case 6 : return new BlockSwapper(world, pos, ModBlocks.altGrass.getDefaultState().withProperty(BotaniaStateProps.ALTGRASS_VARIANT, AltGrassVariant.SCORCHED)); case 7 : return new BlockSwapper(world, pos, ModBlocks.altGrass.getDefaultState().withProperty(BotaniaStateProps.ALTGRASS_VARIANT, AltGrassVariant.INFUSED)); case 8 : return new BlockSwapper(world, pos, ModBlocks.altGrass.getDefaultState().withProperty(BotaniaStateProps.ALTGRASS_VARIANT, AltGrassVariant.MUTATED)); default : return new BlockSwapper(world, pos, Blocks.GRASS.getDefaultState()); } }
@Override public boolean generate(World world, Random rand, BlockPos pos) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); for (int attempt = 0; attempt < 64; ++attempt) { int xx = x + rand.nextInt(8) - rand.nextInt(8); int yy = y + rand.nextInt(4) - rand.nextInt(4); int zz = z + rand.nextInt(8) - rand.nextInt(8); BlockPos posTurnip = new BlockPos(xx, yy, zz); if (world.isAirBlock(posTurnip) && world.getBlockState(posTurnip.down()) == Blocks.GRASS.getDefaultState()) world.setBlockState(posTurnip, ModBlocks.CROP_TURNIP.getDefaultState().withProperty(BlockTurnip.AGE, Integer.valueOf(7))); } return true; } }
@Override public boolean generate(World world, Random rand, BlockPos pos) { boolean canSpawn = rand.nextBoolean() && rand.nextBoolean(); int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); if (!canSpawn) for (int waterAttempt = 0; waterAttempt < 30; waterAttempt++) if (world.getBlockState(new BlockPos(x + rand.nextInt(8) - rand.nextInt(8), y + rand.nextInt(4) - rand.nextInt(4), z + rand.nextInt(8) - rand.nextInt(8))).getMaterial() == Material.WATER) { canSpawn = true; break; } if (!canSpawn) return false; for (int attempt = 0, xx, yy, zz; attempt < 64; ++attempt) { xx = x + rand.nextInt(8) - rand.nextInt(8); yy = y + rand.nextInt(4) - rand.nextInt(4); zz = z + rand.nextInt(8) - rand.nextInt(8); BlockPos posMelon = new BlockPos(xx, yy, zz); if (world.isAirBlock(posMelon) && world.getBlockState(posMelon.down()) == Blocks.GRASS.getDefaultState() && Blocks.MELON_BLOCK.canPlaceBlockAt(world, posMelon)) world.setBlockState(posMelon, Blocks.MELON_BLOCK.getDefaultState(), 3); } return true; }
@Override public boolean generate(World world, Random rand, BlockPos pos) { boolean plausible = false; int y = pos.getY(); for (int a = 0; a < 10; a++) { if (world.isAirBlock(pos) && world.getBlockState(pos.down()) == Blocks.GRASS.getDefaultState()) { plausible = true; break; } if (--y <= 1) return false; } if (!plausible) return false; float rad = rand.nextFloat() + 2.6F; int ceilRad = 1 + (int) Math.ceil(rad); for (int xx = -ceilRad; xx <= ceilRad; xx++) for (int yy = -ceilRad; yy <= ceilRad; yy++) for (int zz = -ceilRad; zz <= ceilRad; zz++) if (Math.sqrt(xx * xx + yy * yy + zz * zz) <= rad + rand.nextFloat() * 0.4F) setAmberBlock(world, pos.add(xx, yy, zz), rand); return true; }
for (int xx = pos.getX() - 3; xx <= pos.getX() + 3; xx++) for (int zz = pos.getZ() - 3; zz <= pos.getZ() + 3; zz++) if (world.getBlockState(new BlockPos(xx, pos.getY(), zz)) != Blocks.GRASS.getDefaultState()) { return false;
@Override public boolean generate(World world, Random rand, BlockPos pos) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); float ang, len; for (int attempt = 0, placed = 0, xx, yy, zz; attempt < 10 && placed < 5; ++attempt) { ang = (float) (rand.nextDouble() * Math.PI * 2D); len = rand.nextFloat() * (0.3F + rand.nextFloat() * 0.7F) * 7F; xx = (int) (x + 0.5F + MathHelper.cos(ang) * len); yy = y + rand.nextInt(3) - rand.nextInt(3); zz = (int) (z + 0.5F + MathHelper.sin(ang) * len); BlockPos posNew = new BlockPos(xx, yy, zz); if (world.isAirBlock(posNew) && world.getBlockState(posNew.down()) == Blocks.GRASS.getDefaultState()) { world.setBlockState(posNew, ModBlocks.SMALL_PLANT.getDefaultState().withProperty(BlockSmallPlant.PLANT_TYPE, rand.nextBoolean() ? BlockSmallPlant.EnumSmallPlantType.NETTLE : BlockSmallPlant.EnumSmallPlantType.NETTLE_FLOWERED), 2); ++placed; } } return true; } }
@Override public boolean generate(World world, Random rand, BlockPos pos) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); float ang, len; for (int attempt = 0, placed = 0, xx, yy, zz; attempt < 10 && placed < 5; ++attempt) { ang = (float) (rand.nextDouble() * Math.PI * 2D); len = rand.nextFloat() * (0.3F + rand.nextFloat() * 0.7F) * 7F; xx = (int) (x + 0.5F + MathHelper.cos(ang) * len); yy = y + rand.nextInt(3) - rand.nextInt(3); zz = (int) (z + 0.5F + MathHelper.sin(ang) * len); BlockPos posNew = new BlockPos(xx, yy, zz); if (world.isAirBlock(posNew.up()) && world.getBlockState(posNew) == Blocks.GRASS.getDefaultState()) { world.setBlockState(posNew, ModBlocks.SWAMP_VENT.getDefaultState(), 2); ++placed; } } return true; } }
if (y == (minY - bottomOffset) + 1 && world.getBlockState(min).getBlock() == Blocks.DIRT) { world.setBlockState(min, Blocks.GRASS.getDefaultState());
@Override public void updateTick(World world, BlockPos blockPos, IBlockState blockState, Random random) { if(random.nextInt(CHANCE_DESPAWN) == 0) { if(random.nextInt(CHANCE_BONEMEAL) == 0) { for(int xr = - 2; xr <= 2; xr++) { for(int zr = - 2; zr <= 2; zr++) { if(random.nextInt(9) == 0) { IBlockState blockBelow = world.getBlockState(blockPos.add(xr, -1, zr)); if(blockBelow.getBlock() == Blocks.DIRT) { world.setBlockState(blockPos.add(xr, -1, zr), Blocks.GRASS.getDefaultState()); } else if(blockBelow == Blocks.GRASS) { ItemDye.applyBonemeal(new ItemStack(Items.DYE, 1), world, blockPos.add(xr, -1, zr)); } ItemDye.applyBonemeal(new ItemStack(Items.DYE, 1), world, blockPos.add(xr, -1, zr)); } } } } world.setBlockToAir(blockPos); } }
@Override public boolean generate(World world, Random rand, BlockPos pos) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); float ang, len; int randomBush = rand.nextInt(2); for (int attempt = 0, placed = 0, xx, yy, zz; attempt < 10 && placed < 5; ++attempt) { ang = (float) (rand.nextDouble() * Math.PI * 2D); len = rand.nextFloat() * (0.3F + rand.nextFloat() * 0.7F) * 7F; xx = (int) (x + 0.5F + MathHelper.cos(ang) * len); yy = y + rand.nextInt(3) - rand.nextInt(3); zz = (int) (z + 0.5F + MathHelper.sin(ang) * len); BlockPos posBush = new BlockPos(xx, yy, zz); if (world.isAirBlock(posBush) && world.getBlockState(posBush.down()) == ModBlocks.UMBERSTONE.getDefaultState()) { world.setBlockState(posBush.down(), Blocks.DIRT.getDefaultState(), 2); world.setBlockState(posBush, bushType[2], 2); ++placed; } else if (world.isAirBlock(posBush) && world.getBlockState(posBush.down()) == Blocks.GRASS.getDefaultState()) { world.setBlockState(posBush, bushType[randomBush], 2); ++placed; } } return true; } }
public boolean matchBlock(IBlockState block) { switch (this) { case GRASS: return block == Blocks.GRASS.getDefaultState() || block == Blocks.MYCELIUM.getDefaultState(); case DIRT: return block == Blocks.DIRT.getDefaultState(); case SAND: return block == Blocks.SAND.getDefaultState() || block == Blocks.SAND.getDefaultState().withProperty(BlockSand.VARIANT, BlockSand.EnumType.RED_SAND); case MIXED: return block == Blocks.GRASS.getDefaultState() || block == Blocks.DIRT.getDefaultState() || block == Blocks.SAND.getDefaultState() || block == Blocks.SAND.getDefaultState().withProperty(BlockSand.VARIANT, BlockSand.EnumType.RED_SAND); case UMBERSTONE: return block == ModBlocks.UMBERSTONE.getDefaultState(); case VOLCANIC_ROCK: return block == ModBlocks.VOLCANIC_ROCK.getDefaultState(); case DUST: return block == ModBlocks.DUST.getDefaultState(); default: return false; } } }
@Override @SuppressWarnings("deprecation, unchecked") @Nonnull public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess world, BlockPos pos) { CropType stage = getEnumFromState(state); TileWithered crop = CropHelper.getTile(world, pos, stage.getSection()); if (stage.getSection() == PlantSection.TOP && crop == null) { IBlockState theState = CropHelper.getTempState(pos); return theState == null ? Blocks.GRASS.getDefaultState(): theState; } if (crop != null) return crop.getData().getCrop().getStateHandler().getState(world, pos, stage.getSection(), crop.getData().getCrop(), crop.getData().getStage(), stage.isWithered()); else return Blocks.DEADBUSH.getDefaultState(); }
if (world.isAirBlock(new BlockPos(xx, yy, zz)) && world.getBlockState(new BlockPos(xx, yy - 1, zz)) == Blocks.GRASS.getDefaultState()) { world.setBlockState(new BlockPos(xx, yy, zz), EnumWood.BAMBOO.getLog().getDefaultState());