public static void generateMushrooms(World worldIn, BlockPos blockpos, BlockPos origin, int radius, Random rand) { if (worldIn.getBlockState(blockpos.down()).isSideSolid(worldIn, blockpos.down(), EnumFacing.UP)) { worldIn.setBlockState(blockpos, rand.nextBoolean() ? Blocks.BROWN_MUSHROOM.getDefaultState() : Blocks.RED_MUSHROOM.getDefaultState()); } }
@Override public boolean generate(World worldIn, Random rand, BlockPos position) { BlockBush flower = ModBlocks.cloud_flower; for (int i = 0; i < 64; ++i) { BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8)); if (worldIn.isAirBlock(blockpos) && (!worldIn.provider.isNether() || blockpos.getY() < 255) && flower.canBlockStay(worldIn, blockpos, flower.getDefaultState())) { worldIn.setBlockState(blockpos, flower.getDefaultState(), 2); } } return true; } }
@Override public void fillFloor(World world, BlockPos pos, IBlockState state) { if(UndergroundBiomes.glowceliumEnabled) { world.setBlockState(pos, UndergroundBiomes.glowcelium.getDefaultState()); if(mushroomChance > 0 && world.rand.nextInt(mushroomChance) == 0) world.setBlockState(pos.up(), UndergroundBiomes.glowshroom.getDefaultState()); } else { super.fillFloor(world, pos, state); if(mushroomChance > 0 && world.rand.nextInt(mushroomChance) == 0) world.setBlockState(pos.up(), (world.rand.nextBoolean() ? Blocks.BROWN_MUSHROOM : Blocks.RED_MUSHROOM).getDefaultState()); } }
@Override public boolean generate(World worldIn, Random rand, BlockPos position) { for (IBlockState iblockstate = worldIn.getBlockState(position); (iblockstate.getBlock().isAir(iblockstate, worldIn, position) || iblockstate.getBlock().isLeaves(iblockstate, worldIn, position)) && position.getY() > 0; iblockstate = worldIn.getBlockState(position)) { position = position.down(); } for (int i = 0; i < 128; ++i) { BlockPos blockPos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8)); if (worldIn.isAirBlock(blockPos) && grassBlock.canBlockStay(worldIn, blockPos, grassBlock.getDefaultState())) { worldIn.setBlockState(blockPos, grassBlock.getDefaultState(), 2); } } return true; } }
@Override public void onLivingUpdate() { if (getEntityWorld().isRemote) Erebus.PROXY.spawnCustomParticle("spores", getEntityWorld(), posX + (rand.nextDouble() - 0.5D) * width, posY + rand.nextDouble() * height - 0.25D, posZ + (rand.nextDouble() - 0.5D) * width, 1.0D + rand.nextDouble(), 1.0D + rand.nextDouble(), 1.0D + rand.nextDouble()); if (!getEntityWorld().isRemote) { if (rand.nextInt(200) == 0) { if (getEntityWorld().isAirBlock(getPosition()) && getEntityWorld().getBiome(getPosition()) == ModBiomes.FUNGAL_FOREST && Blocks.BROWN_MUSHROOM.canPlaceBlockAt(getEntityWorld(), getPosition())) { int mush = rand.nextInt(3); if (mush == 0) getEntityWorld().setBlockState(getPosition(), Blocks.BROWN_MUSHROOM.getDefaultState()); if (mush == 1) getEntityWorld().setBlockState(getPosition(), Blocks.RED_MUSHROOM.getDefaultState()); else getEntityWorld().setBlockState(getPosition(), BiomeDecoratorFungalForest.MUSHROOMS[rand.nextInt(BiomeDecoratorFungalForest.MUSHROOMS.length)].getDefaultState(), 3); } } } super.onLivingUpdate(); }
blockPlant = (world.rand.nextBoolean() ? Blocks.RED_MUSHROOM : Blocks.BROWN_MUSHROOM); statePlant = blockPlant.getDefaultState();
@SubscribeEvent public void onItemExpireEvent(ItemExpireEvent event) { if (saplingDespawnGrow) { EntityItem entityItem = event.getEntityItem(); BlockPos pos = entityItem.getPosition(); Entity entity = event.getEntity(); ItemStack is = entityItem.getItem(); World world = entity.getEntityWorld(); if (is.isEmpty()) { return; } // plant the sapling, replacing the air and on top of dirt/plantable if (Block.getBlockFromItem(is.getItem()) == Blocks.RED_MUSHROOM) world.setBlockState(entityItem.getPosition(), Blocks.RED_MUSHROOM.getDefaultState()); else if (Block.getBlockFromItem(is.getItem()) == Blocks.BROWN_MUSHROOM) world.setBlockState(entityItem.getPosition(), Blocks.BROWN_MUSHROOM.getDefaultState()); else if (UtilOreDictionary.doesMatchOreDict(is, "treeSapling")) { Block saplingBlock = Block.getBlockFromItem(is.getItem()); if (saplingBlock != Blocks.AIR && saplingBlock.canPlaceBlockAt(world, pos)) { world.setBlockState(pos, UtilItemStack.getStateFromMeta(Block.getBlockFromItem(is.getItem()), is.getItemDamage())); } } } }
flowerRegistry.registerPlantableFlower(Blocks.BROWN_MUSHROOM.getDefaultState(), 1.0, FlowerManager.FlowerTypeMushrooms); flowerRegistry.registerPlantableFlower(Blocks.RED_MUSHROOM.getDefaultState(), 1.0, FlowerManager.FlowerTypeMushrooms); flowerRegistry.registerPlantableFlower(Blocks.CACTUS.getDefaultState(), 1.0, FlowerManager.FlowerTypeCacti);