@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { for (int i = 0; i < 25; i++) { int x = chunkX * 16 + random.nextInt(16); int z = chunkZ * 16 + random.nextInt(16); BlockPos pos = world.getHeight(new BlockPos(x, 0, z)); if (world.getBlockState(pos).getBlock() instanceof BlockTallGrass) { world.setBlockState(pos, ARKCraftBlocks.berryBush.getDefaultState()); } } }
void placeGrass(World world, BlockPos pos, Random random, int fertility) { Block block = world.getBlockState(pos.down()).getBlock(); if (block instanceof BlockGrass && block.canPlaceBlockAt(world, pos)) { if (fertility < 50 && random.nextInt(15) == 0) { world.setBlockState(pos, Blocks.tallgrass.getDefaultState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.DEAD_BUSH), 2); return; } if (fertility > 200 && random.nextInt(3) == 0) { if (random.nextInt(20) == 0) { if (random.nextBoolean()) { world.setBlockState(pos, Blocks.brown_mushroom.getDefaultState()); } else { world.setBlockState(pos, Blocks.red_mushroom.getDefaultState()); } return; } world.setBlockState(pos, Blocks.tallgrass.getDefaultState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.FERN), 2); return; } world.setBlockState(pos, Blocks.tallgrass.getDefaultState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.GRASS), 2); } }
private static void addWinnowingRecipes() { IWinnowingMachineHandler winnowing = CulinaryCultivationAPI.winnowing; ItemStack tallGrass = new ItemStack(Blocks.TALLGRASS, 1, BlockTallGrass.EnumType.GRASS.getMeta()); ItemStack doubleTallGrass = new ItemStack(Blocks.DOUBLE_PLANT, 1, BlockDoublePlant.EnumPlantType.GRASS.getMeta()); //Culinary Cultivation outputs winnowing.addOutput(tallGrass, new ItemStack(CROP_SEEDS, 1, ProductType.CUCUMBER.getMetadata()), 10); winnowing.addOutput(tallGrass, new ItemStack(CROP_SEEDS, 1, ProductType.TOMATO.getMetadata()), 8); winnowing.addJunk(tallGrass, new ItemStack(GENERAL, 1, ItemGeneral.Type.CHAFF_PILE.getMetadata()), 10); winnowing.addRecipe(doubleTallGrass, new ItemStack(CROP_SEEDS, 1, ProductType.BLACK_PEPPER_DRUPE.getMetadata()), 18); winnowing.addRecipe(doubleTallGrass, new ItemStack(CROP_SEEDS, 1, ProductType.CORN.getMetadata()), 8); //Vanilla outputs winnowing.addOutput(tallGrass, new ItemStack(Items.WHEAT_SEEDS), 10); winnowing.addOutput(tallGrass, new ItemStack(Items.BEETROOT_SEEDS), 2); winnowing.addOutput(tallGrass, new ItemStack(Items.PUMPKIN_SEEDS), 1); winnowing.addRecipe(new ItemStack(Blocks.SAPLING, 1, BlockPlanks.EnumType.JUNGLE.getMetadata()), new ItemStack(Items.MELON_SEEDS), 1, new ItemStack(Blocks.DEADBUSH), 10); winnowing.addRecipe(new ItemStack(Items.WHEAT), new ItemStack(Items.WHEAT_SEEDS), 15, new ItemStack(GENERAL, 1, ItemGeneral.Type.CHAFF_PILE.getMetadata()), 90); }
@Override public void notifyBlockUpdate(World worldIn, BlockPos pos, IBlockState oldState, IBlockState currentState, int flags) { if (currentState.getBlock() == Blocks.FIRE && !(worldIn.getBlockState(pos.down()).getBlock() instanceof BlockObsidian) && !(worldIn.getBlockState(pos.down()).getBlock() instanceof BlockBush) && !(worldIn.getBlockState(pos.down()).getBlock() instanceof BlockTallGrass)) { IBlockState newStateBlock = BlockRegistry.specialfire.getDefaultState().withProperty(BlockSpecialFire.AGE, currentState.getValue(BlockFire.AGE)).withProperty(BlockSpecialFire.NORTH, currentState.getValue(BlockFire.NORTH)).withProperty(BlockSpecialFire.EAST, currentState.getValue(BlockFire.EAST)).withProperty(BlockSpecialFire.SOUTH, currentState.getValue(BlockFire.SOUTH)).withProperty(BlockSpecialFire.WEST, currentState.getValue(BlockFire.WEST)).withProperty(BlockSpecialFire.UPPER, currentState.getValue(BlockFire.UPPER)); worldIn.setBlockState(pos, newStateBlock, flags); } }
@Override public WorldGenerator getRandomWorldGenForGrass(Random random) { return random.nextInt(4) == 0 ? new WorldGenTallGrass(BlockTallGrass.EnumType.FERN) : new WorldGenTallGrass(BlockTallGrass.EnumType.GRASS); }
private static void registerVanillaVariantProps() { // TODO: omit similar blocks registerVariantProperty(BlockStone.VARIANT); registerVariantProperty(BlockPlanks.VARIANT); registerVariantProperty(BlockSapling.TYPE); registerVariantProperty(BlockDirt.VARIANT); registerVariantProperty(BlockSand.VARIANT); registerVariantProperty(BlockOldLog.VARIANT); registerVariantProperty(BlockNewLog.VARIANT); registerVariantProperty(BlockOldLeaf.VARIANT); registerVariantProperty(BlockNewLeaf.VARIANT); registerVariantProperty(BlockSandStone.TYPE); registerVariantProperty(BlockTallGrass.TYPE); registerVariantProperty(BlockPistonExtension.TYPE); registerVariantProperty(BlockColored.COLOR); registerVariantProperty(BlockPistonMoving.TYPE); registerVariantProperty(Blocks.YELLOW_FLOWER.getTypeProperty()); registerVariantProperty(Blocks.RED_FLOWER.getTypeProperty()); registerVariantProperty(BlockStoneSlab.VARIANT); registerVariantProperty(BlockWoodSlab.VARIANT); registerVariantProperty(BlockAnvil.DAMAGE); registerVariantProperty(BlockQuartz.VARIANT); registerVariantProperty(BlockCarpet.COLOR); registerVariantProperty(BlockDoublePlant.VARIANT); registerVariantProperty(BlockStainedGlass.COLOR); registerVariantProperty(BlockStainedGlassPane.COLOR); registerVariantProperty(BlockPrismarine.VARIANT); registerVariantProperty(BlockRedSandstone.TYPE); registerVariantProperty(BlockStoneSlabNew.VARIANT); }
@SubscribeEvent(priority = EventPriority.HIGHEST) public void interceptGrassDrop(BlockEvent.HarvestDropsEvent event) { // Skip silk touch. if (event.isSilkTouching()) { return; } // Fetch the blockstate. final IBlockState state = event.getState(); // Skip Air or Error if (state == null || state.getBlock() == null) { return; } // Fetch the world random. final Random rand = event.getWorld().rand; // Log // This line was oddly ignoring the debug settings... //AgriCore.getLogger("agricraft").debug("Intercepted! Block: {0}", state.getBlock()); // Add grass drops if grass block. if (state.getBlock() instanceof BlockTallGrass) { // Wipe other drops, if needed. if (AgriCraftConfig.wipeGrassDrops) { event.getDrops().clear(); } // Log // Commenented out to prevent spam. //AgriCore.getLogger("agricraft").debug("Inserting Drops!"); // Add the drops. addGrassDrops(event.getDrops(), rand); } }
/** * Gets a WorldGen appropriate for this biome. */ public WorldGenerator getRandomWorldGenForGrass(Random rand) { return rand.nextInt(4) == 0 ? new WorldGenTallGrass(BlockTallGrass.EnumType.FERN) : new WorldGenTallGrass(BlockTallGrass.EnumType.GRASS); }
/** * Gets a WorldGen appropriate for this biome. */ public WorldGenerator getRandomWorldGenForGrass(Random rand) { return rand.nextInt(5) > 0 ? new WorldGenTallGrass(BlockTallGrass.EnumType.FERN) : new WorldGenTallGrass(BlockTallGrass.EnumType.GRASS); }
/** * Gets a WorldGen appropriate for this biome. */ public WorldGenerator getRandomWorldGenForGrass(Random rand) { return new WorldGenTallGrass(BlockTallGrass.EnumType.GRASS); }
public WorldGenTallGrass(BlockTallGrass.EnumType p_i45629_1_) { this.tallGrassState = Blocks.tallgrass.getDefaultState().withProperty(BlockTallGrass.TYPE, p_i45629_1_); }
private static boolean checkBlock(Block p_checkBlock_0_, IBlockState p_checkBlock_1_) { if (p_checkBlock_0_.isFullCube()) { return false; } else if (p_checkBlock_0_.isOpaqueCube()) { return false; } else if (p_checkBlock_0_ instanceof BlockSnow) { return false; } else if (!(p_checkBlock_0_ instanceof BlockBush) || !(p_checkBlock_0_ instanceof BlockDoublePlant) && !(p_checkBlock_0_ instanceof BlockFlower) && !(p_checkBlock_0_ instanceof BlockMushroom) && !(p_checkBlock_0_ instanceof BlockSapling) && !(p_checkBlock_0_ instanceof BlockTallGrass)) { if (!(p_checkBlock_0_ instanceof BlockFence) && !(p_checkBlock_0_ instanceof BlockFenceGate) && !(p_checkBlock_0_ instanceof BlockFlowerPot) && !(p_checkBlock_0_ instanceof BlockPane) && !(p_checkBlock_0_ instanceof BlockReed) && !(p_checkBlock_0_ instanceof BlockWall)) { if (p_checkBlock_0_ instanceof BlockRedstoneTorch && p_checkBlock_1_.getValue(BlockTorch.FACING) == EnumFacing.UP) { return true; } else { if (p_checkBlock_0_ instanceof BlockLever) { Object object = p_checkBlock_1_.getValue(BlockLever.FACING); if (object == BlockLever.EnumOrientation.UP_X || object == BlockLever.EnumOrientation.UP_Z) { return true; } } return false; } } else { return true; } } else { return true; } }
@Override public WorldGenerator getRandomWorldGenForGrass(Random rand) { return rand.nextInt(4) == 0 ? new WorldGenTallGrass(BlockTallGrass.EnumType.FERN) : super.getRandomWorldGenForGrass(rand); }
public WorldGenTallGrass(BlockTallGrass.EnumType p_i45629_1_) { this.tallGrassState = Blocks.TALLGRASS.getDefaultState().withProperty(BlockTallGrass.TYPE, p_i45629_1_); }
private static boolean checkBlock(Block p_checkBlock_0_, IBlockState p_checkBlock_1_) { if (p_checkBlock_1_.isFullCube()) { return false; } else if (p_checkBlock_1_.isOpaqueCube()) { return false; } else if (p_checkBlock_0_ instanceof BlockSnow) { return false; } else if (!(p_checkBlock_0_ instanceof BlockBush) || !(p_checkBlock_0_ instanceof BlockDoublePlant) && !(p_checkBlock_0_ instanceof BlockFlower) && !(p_checkBlock_0_ instanceof BlockMushroom) && !(p_checkBlock_0_ instanceof BlockSapling) && !(p_checkBlock_0_ instanceof BlockTallGrass)) { if (!(p_checkBlock_0_ instanceof BlockFence) && !(p_checkBlock_0_ instanceof BlockFenceGate) && !(p_checkBlock_0_ instanceof BlockFlowerPot) && !(p_checkBlock_0_ instanceof BlockPane) && !(p_checkBlock_0_ instanceof BlockReed) && !(p_checkBlock_0_ instanceof BlockWall)) { if (p_checkBlock_0_ instanceof BlockRedstoneTorch && p_checkBlock_1_.getValue(BlockTorch.FACING) == EnumFacing.UP) { return true; } else { if (p_checkBlock_0_ instanceof BlockLever) { Object object = p_checkBlock_1_.getValue(BlockLever.FACING); if (object == BlockLever.EnumOrientation.UP_X || object == BlockLever.EnumOrientation.UP_Z) { return true; } } return false; } } else { return true; } } else { return true; } }
@Override public boolean isAssociatedBlock(Block other) { return super.isAssociatedBlock(other) || other instanceof BlockTallGrass; }
public static void init() { IBlockState coarseDirt = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); MapMaterial.addMaterial("concrete", Blocks.STONEBRICK, Blocks.STONE_BRICK_STAIRS, Blocks.COBBLESTONE_WALL); MapMaterial.addMaterial("metal", Blocks.IRON_BLOCK, Blocks.QUARTZ_STAIRS, Blocks.IRON_BARS); MapMaterial.addMaterial("bars", Blocks.IRON_BARS, Blocks.IRON_BARS, Blocks.IRON_BARS); MapMaterial.addMaterial("railing", Blocks.IRON_BARS, Blocks.IRON_BARS, Blocks.IRON_BARS); MapMaterial.addMaterial("chain", Blocks.IRON_BARS, Blocks.IRON_BARS, Blocks.IRON_BARS); MapMaterial.addMaterial("wood", Blocks.PLANKS, Blocks.OAK_STAIRS, Blocks.OAK_FENCE); MapMaterial.addMaterial("asphalt", Blocks.COAL_BLOCK, Blocks.NETHER_BRICK_STAIRS, Blocks.NETHER_BRICK_FENCE); MapMaterial.addMaterial("glass", Blocks.GLASS, Blocks.GLASS, Blocks.GLASS_PANE); MapMaterial.addMaterial("grass", coarseDirt, coarseDirt, Blocks.TALLGRASS.getDefaultState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.GRASS)); MapMaterial.addMaterial("cobblestone", Blocks.COBBLESTONE, Blocks.STONE_STAIRS, Blocks.COBBLESTONE_WALL); MapMaterial.addMaterial("pebbles", Blocks.COBBLESTONE, Blocks.STONE_STAIRS, Blocks.COBBLESTONE_WALL); MapMaterial.addMaterial("pebblestone", Blocks.COBBLESTONE, Blocks.STONE_STAIRS, Blocks.COBBLESTONE_WALL); MapMaterial.addMaterial("cobblestone:flattened", Blocks.COBBLESTONE, Blocks.STONE_STAIRS, Blocks.COBBLESTONE_WALL); MapMaterial.addMaterial("paved", Blocks.DOUBLE_STONE_SLAB, Blocks.DOUBLE_STONE_SLAB, Blocks.DOUBLE_STONE_SLAB); MapMaterial.addMaterial("sidewalk", Blocks.DOUBLE_STONE_SLAB, Blocks.DOUBLE_STONE_SLAB, Blocks.DOUBLE_STONE_SLAB); MapMaterial.addMaterial("brick", Blocks.BRICK_BLOCK, Blocks.NETHER_BRICK_STAIRS, Blocks.NETHER_BRICK_FENCE); MapMaterial.addMaterial("bricks", Blocks.BRICK_BLOCK, Blocks.NETHER_BRICK_STAIRS, Blocks.NETHER_BRICK_FENCE); MapMaterial.addMaterial("stone", Blocks.STONE, Blocks.STONE_BRICK_STAIRS, Blocks.COBBLESTONE_WALL); MapMaterial.addMaterial("gravel", Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL); MapMaterial.addMaterial("fine_gravel", Blocks.GRAVEL, Blocks.GRAVEL, Blocks.GRAVEL); MapMaterial.addMaterial("sand", Blocks.SAND, Blocks.SANDSTONE_STAIRS, Blocks.BIRCH_FENCE); MapMaterial.addMaterial("granite", Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.GRANITE), Blocks.STONE_STAIRS.getDefaultState(), Blocks.COBBLESTONE_WALL.getDefaultState()); MapMaterial.addMaterial("dirt", coarseDirt, coarseDirt, coarseDirt); MapMaterial.addMaterial("mud", coarseDirt, coarseDirt, coarseDirt); MapMaterial.addMaterial("earth", coarseDirt, coarseDirt, coarseDirt); MapMaterial.addMaterial("ground", coarseDirt, coarseDirt, coarseDirt); Block.REGISTRY.iterator().forEachRemaining(block -> { Material material = block.getDefaultState().getMaterial(); if (material == Material.ROCK || material == Material.IRON) { ResourceLocation identifier = Block.REGISTRY.getNameForObject(block); if (identifier.getResourceDomain().equals("minecraft")) { int colour = block.getDefaultState().getMapColor().colorValue; Set<Block> blocks = BLOCK_COLOURS.computeIfAbsent(colour, (key) -> new HashSet<>()); blocks.add(block); } } }); }
@SubscribeEvent public void onHarvestBlock(BlockEvent.HarvestDropsEvent ev) { if (ev.isSilkTouching()) return; if (ev.getState().getBlock() != Blocks.TALLGRASS || ev.getState().getValue(BlockTallGrass.TYPE) == DEAD_BUSH) return; List<ItemStack> drops = ev.getDrops(); if (drops instanceof ImmutableList) { Survivalist.logger.warn("WARNING: Some mod is returning an ImmutableList from HarvestBlocks, replacing drops will NOT be possible."); return; } try { if (rnd.nextFloat() < 0.12f) drops.add(new ItemStack(Survivalist.plant_fibres)); } catch (UnsupportedOperationException ex) { if (!(drops instanceof NonNullList)) throw ex; // Workaround for getDrops using a fixed-length NonNullList if (nonNullListDelegate == null) { nonNullListDelegate = ReflectionHelper.findField(drops.getClass(), "field_191198_a", "delegate"); } try { nonNullListDelegate.set(drops, Lists.newArrayList(drops)); drops.add(new ItemStack(Survivalist.plant_fibres)); } catch (IllegalAccessException e) { throw ex; } } }
public static boolean isPassthroughBlock(World world, int x, int y, int z) { if (y < 0 || y > 254) return false; int id = world.getBlockId(x, y, z); return Block.blocksList[id] == null || Block.blocksList[id].isAirBlock(world, x, y, z) || Block.blocksList[id] instanceof BlockFluid || Block.blocksList[id] instanceof BlockSnow || Block.blocksList[id] instanceof BlockTallGrass; }