From ba09219fed3f6ea74797297a2148ee0f91c81a1d Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 17 Jun 2023 22:47:39 +0200 Subject: [PATCH] [Change] Removed old Bonemeal API --- .../org/betterx/bclib/api/v2/BonemealAPI.java | 220 ------------------ 1 file changed, 220 deletions(-) delete mode 100644 src/main/java/org/betterx/bclib/api/v2/BonemealAPI.java diff --git a/src/main/java/org/betterx/bclib/api/v2/BonemealAPI.java b/src/main/java/org/betterx/bclib/api/v2/BonemealAPI.java deleted file mode 100644 index e8470752..00000000 --- a/src/main/java/org/betterx/bclib/api/v2/BonemealAPI.java +++ /dev/null @@ -1,220 +0,0 @@ -package org.betterx.bclib.api.v2; - -import org.betterx.bclib.util.BlocksHelper; -import org.betterx.bclib.util.WeightedList; - -import net.minecraft.core.BlockPos; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.RandomSource; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; - -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -import java.util.Map; -import java.util.Set; -import java.util.function.BiConsumer; - -public class BonemealAPI { - private static final Map>>> WATER_GRASS_BIOMES = Maps.newHashMap(); - private static final Map>>> LAND_GRASS_BIOMES = Maps.newHashMap(); - private static final Map>> WATER_GRASS_TYPES = Maps.newHashMap(); - private static final Map>> LAND_GRASS_TYPES = Maps.newHashMap(); - private static final Map SPREADABLE_BLOCKS = Maps.newHashMap(); - private static final Set TERRAIN_TO_SPREAD = Sets.newHashSet(); - private static final Set TERRAIN = Sets.newHashSet(); - - @Deprecated(forRemoval = true) - public static void addSpreadableBlock(Block spreadableBlock, Block surfaceForSpread) { - SPREADABLE_BLOCKS.put(spreadableBlock, surfaceForSpread); - TERRAIN_TO_SPREAD.add(surfaceForSpread); - TERRAIN.add(surfaceForSpread); - } - - public static boolean isTerrain(Block block) { - return TERRAIN.contains(block); - } - - @Deprecated(forRemoval = true) - public static boolean isSpreadableTerrain(Block block) { - return TERRAIN_TO_SPREAD.contains(block); - } - - @Deprecated(forRemoval = true) - public static Block getSpreadable(Block block) { - return SPREADABLE_BLOCKS.get(block); - } - - @Deprecated(forRemoval = true) - public static void addLandGrass(Block plant, Block... terrain) { - addLandGrass(makeConsumer(plant), terrain); - } - - @Deprecated(forRemoval = true) - public static void addLandGrass(BiConsumer plant, Block... terrain) { - for (Block block : terrain) { - addLandGrass(plant, block, 1F); - } - } - - /** - * This API is deprecated, please use the new {@link org.betterx.bclib.api.v3.bonemeal.BonemealAPI}. - * - * @param biome - * @param plant - * @param terrain - */ - @Deprecated(forRemoval = true) - public static void addLandGrass(ResourceLocation biome, Block plant, Block... terrain) { - addLandGrass(biome, makeConsumer(plant), terrain); - } - - @Deprecated(forRemoval = true) - public static void addLandGrass(ResourceLocation biome, BiConsumer plant, Block... terrain) { - for (Block block : terrain) { - addLandGrass(biome, plant, block, 1F); - } - } - - @Deprecated(forRemoval = true) - public static void addLandGrass(Block plant, Block terrain, float chance) { - addLandGrass(makeConsumer(plant), terrain, chance); - } - - @Deprecated(forRemoval = true) - public static void addLandGrass(BiConsumer plant, Block terrain, float chance) { - WeightedList> list = LAND_GRASS_TYPES.get(terrain); - if (list == null) { - list = new WeightedList<>(); - LAND_GRASS_TYPES.put(terrain, list); - } - TERRAIN.add(terrain); - list.add(plant, chance); - } - - @Deprecated(forRemoval = true) - public static void addLandGrass(ResourceLocation biome, Block plant, Block terrain, float chance) { - addLandGrass(biome, makeConsumer(plant), terrain, chance); - } - - @Deprecated(forRemoval = true) - public static void addLandGrass( - ResourceLocation biome, - BiConsumer plant, - Block terrain, - float chance - ) { - Map>> map = LAND_GRASS_BIOMES.get(biome); - if (map == null) { - map = Maps.newHashMap(); - LAND_GRASS_BIOMES.put(biome, map); - } - WeightedList> list = map.get(terrain); - if (list == null) { - list = new WeightedList<>(); - map.put(terrain, list); - } - TERRAIN.add(terrain); - list.add(plant, chance); - } - - public static void addWaterGrass(Block plant, Block... terrain) { - addWaterGrass(makeConsumer(plant), terrain); - } - - public static void addWaterGrass(BiConsumer plant, Block... terrain) { - for (Block block : terrain) { - addWaterGrass(plant, block, 1F); - } - } - - public static void addWaterGrass(ResourceLocation biome, Block plant, Block... terrain) { - addWaterGrass(biome, makeConsumer(plant), terrain); - } - - public static void addWaterGrass(ResourceLocation biome, BiConsumer plant, Block... terrain) { - for (Block block : terrain) { - addWaterGrass(biome, plant, block, 1F); - } - } - - public static void addWaterGrass(Block plant, Block terrain, float chance) { - addWaterGrass(makeConsumer(plant), terrain, chance); - } - - public static void addWaterGrass(BiConsumer plant, Block terrain, float chance) { - WeightedList> list = WATER_GRASS_TYPES.get(terrain); - if (list == null) { - list = new WeightedList<>(); - WATER_GRASS_TYPES.put(terrain, list); - } - TERRAIN.add(terrain); - list.add(plant, chance); - } - - public static void addWaterGrass(ResourceLocation biome, Block plant, Block terrain, float chance) { - addWaterGrass(biome, makeConsumer(plant), terrain, chance); - } - - public static void addWaterGrass( - ResourceLocation biome, - BiConsumer plant, - Block terrain, - float chance - ) { - Map>> map = WATER_GRASS_BIOMES.get(biome); - if (map == null) { - map = Maps.newHashMap(); - WATER_GRASS_BIOMES.put(biome, map); - } - WeightedList> list = map.get(terrain); - if (list == null) { - list = new WeightedList<>(); - map.put(terrain, list); - } - TERRAIN.add(terrain); - list.add(plant, chance); - } - - @Deprecated(forRemoval = true) - public static BiConsumer getLandGrass( - ResourceLocation biomeID, - Block terrain, - RandomSource random - ) { - Map>> map = LAND_GRASS_BIOMES.get(biomeID); - WeightedList> list; - if (map != null) { - list = map.get(terrain); - if (list == null) { - list = LAND_GRASS_TYPES.get(terrain); - } - } else { - list = LAND_GRASS_TYPES.get(terrain); - } - return list == null ? null : list.get(random); - } - - public static BiConsumer getWaterGrass( - ResourceLocation biomeID, - Block terrain, - RandomSource random - ) { - Map>> map = WATER_GRASS_BIOMES.get(biomeID); - WeightedList> list; - if (map != null) { - list = map.get(terrain); - if (list == null) { - list = WATER_GRASS_TYPES.get(terrain); - } - } else { - list = WATER_GRASS_TYPES.get(terrain); - } - return list == null ? null : list.get(random); - } - - private static BiConsumer makeConsumer(Block block) { - return (level, pos) -> BlocksHelper.setWithoutUpdate(level, pos, block); - } -}