Removed deprecated Methods/Classes
This commit is contained in:
parent
907785f2f5
commit
22ae922439
81 changed files with 61 additions and 6277 deletions
|
@ -1,77 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2;
|
|
||||||
|
|
||||||
import org.betterx.worlds.together.world.WorldConfig;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Implementation moved to {@link WorldConfig}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class WorldDataAPI {
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link WorldConfig#load(File)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void load(File dataDir) {
|
|
||||||
WorldConfig.load(dataDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link WorldConfig#registerModCache(String)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void registerModCache(String modID) {
|
|
||||||
WorldConfig.registerModCache(modID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link WorldConfig#getRootTag(String)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static CompoundTag getRootTag(String modID) {
|
|
||||||
return WorldConfig.getRootTag(modID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link WorldConfig#hasMod(String)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static boolean hasMod(String modID) {
|
|
||||||
return WorldConfig.hasMod(modID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link WorldConfig#getCompoundTag(String, String)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static CompoundTag getCompoundTag(String modID, String path) {
|
|
||||||
return WorldConfig.getCompoundTag(modID, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link WorldConfig#saveFile(String)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void saveFile(String modID) {
|
|
||||||
WorldConfig.saveFile(modID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link WorldConfig#getModVersion(String)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static String getModVersion(String modID) {
|
|
||||||
return WorldConfig.getModVersion(modID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link WorldConfig#getIntModVersion(String)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int getIntModVersion(String modID) {
|
|
||||||
return WorldConfig.getIntModVersion(modID);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.betterx.bclib.api.v2.generator;
|
package org.betterx.bclib.api.v2.generator;
|
||||||
|
|
||||||
import org.betterx.bclib.BCLib;
|
import org.betterx.bclib.BCLib;
|
||||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
||||||
import org.betterx.worlds.together.biomesource.BiomeSourceFromRegistry;
|
import org.betterx.worlds.together.biomesource.BiomeSourceFromRegistry;
|
||||||
import org.betterx.worlds.together.biomesource.BiomeSourceHelper;
|
import org.betterx.worlds.together.biomesource.BiomeSourceHelper;
|
||||||
|
@ -35,7 +34,6 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
||||||
.location()
|
.location()
|
||||||
.toString()))
|
.toString()))
|
||||||
.toList();
|
.toList();
|
||||||
biomes.forEach(biome -> BiomeAPI.sortBiomeFeatures(biome));
|
|
||||||
return biomes;
|
return biomes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,6 @@ package org.betterx.bclib.api.v2.generator;
|
||||||
|
|
||||||
import org.betterx.bclib.config.Configs;
|
import org.betterx.bclib.config.Configs;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class GeneratorOptions {
|
public class GeneratorOptions {
|
||||||
//private static BiFunction<Point, Integer, Boolean> endLandFunction;
|
//private static BiFunction<Point, Integer, Boolean> endLandFunction;
|
||||||
private static boolean fixEndBiomeSource = true;
|
private static boolean fixEndBiomeSource = true;
|
||||||
|
@ -16,85 +12,6 @@ public class GeneratorOptions {
|
||||||
fixNetherBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options.biomeSource", "fixNetherBiomeSource", true);
|
fixNetherBiomeSource = Configs.GENERATOR_CONFIG.getBoolean("options.biomeSource", "fixNetherBiomeSource", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int getBiomeSizeNether() {
|
|
||||||
return 256;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int getVerticalBiomeSizeNether() {
|
|
||||||
return 86;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int getBiomeSizeEndLand() {
|
|
||||||
return 256;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int getBiomeSizeEndVoid() {
|
|
||||||
return 256;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param endLandFunction
|
|
||||||
* @deprecated use {@link #setEndLandFunction(BiFunction)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void setEndLandFunction(Function<Point, Boolean> endLandFunction) {
|
|
||||||
//GeneratorOptions.endLandFunction = (p, h) -> endLandFunction.apply(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void setEndLandFunction(BiFunction<Point, Integer, Boolean> endLandFunction) {
|
|
||||||
///GeneratorOptions.endLandFunction = endLandFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BiFunction<Point, Integer, Boolean> getEndLandFunction() {
|
|
||||||
return (a, b) -> true;//endLandFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static long getFarEndBiomes() {
|
|
||||||
return 1000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set distance of far End biomes generation, in blocks
|
|
||||||
*
|
|
||||||
* @param distance
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void setFarEndBiomes(int distance) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set distance of far End biomes generation, in blocks^2
|
|
||||||
*
|
|
||||||
* @param distanceSqr the distance squared
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void setFarEndBiomesSqr(long distanceSqr) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static boolean customNetherBiomeSource() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static boolean customEndBiomeSource() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static boolean useVerticalBiomes() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean fixEndBiomeSource() {
|
public static boolean fixEndBiomeSource() {
|
||||||
return fixEndBiomeSource;
|
return fixEndBiomeSource;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
|
||||||
import org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig;
|
import org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig;
|
||||||
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
||||||
import org.betterx.bclib.api.v2.poi.PoiManager;
|
import org.betterx.bclib.api.v2.poi.PoiManager;
|
||||||
import org.betterx.bclib.api.v2.tag.TagAPI;
|
|
||||||
import org.betterx.bclib.registry.PresetsRegistry;
|
import org.betterx.bclib.registry.PresetsRegistry;
|
||||||
import org.betterx.worlds.together.tag.v3.TagManager;
|
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||||
import org.betterx.worlds.together.world.WorldConfig;
|
import org.betterx.worlds.together.world.WorldConfig;
|
||||||
|
@ -57,9 +56,6 @@ public class LevelGenEvents {
|
||||||
String directory,
|
String directory,
|
||||||
Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap
|
Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap
|
||||||
) {
|
) {
|
||||||
//make sure we include Tags registered by the deprecated API
|
|
||||||
TagAPI.apply(directory, tagsMap);
|
|
||||||
|
|
||||||
if (directory.equals(TagManager.BIOMES.directory)) {
|
if (directory.equals(TagManager.BIOMES.directory)) {
|
||||||
InternalBiomeAPI._runBiomeTagAdders();
|
InternalBiomeAPI._runBiomeTagAdders();
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,15 +227,6 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
||||||
this(ResourceKey.create(Registry.BIOME_REGISTRY, biomeID), null);
|
this(ResourceKey.create(Registry.BIOME_REGISTRY, biomeID), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create wrapper for existing biome using biome instance from {@link BuiltinRegistries}.
|
|
||||||
*
|
|
||||||
* @param biomeToRegister {@link Biome} to wrap.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
protected BCLBiome(Biome biomeToRegister) {
|
|
||||||
this(biomeToRegister, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create wrapper for existing biome using biome instance from {@link BuiltinRegistries}.
|
* Create wrapper for existing biome using biome instance from {@link BuiltinRegistries}.
|
||||||
|
@ -243,21 +234,11 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
||||||
* @param biomeToRegister {@link Biome} to wrap.
|
* @param biomeToRegister {@link Biome} to wrap.
|
||||||
* @param settings The Settings for this Biome or {@code null} if you want to apply default settings
|
* @param settings The Settings for this Biome or {@code null} if you want to apply default settings
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true)
|
@ApiStatus.Internal
|
||||||
protected BCLBiome(Biome biomeToRegister, VanillaBiomeSettings settings) {
|
BCLBiome(Biome biomeToRegister, VanillaBiomeSettings settings) {
|
||||||
this(BiomeAPI.getBiomeID(biomeToRegister), biomeToRegister, settings);
|
this(BiomeAPI.getBiomeID(biomeToRegister), biomeToRegister, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create wrapper for existing biome using biome instance from {@link BuiltinRegistries}.
|
|
||||||
*
|
|
||||||
* @param biomeToRegister {@link Biome} to wrap.
|
|
||||||
* @param biomeID Teh ResoureLocation for this Biome
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public BCLBiome(ResourceLocation biomeID, Biome biomeToRegister) {
|
|
||||||
this(biomeID, biomeToRegister, (BCLBiomeSettings) null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create wrapper for existing biome using biome instance from {@link BuiltinRegistries}.
|
* Create wrapper for existing biome using biome instance from {@link BuiltinRegistries}.
|
||||||
|
@ -434,18 +415,6 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
||||||
return biomeID;
|
return biomeID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for biome from buil-in registry. For datapack biomes will be same as actual biome.
|
|
||||||
*
|
|
||||||
* @return {@link Biome}.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public Biome getBiome() {
|
|
||||||
if (biomeToRegister != null) return biomeToRegister;
|
|
||||||
return BiomeAPI.getFromBuiltinRegistry(biomeKey).value();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for biomeKey
|
* Getter for biomeKey
|
||||||
*
|
*
|
||||||
|
@ -466,58 +435,6 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for custom data. Will get custom data object or null if object doesn't exists.
|
|
||||||
*
|
|
||||||
* @param name {@link String} name of data object.
|
|
||||||
* @return object value or null.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public <T> T getCustomData(String name) {
|
|
||||||
return (T) customData.get(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for custom data. Will get custom data object or default value if object doesn't exists.
|
|
||||||
*
|
|
||||||
* @param name {@link String} name of data object.
|
|
||||||
* @param defaultValue object default value.
|
|
||||||
* @return object value or default value.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public <T> T getCustomData(String name, T defaultValue) {
|
|
||||||
return (T) customData.getOrDefault(name, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds custom data object to this biome instance.
|
|
||||||
*
|
|
||||||
* @param name {@link String} name of data object.
|
|
||||||
* @param obj any data to add.
|
|
||||||
* @return same {@link BCLBiome}.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public BCLBiome addCustomData(String name, Object obj) {
|
|
||||||
customData.put(name, obj);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds custom data object to this biome instance.
|
|
||||||
*
|
|
||||||
* @param data a {@link Map} with custom data.
|
|
||||||
* @return same {@link BCLBiome}.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public BCLBiome addCustomData(Map<String, Object> data) {
|
|
||||||
customData.putAll(data);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj == this) {
|
if (obj == this) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.biomes;
|
package org.betterx.bclib.api.v2.levelgen.biomes;
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.BCLFeature;
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.structures.BCLStructure;
|
import org.betterx.bclib.api.v2.levelgen.structures.BCLStructure;
|
||||||
import org.betterx.bclib.api.v2.levelgen.surface.SurfaceRuleBuilder;
|
import org.betterx.bclib.api.v2.levelgen.surface.SurfaceRuleBuilder;
|
||||||
|
import org.betterx.bclib.api.v3.levelgen.features.BCLFeature;
|
||||||
import org.betterx.bclib.entity.BCLEntityWrapper;
|
import org.betterx.bclib.entity.BCLEntityWrapper;
|
||||||
import org.betterx.bclib.mixin.common.BiomeGenerationSettingsAccessor;
|
import org.betterx.bclib.mixin.common.BiomeGenerationSettingsAccessor;
|
||||||
import org.betterx.bclib.util.CollectionsUtil;
|
import org.betterx.bclib.util.CollectionsUtil;
|
||||||
|
@ -46,7 +46,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class BCLBiomeBuilder {
|
public class BCLBiomeBuilder {
|
||||||
|
@ -601,15 +600,6 @@ public class BCLBiomeBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds new feature to the biome.
|
|
||||||
*
|
|
||||||
* @param feature {@link BCLFeature}.
|
|
||||||
* @return same {@link BCLBiomeBuilder} instance.
|
|
||||||
*/
|
|
||||||
public BCLBiomeBuilder feature(BCLFeature feature) {
|
|
||||||
return feature(feature.getDecoration(), feature.getPlacedFeature());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds new feature to the biome.
|
* Adds new feature to the biome.
|
||||||
|
@ -617,7 +607,7 @@ public class BCLBiomeBuilder {
|
||||||
* @param feature {@link BCLFeature}.
|
* @param feature {@link BCLFeature}.
|
||||||
* @return same {@link BCLBiomeBuilder} instance.
|
* @return same {@link BCLBiomeBuilder} instance.
|
||||||
*/
|
*/
|
||||||
public BCLBiomeBuilder feature(org.betterx.bclib.api.v3.levelgen.features.BCLFeature feature) {
|
public BCLBiomeBuilder feature(BCLFeature feature) {
|
||||||
return feature(feature.decoration, feature.placedFeature);
|
return feature(feature.decoration, feature.placedFeature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,17 +853,6 @@ public class BCLBiomeBuilder {
|
||||||
return build((BiomeSupplier<BCLBiome>) BCLBiome::new);
|
return build((BiomeSupplier<BCLBiome>) BCLBiome::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Finalize biome creation.
|
|
||||||
*
|
|
||||||
* @param biomeConstructor {@link BiFunction} biome constructor.
|
|
||||||
* @return created {@link BCLBiome} instance.
|
|
||||||
* @deprecated Replaced with {@link #build(BiomeSupplier)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public <T extends BCLBiome> T build(BiFunction<ResourceLocation, Biome, T> biomeConstructor) {
|
|
||||||
return build((id, biome, settings) -> biomeConstructor.apply(id, biome));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finalize biome creation.
|
* Finalize biome creation.
|
||||||
|
|
|
@ -59,11 +59,6 @@ public class BCLBiomeRegistry {
|
||||||
return codec.codec();
|
return codec.codec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static ResourceKey<BCLBiome> register(BCLBiome biome) {
|
|
||||||
return register(null, biome);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register new Biome Data
|
* Register new Biome Data
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.biomes;
|
package org.betterx.bclib.api.v2.levelgen.biomes;
|
||||||
|
|
||||||
import org.betterx.bclib.BCLib;
|
import org.betterx.bclib.BCLib;
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.BCLFeature;
|
import org.betterx.bclib.api.v3.levelgen.features.BCLFeature;
|
||||||
import org.betterx.bclib.interfaces.SurfaceMaterialProvider;
|
import org.betterx.bclib.interfaces.SurfaceMaterialProvider;
|
||||||
import org.betterx.bclib.mixin.common.BiomeGenerationSettingsAccessor;
|
import org.betterx.bclib.mixin.common.BiomeGenerationSettingsAccessor;
|
||||||
import org.betterx.bclib.mixin.common.MobSpawnSettingsAccessor;
|
import org.betterx.bclib.mixin.common.MobSpawnSettingsAccessor;
|
||||||
|
@ -55,6 +55,26 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class BiomeAPI {
|
public class BiomeAPI {
|
||||||
|
/**
|
||||||
|
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
||||||
|
*
|
||||||
|
* @param bclbiome {@link BCLBiome}
|
||||||
|
* @param dim The Dimension fo rthis Biome
|
||||||
|
* @return {@link BCLBiome}
|
||||||
|
*/
|
||||||
|
public static BCLBiome registerBuiltinBiomeAndOverrideIntendedDimension(BCLBiome bclbiome, BiomeType dim) {
|
||||||
|
return registerBiomeAndOverrideIntendedDimension(bclbiome, dim, BuiltinRegistries.BIOME);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BCLBiome registerBiomeAndOverrideIntendedDimension(
|
||||||
|
BCLBiome bclbiome,
|
||||||
|
BiomeType dim,
|
||||||
|
Registry<Biome> registryOrNull
|
||||||
|
) {
|
||||||
|
bclbiome._setIntendedType(dim);
|
||||||
|
return registerBiome(bclbiome, registryOrNull);
|
||||||
|
}
|
||||||
|
|
||||||
public static class BiomeType {
|
public static class BiomeType {
|
||||||
public static final Codec<BiomeType> DIRECT_CODEC = RecordCodecBuilder.create(instance -> instance
|
public static final Codec<BiomeType> DIRECT_CODEC = RecordCodecBuilder.create(instance -> instance
|
||||||
.group(
|
.group(
|
||||||
|
@ -209,14 +229,6 @@ public class BiomeAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Empty biome used as default value if requested biome doesn't exist or linked. Shouldn't be registered anywhere to prevent bugs.
|
|
||||||
* Have {@code Biomes.THE_VOID} as the reference biome.
|
|
||||||
*
|
|
||||||
* @deprecated use {@link BCLBiomeRegistry#EMPTY_BIOME} instead
|
|
||||||
*/
|
|
||||||
public static final BCLBiome EMPTY_BIOME = BCLBiomeRegistry.EMPTY_BIOME;
|
|
||||||
|
|
||||||
public static final BCLBiome NETHER_WASTES_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
public static final BCLBiome NETHER_WASTES_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||||
Biomes.NETHER_WASTES,
|
Biomes.NETHER_WASTES,
|
||||||
InternalBiomeAPI.OTHER_NETHER
|
InternalBiomeAPI.OTHER_NETHER
|
||||||
|
@ -270,35 +282,6 @@ public class BiomeAPI {
|
||||||
InternalBiomeAPI.OTHER_END_VOID
|
InternalBiomeAPI.OTHER_END_VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLBiome registerBiome(BCLBiome bclbiome) {
|
|
||||||
return InternalBiomeAPI.registerBuiltinBiome(bclbiome);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
|
||||||
*
|
|
||||||
* @param bclbiome {@link BCLBiome}
|
|
||||||
* @param dim The Dimension fo rthis Biome
|
|
||||||
* @return {@link BCLBiome}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLBiome registerBiome(BCLBiome bclbiome, BiomeType dim) {
|
|
||||||
return registerBiome(bclbiome, dim, BuiltinRegistries.BIOME);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
|
||||||
*
|
|
||||||
* @param bclbiome {@link BCLBiome}
|
|
||||||
* @param dim The Dimension fo rthis Biome
|
|
||||||
* @return {@link BCLBiome}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
static BCLBiome registerBiome(BCLBiome bclbiome, BiomeType dim, Registry<Biome> registryOrNull) {
|
|
||||||
bclbiome._setIntendedType(dim);
|
|
||||||
return registerBiome(bclbiome, registryOrNull);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
||||||
|
@ -347,7 +330,7 @@ public class BiomeAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BCLBiome registerSubBiome(BCLBiome parent, BCLBiome subBiome, BiomeType dim) {
|
public static BCLBiome registerSubBiome(BCLBiome parent, BCLBiome subBiome, BiomeType dim) {
|
||||||
registerBiome(subBiome, dim);
|
registerBuiltinBiomeAndOverrideIntendedDimension(subBiome, dim);
|
||||||
parent.addSubBiome(subBiome);
|
parent.addSubBiome(subBiome);
|
||||||
|
|
||||||
return subBiome;
|
return subBiome;
|
||||||
|
@ -366,7 +349,7 @@ public class BiomeAPI {
|
||||||
* @return {@link BCLBiome}
|
* @return {@link BCLBiome}
|
||||||
*/
|
*/
|
||||||
public static BCLBiome registerEndLandBiome(BCLBiome biome) {
|
public static BCLBiome registerEndLandBiome(BCLBiome biome) {
|
||||||
registerBiome(biome, BiomeType.BCL_END_LAND);
|
registerBuiltinBiomeAndOverrideIntendedDimension(biome, BiomeType.BCL_END_LAND);
|
||||||
|
|
||||||
float weight = biome.getGenChance();
|
float weight = biome.getGenChance();
|
||||||
ResourceKey<Biome> key = biome.getBiomeKey();
|
ResourceKey<Biome> key = biome.getBiomeKey();
|
||||||
|
@ -390,7 +373,7 @@ public class BiomeAPI {
|
||||||
* @return {@link BCLBiome}
|
* @return {@link BCLBiome}
|
||||||
*/
|
*/
|
||||||
public static BCLBiome registerEndVoidBiome(BCLBiome biome) {
|
public static BCLBiome registerEndVoidBiome(BCLBiome biome) {
|
||||||
registerBiome(biome, BiomeType.BCL_END_VOID);
|
registerBuiltinBiomeAndOverrideIntendedDimension(biome, BiomeType.BCL_END_VOID);
|
||||||
|
|
||||||
float weight = biome.getGenChance();
|
float weight = biome.getGenChance();
|
||||||
ResourceKey<Biome> key = biome.getBiomeKey();
|
ResourceKey<Biome> key = biome.getBiomeKey();
|
||||||
|
@ -409,7 +392,7 @@ public class BiomeAPI {
|
||||||
* @return {@link BCLBiome}
|
* @return {@link BCLBiome}
|
||||||
*/
|
*/
|
||||||
public static BCLBiome registerEndCenterBiome(BCLBiome biome) {
|
public static BCLBiome registerEndCenterBiome(BCLBiome biome) {
|
||||||
registerBiome(biome, BiomeType.BCL_END_CENTER);
|
registerBuiltinBiomeAndOverrideIntendedDimension(biome, BiomeType.BCL_END_CENTER);
|
||||||
|
|
||||||
float weight = biome.getGenChance();
|
float weight = biome.getGenChance();
|
||||||
ResourceKey<Biome> key = biome.getBiomeKey();
|
ResourceKey<Biome> key = biome.getBiomeKey();
|
||||||
|
@ -428,7 +411,7 @@ public class BiomeAPI {
|
||||||
* @return {@link BCLBiome}
|
* @return {@link BCLBiome}
|
||||||
*/
|
*/
|
||||||
public static BCLBiome registerEndBarrensBiome(BCLBiome highlandBiome, BCLBiome biome) {
|
public static BCLBiome registerEndBarrensBiome(BCLBiome highlandBiome, BCLBiome biome) {
|
||||||
registerBiome(biome, BiomeType.BCL_END_BARRENS);
|
registerBuiltinBiomeAndOverrideIntendedDimension(biome, BiomeType.BCL_END_BARRENS);
|
||||||
|
|
||||||
float weight = biome.getGenChance();
|
float weight = biome.getGenChance();
|
||||||
ResourceKey<Biome> key = biome.getBiomeKey();
|
ResourceKey<Biome> key = biome.getBiomeKey();
|
||||||
|
@ -448,7 +431,7 @@ public class BiomeAPI {
|
||||||
* @return {@link BCLBiome}
|
* @return {@link BCLBiome}
|
||||||
*/
|
*/
|
||||||
public static BCLBiome registerNetherBiome(BCLBiome bclBiome) {
|
public static BCLBiome registerNetherBiome(BCLBiome bclBiome) {
|
||||||
registerBiome(bclBiome, BiomeType.BCL_NETHER);
|
registerBuiltinBiomeAndOverrideIntendedDimension(bclBiome, BiomeType.BCL_NETHER);
|
||||||
|
|
||||||
ResourceKey<Biome> key = bclBiome.getBiomeKey();
|
ResourceKey<Biome> key = bclBiome.getBiomeKey();
|
||||||
if (!bclBiome.isEdgeBiome()) {
|
if (!bclBiome.isEdgeBiome()) {
|
||||||
|
@ -457,25 +440,6 @@ public class BiomeAPI {
|
||||||
return bclBiome;
|
return bclBiome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get {@link BCLBiome} from {@link Biome} instance on server. Used to convert world biomes to BCLBiomes.
|
|
||||||
*
|
|
||||||
* @param biome - {@link Holder<Biome>} from world.
|
|
||||||
* @return {@link BCLBiome} or {@code BiomeAPI.EMPTY_BIOME}.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLBiome getFromBiome(Holder<Biome> biome) {
|
|
||||||
if (InternalBiomeAPI.biomeRegistry == null) {
|
|
||||||
return BCLBiomeRegistry.EMPTY_BIOME;
|
|
||||||
}
|
|
||||||
return BCLBiomeRegistry
|
|
||||||
.getOrElseEmpty(
|
|
||||||
InternalBiomeAPI.registryAccess,
|
|
||||||
biome.unwrapKey().orElseThrow().location()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get {@link BCLBiome} from biome on client. Used in fog rendering.
|
* Get {@link BCLBiome} from biome on client. Used in fog rendering.
|
||||||
*
|
*
|
||||||
|
@ -648,18 +612,6 @@ public class BiomeAPI {
|
||||||
return BuiltinRegistries.BIOME.getHolder(key).orElse(null);
|
return BuiltinRegistries.BIOME.getHolder(key).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static boolean registryContains(ResourceKey<Biome> key) {
|
|
||||||
if (InternalBiomeAPI.biomeRegistry != null)
|
|
||||||
return InternalBiomeAPI.biomeRegistry.containsKey(key);
|
|
||||||
return builtinRegistryContains(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static boolean builtinRegistryContains(ResourceKey<Biome> key) {
|
|
||||||
return BuiltinRegistries.BIOME.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isDatapackBiome(ResourceLocation biomeID) {
|
public static boolean isDatapackBiome(ResourceLocation biomeID) {
|
||||||
return getFromBuiltinRegistry(biomeID) == null;
|
return getFromBuiltinRegistry(biomeID) == null;
|
||||||
|
@ -781,40 +733,6 @@ public class BiomeAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a unique sort order for all Features of the Biome. This method is automatically called for each Biome
|
|
||||||
* after all biome Modifications were executed.
|
|
||||||
*
|
|
||||||
* @param biome The {@link Biome} to sort the features for
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void sortBiomeFeatures(Holder<Biome> biome) {
|
|
||||||
//sortBiomeFeatures(biome.value());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sortBiomeFeatures(Biome biome) {
|
|
||||||
// BiomeGenerationSettings settings = biome.getGenerationSettings();
|
|
||||||
// BiomeGenerationSettingsAccessor accessor = (BiomeGenerationSettingsAccessor) settings;
|
|
||||||
// List<HolderSet<PlacedFeature>> featureList = CollectionsUtil.getMutable(accessor.bclib_getFeatures());
|
|
||||||
// final int size = featureList.size();
|
|
||||||
// for (int i = 0; i < size; i++) {
|
|
||||||
// List<Holder<PlacedFeature>> features = getFeaturesListCopy(featureList, i);
|
|
||||||
// sortFeatures(features);
|
|
||||||
// featureList.set(i, HolderSet.direct(features));
|
|
||||||
// }
|
|
||||||
// accessor.bclib_setFeatures(featureList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds new features to existing biome.
|
|
||||||
*
|
|
||||||
* @param biome {@link Biome} to add features in.
|
|
||||||
* @param feature {@link ConfiguredFeature} to add.
|
|
||||||
*/
|
|
||||||
public static void addBiomeFeature(Holder<Biome> biome, BCLFeature feature) {
|
|
||||||
addBiomeFeature(biome, feature.getDecoration(), feature.getPlacedFeature());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds new features to existing biome.
|
* Adds new features to existing biome.
|
||||||
*
|
*
|
||||||
|
@ -823,7 +741,7 @@ public class BiomeAPI {
|
||||||
*/
|
*/
|
||||||
public static void addBiomeFeature(
|
public static void addBiomeFeature(
|
||||||
Holder<Biome> biome,
|
Holder<Biome> biome,
|
||||||
org.betterx.bclib.api.v3.levelgen.features.BCLFeature feature
|
BCLFeature feature
|
||||||
) {
|
) {
|
||||||
addBiomeFeature(biome, feature.getDecoration(), feature.getPlacedFeature());
|
addBiomeFeature(biome, feature.getDecoration(), feature.getPlacedFeature());
|
||||||
}
|
}
|
||||||
|
@ -1009,85 +927,4 @@ public class BiomeAPI {
|
||||||
return features.get(index).stream().collect(Collectors.toList());
|
return features.get(index).stream().collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
|
||||||
* After that biome will be added to BCLib Nether Biome Generator and into Fabric Biome API.
|
|
||||||
*
|
|
||||||
* @param biome {@link BCLBiome}
|
|
||||||
* @return {@link BCLBiome}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLBiome registerNetherBiome(Biome biome) {
|
|
||||||
return InternalBiomeAPI.wrapNativeBiome(biome, -1, InternalBiomeAPI.OTHER_NETHER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLBiome registerEndLandBiome(Holder<Biome> biome) {
|
|
||||||
return InternalBiomeAPI.wrapNativeBiome(biome.unwrapKey().orElseThrow(), InternalBiomeAPI.OTHER_END_LAND);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
|
||||||
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a void biome (will generate only in the End void - between islands).
|
|
||||||
*
|
|
||||||
* @param biome {@link BCLBiome}
|
|
||||||
* @return {@link BCLBiome}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLBiome registerEndVoidBiome(Holder<Biome> biome) {
|
|
||||||
return InternalBiomeAPI.wrapNativeBiome(biome.unwrapKey().orElseThrow(), InternalBiomeAPI.OTHER_END_VOID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register {@link BCLBiome} wrapper for {@link Biome}.
|
|
||||||
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a land biome (will generate only on islands).
|
|
||||||
*
|
|
||||||
* @param biome {@link BCLBiome};
|
|
||||||
* @param genChance float generation chance.
|
|
||||||
* @return {@link BCLBiome}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLBiome registerEndLandBiome(Holder<Biome> biome, float genChance) {
|
|
||||||
return InternalBiomeAPI.wrapNativeBiome(
|
|
||||||
biome.unwrapKey().orElseThrow(),
|
|
||||||
genChance,
|
|
||||||
InternalBiomeAPI.OTHER_END_LAND
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
|
||||||
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a void biome (will generate only in the End void - between islands).
|
|
||||||
*
|
|
||||||
* @param biome {@link BCLBiome}.
|
|
||||||
* @param genChance float generation chance.
|
|
||||||
* @return {@link BCLBiome}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLBiome registerEndVoidBiome(Holder<Biome> biome, float genChance) {
|
|
||||||
return InternalBiomeAPI.wrapNativeBiome(
|
|
||||||
biome.unwrapKey().orElseThrow(),
|
|
||||||
genChance,
|
|
||||||
InternalBiomeAPI.OTHER_END_VOID
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLBiome registerEndBiome(Holder<Biome> biome) {
|
|
||||||
BCLBiome bclBiome = new BCLBiome(biome.value(), null);
|
|
||||||
|
|
||||||
registerBiome(bclBiome, BiomeType.END);
|
|
||||||
return bclBiome;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLBiome registerCenterBiome(Holder<Biome> biome) {
|
|
||||||
BCLBiome bclBiome = new BCLBiome(biome.value(), null);
|
|
||||||
|
|
||||||
registerBiome(bclBiome, BiomeType.END_CENTER);
|
|
||||||
return bclBiome;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.biomes;
|
package org.betterx.bclib.api.v2.levelgen.biomes;
|
||||||
|
|
||||||
import org.betterx.bclib.BCLib;
|
import org.betterx.bclib.BCLib;
|
||||||
import org.betterx.bclib.interfaces.BiomeSourceAccessor;
|
|
||||||
import org.betterx.bclib.interfaces.NoiseGeneratorSettingsProvider;
|
|
||||||
import org.betterx.bclib.mixin.common.BiomeGenerationSettingsAccessor;
|
import org.betterx.bclib.mixin.common.BiomeGenerationSettingsAccessor;
|
||||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleProvider;
|
|
||||||
|
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
|
@ -12,13 +9,10 @@ import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.data.BuiltinRegistries;
|
import net.minecraft.data.BuiltinRegistries;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.biome.BiomeSource;
|
import net.minecraft.world.level.biome.BiomeSource;
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
|
||||||
import net.minecraft.world.level.dimension.LevelStem;
|
import net.minecraft.world.level.dimension.LevelStem;
|
||||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback;
|
import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback;
|
||||||
|
@ -185,64 +179,10 @@ public class InternalBiomeAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void applyModificationsDeprecated(ServerLevel level) {
|
|
||||||
//TODO: Now Disabled, because we fix the settings when everything gets loaded
|
|
||||||
if (level != null) return;
|
|
||||||
|
|
||||||
NoiseGeneratorSettings noiseGeneratorSettings = null;
|
|
||||||
final ChunkGenerator chunkGenerator = level.getChunkSource().getGenerator();
|
|
||||||
final BiomeSource source = chunkGenerator.getBiomeSource();
|
|
||||||
final Set<Holder<Biome>> biomes = source.possibleBiomes();
|
|
||||||
|
|
||||||
if (chunkGenerator instanceof NoiseGeneratorSettingsProvider gen)
|
|
||||||
noiseGeneratorSettings = gen.bclib_getNoiseGeneratorSettings();
|
|
||||||
|
|
||||||
// Datapacks (like Amplified Nether)will change the GeneratorSettings upon load, so we will
|
|
||||||
// only use the default Setting for Nether/End if we were unable to find a settings object
|
|
||||||
if (noiseGeneratorSettings == null) {
|
|
||||||
if (level.dimension() == Level.NETHER) {
|
|
||||||
noiseGeneratorSettings = BuiltinRegistries.NOISE_GENERATOR_SETTINGS.get(NoiseGeneratorSettings.NETHER);
|
|
||||||
} else if (level.dimension() == Level.END) {
|
|
||||||
noiseGeneratorSettings = BuiltinRegistries.NOISE_GENERATOR_SETTINGS.get(NoiseGeneratorSettings.END);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<BiConsumer<ResourceLocation, Holder<Biome>>> modifications = MODIFICATIONS.get(level
|
|
||||||
.dimensionTypeRegistration()
|
|
||||||
.unwrapKey()
|
|
||||||
.orElseThrow());
|
|
||||||
for (Holder<Biome> biomeHolder : biomes) {
|
|
||||||
if (biomeHolder.isBound()) {
|
|
||||||
applyModificationsAndUpdateFeatures(modifications, biomeHolder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (noiseGeneratorSettings != null) {
|
|
||||||
final SurfaceRuleProvider provider = SurfaceRuleProvider.class.cast(noiseGeneratorSettings);
|
|
||||||
// Multiple Biomes can use the same generator. So we need to keep track of all Biomes that are
|
|
||||||
// Provided by all the BiomeSources that use the same generator.
|
|
||||||
// This happens for example when using the MiningDimensions, which reuses the generator for the
|
|
||||||
// Nethering Dimension
|
|
||||||
//MODIFIED_SURFACE_PROVIDERS.add(provider);
|
|
||||||
|
|
||||||
//provider.bclib_addBiomeSource(source);
|
|
||||||
} else {
|
|
||||||
BCLib.LOGGER.warning("No generator for " + source);
|
|
||||||
}
|
|
||||||
|
|
||||||
((BiomeSourceAccessor) source).bclRebuildFeatures();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void applyModifications(BiomeSource source, ResourceKey<LevelStem> dimension) {
|
public static void applyModifications(BiomeSource source, ResourceKey<LevelStem> dimension) {
|
||||||
BCLib.LOGGER.info("\nApply Modifications for " + dimension.location() + source.toString()
|
BCLib.LOGGER.info("\nApply Modifications for " + dimension.location() + source.toString()
|
||||||
.replace("\n", "\n "));
|
.replace("\n", "\n "));
|
||||||
/*if (dimension.location().equals(LevelStem.NETHER)){
|
|
||||||
if (source instanceof BCLBiomeSource s) {
|
|
||||||
NetherBiomes.useLegacyGeneration = s.biomeSourceVersion==BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
final Set<Holder<Biome>> biomes = source.possibleBiomes();
|
final Set<Holder<Biome>> biomes = source.possibleBiomes();
|
||||||
List<BiConsumer<ResourceLocation, Holder<Biome>>> modifications = MODIFICATIONS.get(dimension);
|
List<BiConsumer<ResourceLocation, Holder<Biome>>> modifications = MODIFICATIONS.get(dimension);
|
||||||
for (Holder<Biome> biomeHolder : biomes) {
|
for (Holder<Biome> biomeHolder : biomes) {
|
||||||
|
@ -262,8 +202,6 @@ public class InternalBiomeAPI {
|
||||||
consumer.accept(biomeID, biome);
|
consumer.accept(biomeID, biome);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
BiomeAPI.sortBiomeFeatures(biome);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Set<ResourceLocation> BIOMES_TO_SORT = Sets.newHashSet();
|
private static final Set<ResourceLocation> BIOMES_TO_SORT = Sets.newHashSet();
|
||||||
|
@ -333,28 +271,6 @@ public class InternalBiomeAPI {
|
||||||
return bclBiome;
|
return bclBiome;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Register {@link BCLBiome} wrapper for {@link Biome}.
|
|
||||||
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a land biome (will generate only on islands).
|
|
||||||
*
|
|
||||||
* @param biome The source biome to wrap
|
|
||||||
* @param genChance generation chance.
|
|
||||||
* @return {@link BCLBiome}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
static BCLBiome wrapNativeBiome(Biome biome, float genChance, BiomeAPI.BiomeType type) {
|
|
||||||
BCLBiome bclBiome = BiomeAPI.getBiome(biome);
|
|
||||||
if (bclBiome == BCLBiomeRegistry.EMPTY_BIOME) {
|
|
||||||
bclBiome = new BCLBiome(
|
|
||||||
biome,
|
|
||||||
genChance < 0 ? null : VanillaBiomeSettings.createVanilla().setGenChance(genChance).build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
BiomeAPI.registerBiome(bclBiome, type, null);
|
|
||||||
return bclBiome;
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
DynamicRegistrySetupCallback.EVENT.register(registryManager -> {
|
DynamicRegistrySetupCallback.EVENT.register(registryManager -> {
|
||||||
Optional<? extends Registry<Biome>> oBiomeRegistry = registryManager.registry(Registry.BIOME_REGISTRY);
|
Optional<? extends Registry<Biome>> oBiomeRegistry = registryManager.registry(Registry.BIOME_REGISTRY);
|
||||||
|
@ -415,4 +331,5 @@ public class InternalBiomeAPI {
|
||||||
public static BCLBiome registerBuiltinBiome(BCLBiome bclbiome) {
|
public static BCLBiome registerBuiltinBiome(BCLBiome bclbiome) {
|
||||||
return BiomeAPI.registerBiome(bclbiome, BuiltinRegistries.BIOME);
|
return BiomeAPI.registerBiome(bclbiome, BuiltinRegistries.BIOME);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,166 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features;
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.BlockMatchTest;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class BCLCommonFeatures {
|
|
||||||
/**
|
|
||||||
* Will create a basic plant feature.
|
|
||||||
*
|
|
||||||
* @param id {@link ResourceLocation} feature ID.
|
|
||||||
* @param feature {@link Feature} with {@link NoneFeatureConfiguration} config.
|
|
||||||
* @param density iterations per chunk.
|
|
||||||
* @return new BCLFeature instance.
|
|
||||||
*/
|
|
||||||
public static BCLFeature makeVegetationFeature(
|
|
||||||
ResourceLocation id,
|
|
||||||
Feature<NoneFeatureConfiguration> feature,
|
|
||||||
int density
|
|
||||||
) {
|
|
||||||
return makeVegetationFeature(id, feature, density, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will create a basic plant feature.
|
|
||||||
*
|
|
||||||
* @param id {@link ResourceLocation} feature ID.
|
|
||||||
* @param feature {@link Feature} with {@link NoneFeatureConfiguration} config.
|
|
||||||
* @param density iterations per chunk.
|
|
||||||
* @param allHeight if {@code true} will generate plant on all layers, if {@code false} - only on surface.
|
|
||||||
* @return new BCLFeature instance.
|
|
||||||
*/
|
|
||||||
public static BCLFeature makeVegetationFeature(
|
|
||||||
ResourceLocation id,
|
|
||||||
Feature<NoneFeatureConfiguration> feature,
|
|
||||||
int density,
|
|
||||||
boolean allHeight
|
|
||||||
) {
|
|
||||||
if (allHeight) {
|
|
||||||
return BCLFeatureBuilder
|
|
||||||
.start(id, feature)
|
|
||||||
.countLayers(density)
|
|
||||||
.squarePlacement()
|
|
||||||
.onlyInBiome()
|
|
||||||
.buildAndRegister();
|
|
||||||
} else {
|
|
||||||
return BCLFeatureBuilder
|
|
||||||
.start(id, feature)
|
|
||||||
.countMax(density)
|
|
||||||
.squarePlacement()
|
|
||||||
.heightmap()
|
|
||||||
.onlyInBiome()
|
|
||||||
.buildAndRegister();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will create feature which will be generated once in each chunk.
|
|
||||||
*
|
|
||||||
* @param id {@link ResourceLocation} feature ID.
|
|
||||||
* @param decoration {@link Decoration} feature step.
|
|
||||||
* @param feature {@link Feature} with {@link NoneFeatureConfiguration} config.
|
|
||||||
* @return new BCLFeature instance.
|
|
||||||
*/
|
|
||||||
public static BCLFeature makeChunkFeature(
|
|
||||||
ResourceLocation id,
|
|
||||||
Decoration decoration,
|
|
||||||
Feature<NoneFeatureConfiguration> feature
|
|
||||||
) {
|
|
||||||
return BCLFeatureBuilder.start(id, feature).decoration(decoration).count(1).onlyInBiome().buildAndRegister();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will create feature with chanced decoration, chance for feature to generate per chunk is 1 / chance.
|
|
||||||
*
|
|
||||||
* @param id {@link ResourceLocation} feature ID.
|
|
||||||
* @param decoration {@link Decoration} feature step.
|
|
||||||
* @param feature {@link Feature} with {@link NoneFeatureConfiguration} config.
|
|
||||||
* @param chance chance for feature to be generated in.
|
|
||||||
* @return new BCLFeature instance.
|
|
||||||
*/
|
|
||||||
public static BCLFeature makeChancedFeature(
|
|
||||||
ResourceLocation id,
|
|
||||||
Decoration decoration,
|
|
||||||
Feature<NoneFeatureConfiguration> feature,
|
|
||||||
int chance
|
|
||||||
) {
|
|
||||||
return BCLFeatureBuilder.start(id, feature)
|
|
||||||
.decoration(decoration)
|
|
||||||
.onceEvery(chance)
|
|
||||||
.squarePlacement()
|
|
||||||
.onlyInBiome()
|
|
||||||
.buildAndRegister();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will create feature with specified generation iterations per chunk.
|
|
||||||
*
|
|
||||||
* @param id {@link ResourceLocation} feature ID.
|
|
||||||
* @param decoration {@link Decoration} feature step.
|
|
||||||
* @param feature {@link Feature} with {@link NoneFeatureConfiguration} config.
|
|
||||||
* @param count iterations steps.
|
|
||||||
* @return new BCLFeature instance.
|
|
||||||
*/
|
|
||||||
public static BCLFeature makeCountFeature(
|
|
||||||
ResourceLocation id,
|
|
||||||
Decoration decoration,
|
|
||||||
Feature<NoneFeatureConfiguration> feature,
|
|
||||||
int count
|
|
||||||
) {
|
|
||||||
return BCLFeatureBuilder.start(id, feature)
|
|
||||||
.decoration(decoration)
|
|
||||||
.count(count)
|
|
||||||
.squarePlacement()
|
|
||||||
.onlyInBiome()
|
|
||||||
.buildAndRegister();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will create a basic ore feature.
|
|
||||||
*
|
|
||||||
* @param id {@link ResourceLocation} feature ID.
|
|
||||||
* @param blockOre {@link Decoration} feature step.
|
|
||||||
* @param hostBlock {@link Block} to generate feature in.
|
|
||||||
* @param veins iterations per chunk.
|
|
||||||
* @param veinSize size of ore vein.
|
|
||||||
* @param airDiscardChance chance that this orge gets discarded when it is exposed to air
|
|
||||||
* @param placement {@link net.minecraft.world.level.levelgen.placement.PlacementModifier} for the ore distribution,
|
|
||||||
* for example {@code PlacementUtils.FULL_RANGE}, {@code PlacementUtils.RANGE_10_10}
|
|
||||||
* @param rare when true, this is placed as a rare resource
|
|
||||||
* @return new BCLFeature instance.
|
|
||||||
*/
|
|
||||||
public static BCLFeature makeOreFeature(
|
|
||||||
ResourceLocation id,
|
|
||||||
Block blockOre,
|
|
||||||
Block hostBlock,
|
|
||||||
int veins,
|
|
||||||
int veinSize,
|
|
||||||
float airDiscardChance,
|
|
||||||
PlacementModifier placement,
|
|
||||||
boolean rare
|
|
||||||
) {
|
|
||||||
BCLFeatureBuilder builder = BCLFeatureBuilder.start(id, Feature.ORE).decoration(Decoration.UNDERGROUND_ORES);
|
|
||||||
|
|
||||||
if (rare) {
|
|
||||||
builder.onceEvery(veins);
|
|
||||||
} else {
|
|
||||||
builder.count(veins);
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.modifier(placement).squarePlacement().onlyInBiome();
|
|
||||||
|
|
||||||
return builder.buildAndRegister(new OreConfiguration(
|
|
||||||
new BlockMatchTest(hostBlock),
|
|
||||||
blockOre.defaultBlockState(),
|
|
||||||
veinSize,
|
|
||||||
airDiscardChance
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,290 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features;
|
|
||||||
|
|
||||||
import org.betterx.bclib.BCLib;
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.config.ScatterFeatureConfig;
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.features.ScatterFeature;
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.features.WeightedRandomSelectorFeature;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.BCLConfigureFeature;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.BCLFeatureBuilder;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.UserGrowableFeature;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.config.ConditionFeatureConfig;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.config.PlaceFacingBlockConfig;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.config.SequenceFeatureConfig;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.config.TemplateFeatureConfig;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.data.BuiltinRegistries;
|
|
||||||
import net.minecraft.data.worldgen.features.FeatureUtils;
|
|
||||||
import net.minecraft.data.worldgen.placement.PlacementUtils;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.RandomFeatureConfiguration;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param <F>
|
|
||||||
* @param <FC>
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.BCLFeature} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class BCLFeature<F extends Feature<FC>, FC extends FeatureConfiguration> {
|
|
||||||
/**
|
|
||||||
* @deprecated Replace by {@link org.betterx.bclib.api.v3.levelgen.features.BCLFeature#PLACE_BLOCK}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final Feature<PlaceFacingBlockConfig> PLACE_BLOCK = org.betterx.bclib.api.v3.levelgen.features.BCLFeature.PLACE_BLOCK;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final Feature<ScatterFeatureConfig.OnSolid> SCATTER_ON_SOLID = register(
|
|
||||||
BCLib.makeID("scatter_on_solid"),
|
|
||||||
new ScatterFeature<>(ScatterFeatureConfig.OnSolid.CODEC)
|
|
||||||
);
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final Feature<ScatterFeatureConfig.ExtendTop> SCATTER_EXTEND_TOP = register(
|
|
||||||
BCLib.makeID("scatter_extend_top"),
|
|
||||||
new ScatterFeature<>(ScatterFeatureConfig.ExtendTop.CODEC)
|
|
||||||
);
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final Feature<ScatterFeatureConfig.ExtendBottom> SCATTER_EXTEND_BOTTOM = register(
|
|
||||||
BCLib.makeID("scatter_extend_bottom"),
|
|
||||||
new ScatterFeature<>(ScatterFeatureConfig.ExtendBottom.CODEC)
|
|
||||||
);
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final Feature<RandomFeatureConfiguration> RANDOM_SELECTOR = register(
|
|
||||||
BCLib.makeID("random_select"),
|
|
||||||
new WeightedRandomSelectorFeature()
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replace by {@link org.betterx.bclib.api.v3.levelgen.features.BCLFeature#TEMPLATE}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final Feature<TemplateFeatureConfig> TEMPLATE = org.betterx.bclib.api.v3.levelgen.features.BCLFeature.TEMPLATE;
|
|
||||||
/**
|
|
||||||
* @deprecated Replace by {@link org.betterx.bclib.api.v3.levelgen.features.BCLFeature#MARK_POSTPROCESSING}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final Feature<NoneFeatureConfiguration> MARK_POSTPROCESSING = org.betterx.bclib.api.v3.levelgen.features.BCLFeature.MARK_POSTPROCESSING;
|
|
||||||
/**
|
|
||||||
* @deprecated Replace by {@link org.betterx.bclib.api.v3.levelgen.features.BCLFeature#SEQUENCE}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final Feature<SequenceFeatureConfig> SEQUENCE = org.betterx.bclib.api.v3.levelgen.features.BCLFeature.SEQUENCE;
|
|
||||||
/**
|
|
||||||
* @deprecated Replace by {@link org.betterx.bclib.api.v3.levelgen.features.BCLFeature#CONDITION}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final Feature<ConditionFeatureConfig> CONDITION = org.betterx.bclib.api.v3.levelgen.features.BCLFeature.CONDITION;
|
|
||||||
|
|
||||||
public final ResourceLocation id;
|
|
||||||
|
|
||||||
org.betterx.bclib.api.v3.levelgen.features.BCLFeature<F, FC> proxy;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public BCLFeature(
|
|
||||||
ResourceLocation id,
|
|
||||||
F feature,
|
|
||||||
Decoration featureStep,
|
|
||||||
FC configuration,
|
|
||||||
PlacementModifier[] modifiers
|
|
||||||
) {
|
|
||||||
this(id, feature, featureStep, configuration, buildPlacedFeature(id, feature, configuration, modifiers));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <E> boolean containsObj(Registry<E> registry, E obj) {
|
|
||||||
Optional<Map.Entry<ResourceKey<E>, E>> optional = registry
|
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.filter(entry -> entry.getValue() == obj)
|
|
||||||
.findAny();
|
|
||||||
return optional.isPresent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <F extends Feature<FC>, FC extends FeatureConfiguration> org.betterx.bclib.api.v3.levelgen.features.BCLFeature<F, FC> build(
|
|
||||||
ResourceLocation id,
|
|
||||||
F feature,
|
|
||||||
Decoration featureStep,
|
|
||||||
FC configuration,
|
|
||||||
Holder<PlacedFeature> placedFeature
|
|
||||||
) {
|
|
||||||
BCLConfigureFeature<F, FC> cfg = BCLFeatureBuilder.start(id, feature)
|
|
||||||
.configuration(configuration)
|
|
||||||
.build();
|
|
||||||
if (!BuiltinRegistries.PLACED_FEATURE.containsKey(id)) {
|
|
||||||
Registry.register(BuiltinRegistries.PLACED_FEATURE, id, placedFeature.value());
|
|
||||||
}
|
|
||||||
if (!Registry.FEATURE.containsKey(id) && !containsObj(Registry.FEATURE, feature)) {
|
|
||||||
Registry.register(Registry.FEATURE, id, feature);
|
|
||||||
}
|
|
||||||
return new org.betterx.bclib.api.v3.levelgen.features.BCLFeature<>(cfg, placedFeature, featureStep);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public BCLFeature(
|
|
||||||
ResourceLocation id,
|
|
||||||
F feature,
|
|
||||||
Decoration featureStep,
|
|
||||||
FC configuration,
|
|
||||||
Holder<PlacedFeature> placedFeature
|
|
||||||
) {
|
|
||||||
this(build(id, feature, featureStep, configuration, placedFeature));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public BCLFeature(org.betterx.bclib.api.v3.levelgen.features.BCLFeature proxy) {
|
|
||||||
this.proxy = proxy;
|
|
||||||
this.id = proxy.configuredFeature.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <FC extends FeatureConfiguration, F extends Feature<FC>> Holder<PlacedFeature> buildPlacedFeature(
|
|
||||||
ResourceLocation id,
|
|
||||||
F feature,
|
|
||||||
FC configuration,
|
|
||||||
PlacementModifier[] modifiers
|
|
||||||
) {
|
|
||||||
Holder<ConfiguredFeature<?, ?>> configuredFeature;
|
|
||||||
if (!BuiltinRegistries.CONFIGURED_FEATURE.containsKey(id)) {
|
|
||||||
configuredFeature = (Holder<ConfiguredFeature<?, ?>>) (Object) FeatureUtils.register(
|
|
||||||
id.toString(),
|
|
||||||
feature,
|
|
||||||
configuration
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
configuredFeature = BuiltinRegistries.CONFIGURED_FEATURE
|
|
||||||
.getHolder(ResourceKey.create(
|
|
||||||
BuiltinRegistries.CONFIGURED_FEATURE.key(),
|
|
||||||
id
|
|
||||||
))
|
|
||||||
.orElseThrow();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!BuiltinRegistries.PLACED_FEATURE.containsKey(id)) {
|
|
||||||
return PlacementUtils.register(id.toString(), configuredFeature, modifiers);
|
|
||||||
} else {
|
|
||||||
return BuiltinRegistries.PLACED_FEATURE.getHolder(ResourceKey.create(
|
|
||||||
BuiltinRegistries.PLACED_FEATURE.key(),
|
|
||||||
id
|
|
||||||
)).orElseThrow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string
|
|
||||||
* @param feature
|
|
||||||
* @param <C>
|
|
||||||
* @param <F>
|
|
||||||
* @return
|
|
||||||
* @deprecated Use {@link org.betterx.bclib.api.v3.levelgen.features.BCLFeature#register(ResourceLocation, Feature)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static <C extends FeatureConfiguration, F extends Feature<C>> F register(
|
|
||||||
ResourceLocation string,
|
|
||||||
F feature
|
|
||||||
) {
|
|
||||||
return org.betterx.bclib.api.v3.levelgen.features.BCLFeature.register(string, feature);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get raw feature.
|
|
||||||
*
|
|
||||||
* @return {@link Feature}.
|
|
||||||
*/
|
|
||||||
public F getFeature() {
|
|
||||||
return proxy.getFeature();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLConfigureFeature<F, FC> getConfFeature() {
|
|
||||||
return proxy.configuredFeature;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get configured feature.
|
|
||||||
*
|
|
||||||
* @return {@link PlacedFeature}.
|
|
||||||
*/
|
|
||||||
public Holder<PlacedFeature> getPlacedFeature() {
|
|
||||||
return proxy.getPlacedFeature();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get feature decoration step.
|
|
||||||
*
|
|
||||||
* @return {@link Decoration}.
|
|
||||||
*/
|
|
||||||
public Decoration getDecoration() {
|
|
||||||
return proxy.getDecoration();
|
|
||||||
}
|
|
||||||
|
|
||||||
public FC getConfiguration() {
|
|
||||||
return proxy.getConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean place(ServerLevel level, BlockPos pos, RandomSource random) {
|
|
||||||
return place(this.getFeature(), this.getConfiguration(), level, pos, random);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean placeUnbound(
|
|
||||||
Feature<?> feature,
|
|
||||||
FeatureConfiguration config,
|
|
||||||
ServerLevel level,
|
|
||||||
BlockPos pos,
|
|
||||||
RandomSource random
|
|
||||||
) {
|
|
||||||
if (config instanceof RandomPatchConfiguration rnd) {
|
|
||||||
var configured = rnd.feature().value().feature().value();
|
|
||||||
feature = configured.feature();
|
|
||||||
config = configured.config();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (feature instanceof UserGrowableFeature growable) {
|
|
||||||
return growable.grow(level, pos, random, config);
|
|
||||||
}
|
|
||||||
|
|
||||||
FeaturePlaceContext context = new FeaturePlaceContext(
|
|
||||||
Optional.empty(),
|
|
||||||
level,
|
|
||||||
level.getChunkSource().getGenerator(),
|
|
||||||
random,
|
|
||||||
pos,
|
|
||||||
config
|
|
||||||
);
|
|
||||||
return feature.place(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean place(
|
|
||||||
Feature<NoneFeatureConfiguration> feature,
|
|
||||||
ServerLevel level,
|
|
||||||
BlockPos pos,
|
|
||||||
RandomSource random
|
|
||||||
) {
|
|
||||||
return placeUnbound(feature, FeatureConfiguration.NONE, level, pos, random);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <FC extends FeatureConfiguration> boolean place(
|
|
||||||
Feature<FC> feature,
|
|
||||||
FC config,
|
|
||||||
ServerLevel level,
|
|
||||||
BlockPos pos,
|
|
||||||
RandomSource random
|
|
||||||
) {
|
|
||||||
return placeUnbound(feature, config, level, pos, random);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,402 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features;
|
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.placement.IsEmptyAboveSampledFilter;
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.placement.MinEmptyFilter;
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.placement.Stencil;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.placement.*;
|
|
||||||
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
|
|
||||||
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.core.Vec3i;
|
|
||||||
import net.minecraft.data.worldgen.placement.PlacementUtils;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.util.valueproviders.IntProvider;
|
|
||||||
import net.minecraft.util.valueproviders.UniformInt;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
|
|
||||||
import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.SimpleBlockFeature;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.SimpleBlockConfiguration;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.*;
|
|
||||||
import net.minecraft.world.level.material.Material;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param <FC>
|
|
||||||
* @param <F>
|
|
||||||
* @deprecated please use {@link org.betterx.bclib.api.v3.levelgen.features.BCLFeatureBuilder} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class BCLFeatureBuilder<FC extends FeatureConfiguration, F extends Feature<FC>> {
|
|
||||||
private final List<PlacementModifier> modifications = new ArrayList<>(5);
|
|
||||||
private final ResourceLocation featureID;
|
|
||||||
private Decoration decoration = Decoration.VEGETAL_DECORATION;
|
|
||||||
private final F feature;
|
|
||||||
private BlockStateProvider provider;
|
|
||||||
|
|
||||||
private BCLFeatureBuilder(ResourceLocation featureID, F feature) {
|
|
||||||
this.featureID = featureID;
|
|
||||||
this.feature = feature;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts a new {@link BCLFeature} builder.
|
|
||||||
*
|
|
||||||
* @param featureID {@link ResourceLocation} feature identifier.
|
|
||||||
* @param feature {@link Feature} to construct.
|
|
||||||
* @return {@link BCLFeatureBuilder} instance.
|
|
||||||
*/
|
|
||||||
public static BCLFeatureBuilder start(ResourceLocation featureID, Feature<?> feature) {
|
|
||||||
return new BCLFeatureBuilder(featureID, feature);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BCLFeatureBuilder<SimpleBlockConfiguration, SimpleBlockFeature> start(
|
|
||||||
ResourceLocation featureID,
|
|
||||||
Block block
|
|
||||||
) {
|
|
||||||
return start(featureID, BlockStateProvider.simple(block));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BCLFeatureBuilder<SimpleBlockConfiguration, SimpleBlockFeature> start(
|
|
||||||
ResourceLocation featureID,
|
|
||||||
BlockState state
|
|
||||||
) {
|
|
||||||
return start(featureID, BlockStateProvider.simple(state));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BCLFeatureBuilder<SimpleBlockConfiguration, SimpleBlockFeature> start(
|
|
||||||
ResourceLocation featureID,
|
|
||||||
BlockStateProvider provider
|
|
||||||
) {
|
|
||||||
BCLFeatureBuilder<SimpleBlockConfiguration, SimpleBlockFeature> builder = new BCLFeatureBuilder(
|
|
||||||
featureID,
|
|
||||||
Feature.SIMPLE_BLOCK
|
|
||||||
);
|
|
||||||
builder.provider = provider;
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set generation step for the feature. Default is {@code VEGETAL_DECORATION}.
|
|
||||||
*
|
|
||||||
* @param decoration {@link Decoration} step.
|
|
||||||
* @return same {@link BCLFeatureBuilder} instance.
|
|
||||||
*/
|
|
||||||
public BCLFeatureBuilder decoration(Decoration decoration) {
|
|
||||||
this.decoration = decoration;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add feature placement modifier. Used as a condition for feature how to generate.
|
|
||||||
*
|
|
||||||
* @param modifier {@link PlacementModifier}.
|
|
||||||
* @return same {@link BCLFeatureBuilder} instance.
|
|
||||||
*/
|
|
||||||
public BCLFeatureBuilder modifier(PlacementModifier modifier) {
|
|
||||||
modifications.add(modifier);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder modifier(List<PlacementModifier> modifiers) {
|
|
||||||
modifications.addAll(modifiers);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate feature in certain iterations (per chunk).
|
|
||||||
*
|
|
||||||
* @param count how many times feature will be generated in chunk.
|
|
||||||
* @return same {@link BCLFeatureBuilder} instance.
|
|
||||||
*/
|
|
||||||
public BCLFeatureBuilder count(int count) {
|
|
||||||
return modifier(CountPlacement.of(count));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate feature in certain iterations (per chunk). Count can be between 0 and max value.
|
|
||||||
*
|
|
||||||
* @param count maximum amount of iterations per chunk.
|
|
||||||
* @return same {@link BCLFeatureBuilder} instance.
|
|
||||||
*/
|
|
||||||
public BCLFeatureBuilder countMax(int count) {
|
|
||||||
return modifier(CountPlacement.of(UniformInt.of(0, count)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder countRange(int min, int max) {
|
|
||||||
return modifier(CountPlacement.of(UniformInt.of(min, max)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate feature in certain iterations (per chunk).
|
|
||||||
* Feature will be generated on all layers (example - Nether plants).
|
|
||||||
*
|
|
||||||
* @param count how many times feature will be generated in chunk layers.
|
|
||||||
* @return same {@link BCLFeatureBuilder} instance.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public BCLFeatureBuilder countLayers(int count) {
|
|
||||||
return modifier(CountOnEveryLayerPlacement.of(count));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate feature in certain iterations (per chunk). Count can be between 0 and max value.
|
|
||||||
* Feature will be generated on all layers (example - Nether plants).
|
|
||||||
*
|
|
||||||
* @param count maximum amount of iterations per chunk layers.
|
|
||||||
* @return same {@link BCLFeatureBuilder} instance.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public BCLFeatureBuilder countLayersMax(int count) {
|
|
||||||
return modifier(CountOnEveryLayerPlacement.of(UniformInt.of(0, count)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will place feature once every n-th attempts (in average).
|
|
||||||
*
|
|
||||||
* @param n amount of attempts.
|
|
||||||
* @return same {@link BCLFeatureBuilder} instance.
|
|
||||||
*/
|
|
||||||
public BCLFeatureBuilder onceEvery(int n) {
|
|
||||||
return modifier(RarityFilter.onAverageOnceEvery(n));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Restricts feature generation only to biome where feature was added.
|
|
||||||
*
|
|
||||||
* @return same {@link BCLFeatureBuilder} instance.
|
|
||||||
*/
|
|
||||||
public BCLFeatureBuilder onlyInBiome() {
|
|
||||||
return modifier(BiomeFilter.biome());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder squarePlacement() {
|
|
||||||
return modifier(InSquarePlacement.spread());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder stencil() {
|
|
||||||
return modifier(Stencil.all());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder all() {
|
|
||||||
return modifier(All.simple());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder stencilOneIn4() {
|
|
||||||
return modifier(Stencil.oneIn4());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select random height that is 10 above min Build height and 10 below max generation height
|
|
||||||
*
|
|
||||||
* @return The instance it was called on
|
|
||||||
*/
|
|
||||||
public BCLFeatureBuilder randomHeight10FromFloorCeil() {
|
|
||||||
return modifier(PlacementUtils.RANGE_10_10);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select random height that is 4 above min Build height and 10 below max generation height
|
|
||||||
*
|
|
||||||
* @return The instance it was called on
|
|
||||||
*/
|
|
||||||
public BCLFeatureBuilder randomHeight4FromFloorCeil() {
|
|
||||||
return modifier(PlacementUtils.RANGE_4_4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select random height that is 8 above min Build height and 10 below max generation height
|
|
||||||
*
|
|
||||||
* @return The instance it was called on
|
|
||||||
*/
|
|
||||||
public BCLFeatureBuilder randomHeight8FromFloorCeil() {
|
|
||||||
return modifier(PlacementUtils.RANGE_8_8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select random height that is above min Build height and 10 below max generation height
|
|
||||||
*
|
|
||||||
* @return The instance it was called on
|
|
||||||
*/
|
|
||||||
public BCLFeatureBuilder randomHeight() {
|
|
||||||
return modifier(PlacementUtils.FULL_RANGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder isEmptyAbove4() {
|
|
||||||
return modifier(IsEmptyAboveSampledFilter.emptyAbove4());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder isEmptyAbove2() {
|
|
||||||
return modifier(IsEmptyAboveSampledFilter.emptyAbove2());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder isEmptyAbove() {
|
|
||||||
return modifier(IsEmptyAboveSampledFilter.emptyAbove());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder isEmptyBelow4() {
|
|
||||||
return modifier(IsEmptyAboveSampledFilter.emptyBelow4());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder isEmptyBelow2() {
|
|
||||||
return modifier(IsEmptyAboveSampledFilter.emptyBelow2());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder isEmptyBelow() {
|
|
||||||
return modifier(IsEmptyAboveSampledFilter.emptyBelow());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder isEmptyAbove(int d1, int d2) {
|
|
||||||
return modifier(new IsEmptyAboveSampledFilter(d1, d2));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder onEveryLayer() {
|
|
||||||
return modifier(OnEveryLayer.simple());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder underEveryLayer() {
|
|
||||||
return modifier(UnderEveryLayer.simple());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder spreadHorizontal(IntProvider p) {
|
|
||||||
return modifier(RandomOffsetPlacement.horizontal(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder spreadVertical(IntProvider p) {
|
|
||||||
return modifier(RandomOffsetPlacement.horizontal(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder spread(IntProvider horizontal, IntProvider vertical) {
|
|
||||||
return modifier(RandomOffsetPlacement.of(horizontal, vertical));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder offset(Direction dir) {
|
|
||||||
return modifier(Offset.inDirection(dir));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder offset(Vec3i dir) {
|
|
||||||
return modifier(new Offset(dir));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cast a downward ray with max {@code distance} length to find the next solid Block.
|
|
||||||
*
|
|
||||||
* @param distance The maximum search Distance
|
|
||||||
* @return The instance it was called on
|
|
||||||
* @see #findSolidSurface(Direction, int) for Details
|
|
||||||
*/
|
|
||||||
public BCLFeatureBuilder findSolidFloor(int distance) {
|
|
||||||
return modifier(FindSolidInDirection.down(distance));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder noiseBasedCount(float noiseLevel, int belowNoiseCount, int aboveNoiseCount) {
|
|
||||||
return modifier(NoiseThresholdCountPlacement.of(noiseLevel, belowNoiseCount, aboveNoiseCount));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder extendDown(int min, int max) {
|
|
||||||
return modifier(new Extend(Direction.DOWN, UniformInt.of(min, max)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder inBasinOf(BlockPredicate... predicates) {
|
|
||||||
return modifier(new IsBasin(BlockPredicate.anyOf(predicates)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder inOpenBasinOf(BlockPredicate... predicates) {
|
|
||||||
return modifier(IsBasin.openTop(BlockPredicate.anyOf(predicates)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder is(BlockPredicate... predicates) {
|
|
||||||
return modifier(new Is(BlockPredicate.anyOf(predicates), Optional.empty()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder isAbove(BlockPredicate... predicates) {
|
|
||||||
return modifier(new Is(BlockPredicate.anyOf(predicates), Optional.of(Direction.DOWN.getNormal())));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder isUnder(BlockPredicate... predicates) {
|
|
||||||
return modifier(new Is(BlockPredicate.anyOf(predicates), Optional.of(Direction.UP.getNormal())));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder findSolidCeil(int distance) {
|
|
||||||
return modifier(FindSolidInDirection.up(distance));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder hasMinimumDownwardSpace() {
|
|
||||||
return modifier(MinEmptyFilter.down());
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder hasMinimumUpwardSpace() {
|
|
||||||
return modifier(MinEmptyFilter.up());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cast a ray with max {@code distance} length to find the next solid Block. The ray will travel through replaceable
|
|
||||||
* Blocks (see {@link Material#isReplaceable()}) and will be accepted if it hits a block with the
|
|
||||||
* {@link CommonBlockTags#TERRAIN}-tag
|
|
||||||
*
|
|
||||||
* @param dir The direction the ray is cast
|
|
||||||
* @param distance The maximum search Distance
|
|
||||||
* @return The instance it was called on
|
|
||||||
* @see #findSolidSurface(Direction, int) for Details
|
|
||||||
*/
|
|
||||||
public BCLFeatureBuilder findSolidSurface(Direction dir, int distance) {
|
|
||||||
return modifier(new FindSolidInDirection(dir, distance, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder findSolidSurface(List<Direction> dir, int distance, boolean randomSelect) {
|
|
||||||
return modifier(new FindSolidInDirection(dir, distance, randomSelect, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder heightmap() {
|
|
||||||
return modifier(PlacementUtils.HEIGHTMAP);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder heightmapTopSolid() {
|
|
||||||
return modifier(PlacementUtils.HEIGHTMAP_TOP_SOLID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BCLFeatureBuilder heightmapWorldSurface() {
|
|
||||||
return modifier(PlacementUtils.HEIGHTMAP_WORLD_SURFACE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a new {@link BCLFeature} instance. Features will be registered during this process.
|
|
||||||
*
|
|
||||||
* @param configuration any {@link FeatureConfiguration} for provided {@link Feature}.
|
|
||||||
* @return created {@link BCLFeature} instance.
|
|
||||||
*/
|
|
||||||
public BCLFeature buildAndRegister(FC configuration) {
|
|
||||||
PlacementModifier[] modifiers = modifications.toArray(new PlacementModifier[modifications.size()]);
|
|
||||||
return new BCLFeature(featureID, feature, decoration, configuration, modifiers);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a new {@link BCLFeature} instance with {@code NONE} {@link FeatureConfiguration}.
|
|
||||||
* Features will be registered during this process.
|
|
||||||
*
|
|
||||||
* @return created {@link BCLFeature} instance.
|
|
||||||
*/
|
|
||||||
public BCLFeature buildAndRegister() {
|
|
||||||
if (this.feature == Feature.SIMPLE_BLOCK && provider != null)
|
|
||||||
return buildAndRegister((FC) new SimpleBlockConfiguration(provider));
|
|
||||||
return buildAndRegister((FC) FeatureConfiguration.NONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public BCLFeature build(FC configuration) {
|
|
||||||
return buildAndRegister(configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public BCLFeature build() {
|
|
||||||
return buildAndRegister();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,255 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class FastFeatures {
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static RandomPatchConfiguration grassPatch(BlockStateProvider stateProvider, int tries) {
|
|
||||||
// return FeatureUtils.simpleRandomPatchConfiguration(
|
|
||||||
// tries,
|
|
||||||
// PlacementUtils.onlyWhenEmpty(Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(stateProvider))
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature<ScatterFeature<ScatterFeatureConfig.OnSolid>, ScatterFeatureConfig.OnSolid> vine(
|
|
||||||
// ResourceLocation location,
|
|
||||||
// boolean onFloor,
|
|
||||||
// boolean sparse,
|
|
||||||
// ScatterFeatureConfig.Builder builder
|
|
||||||
// ) {
|
|
||||||
// return scatter(location, onFloor, sparse, builder,
|
|
||||||
// org.betterx.bclib.api.v3.levelgen.features.BCLFeature.SCATTER_ON_SOLID
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature scatter(
|
|
||||||
// ResourceLocation location,
|
|
||||||
// boolean onFloor,
|
|
||||||
// boolean sparse,
|
|
||||||
// ScatterFeatureConfig.Builder builder,
|
|
||||||
// Feature scatterFeature
|
|
||||||
// ) {
|
|
||||||
// BCLFeatureBuilder fBuilder = BCLFeatureBuilder.start(location, scatterFeature);
|
|
||||||
// if (onFloor) {
|
|
||||||
// fBuilder.findSolidFloor(3).isEmptyAbove2();
|
|
||||||
// builder.onFloor();
|
|
||||||
// } else {
|
|
||||||
// fBuilder.findSolidCeil(3).isEmptyBelow2();
|
|
||||||
// builder.onCeil();
|
|
||||||
// }
|
|
||||||
// if (sparse) {
|
|
||||||
// fBuilder.onceEvery(3);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return fBuilder
|
|
||||||
// .is(BlockPredicate.ONLY_IN_AIR_PREDICATE)
|
|
||||||
// .buildAndRegister(builder.build());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature patch(ResourceLocation location, Block block) {
|
|
||||||
// return patch(location, block, 96, 7, 3);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature
|
|
||||||
// patch(ResourceLocation location, Block block, int attempts, int xzSpread, int ySpread) {
|
|
||||||
// return patch(
|
|
||||||
// location,
|
|
||||||
// attempts,
|
|
||||||
// xzSpread,
|
|
||||||
// ySpread,
|
|
||||||
// Feature.SIMPLE_BLOCK,
|
|
||||||
// new SimpleBlockConfiguration(BlockStateProvider.simple(block))
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature
|
|
||||||
// patch(ResourceLocation location, BlockStateProvider provider, int attempts, int xzSpread, int ySpread) {
|
|
||||||
// return patch(
|
|
||||||
// location,
|
|
||||||
// attempts,
|
|
||||||
// xzSpread,
|
|
||||||
// ySpread,
|
|
||||||
// Feature.SIMPLE_BLOCK,
|
|
||||||
// new SimpleBlockConfiguration(provider)
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature patchWitRandomInt(ResourceLocation location, Block block, IntegerProperty prop) {
|
|
||||||
// return patchWitRandomInt(location, block, prop, 96, 7, 3);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature
|
|
||||||
// patchWitRandomInt(
|
|
||||||
// ResourceLocation location,
|
|
||||||
// Block block,
|
|
||||||
// IntegerProperty prop,
|
|
||||||
// int attempts,
|
|
||||||
// int xzSpread,
|
|
||||||
// int ySpread
|
|
||||||
// ) {
|
|
||||||
// return patch(
|
|
||||||
// location,
|
|
||||||
// attempts,
|
|
||||||
// xzSpread,
|
|
||||||
// ySpread,
|
|
||||||
// simple(location, ySpread, false, block.defaultBlockState(), prop)
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature
|
|
||||||
// simple(
|
|
||||||
// ResourceLocation location,
|
|
||||||
// int searchDist,
|
|
||||||
// boolean rare,
|
|
||||||
// Feature<NoneFeatureConfiguration> feature
|
|
||||||
// ) {
|
|
||||||
// return simple(location, searchDist, rare, feature, NoneFeatureConfiguration.NONE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature
|
|
||||||
// single(ResourceLocation location, Block block) {
|
|
||||||
// return single(location, BlockStateProvider.simple(block));
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature
|
|
||||||
// single(ResourceLocation location, BlockStateProvider provider) {
|
|
||||||
// return BCLFeatureBuilder
|
|
||||||
// .start(location, provider)
|
|
||||||
// .buildAndRegister();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature
|
|
||||||
// simple(ResourceLocation location, Feature<NoneFeatureConfiguration> feature) {
|
|
||||||
// return BCLFeatureBuilder
|
|
||||||
// .start(location, feature)
|
|
||||||
// .buildAndRegister();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature
|
|
||||||
// simple(
|
|
||||||
// ResourceLocation location,
|
|
||||||
// int searchDist,
|
|
||||||
// boolean rare,
|
|
||||||
// BlockState baseState,
|
|
||||||
// IntegerProperty property
|
|
||||||
// ) {
|
|
||||||
// int min = Integer.MAX_VALUE;
|
|
||||||
// int max = Integer.MIN_VALUE;
|
|
||||||
//
|
|
||||||
// for (Integer i : property.getPossibleValues()) {
|
|
||||||
// if (i < min) min = i;
|
|
||||||
// if (i > max) max = i;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return simple(
|
|
||||||
// location,
|
|
||||||
// searchDist,
|
|
||||||
// rare,
|
|
||||||
// Feature.SIMPLE_BLOCK,
|
|
||||||
// new SimpleBlockConfiguration(new RandomizedIntStateProvider(
|
|
||||||
// BlockStateProvider.simple(baseState),
|
|
||||||
// property,
|
|
||||||
// UniformInt.of(min, max)
|
|
||||||
// ))
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
//
|
|
||||||
// public static <FC extends FeatureConfiguration> BCLFeature<Feature<FC>, FC>
|
|
||||||
// simple(
|
|
||||||
// ResourceLocation location,
|
|
||||||
// int searchDist,
|
|
||||||
// boolean rare,
|
|
||||||
// Feature<FC> feature,
|
|
||||||
// FC config
|
|
||||||
// ) {
|
|
||||||
// BCLFeatureBuilder builder = BCLFeatureBuilder
|
|
||||||
// .start(location, feature)
|
|
||||||
// .findSolidFloor(Math.min(12, searchDist))
|
|
||||||
// .is(BlockPredicate.ONLY_IN_AIR_PREDICATE);
|
|
||||||
// if (rare) {
|
|
||||||
// builder.onceEvery(4);
|
|
||||||
// }
|
|
||||||
// return builder.buildAndRegister(config);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature
|
|
||||||
// patch(ResourceLocation location, Feature<NoneFeatureConfiguration> feature) {
|
|
||||||
// return patch(location, 96, 7, 3, feature, FeatureConfiguration.NONE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature
|
|
||||||
// patch(
|
|
||||||
// ResourceLocation location,
|
|
||||||
// int attempts,
|
|
||||||
// int xzSpread,
|
|
||||||
// int ySpread,
|
|
||||||
// Feature<NoneFeatureConfiguration> feature
|
|
||||||
// ) {
|
|
||||||
// return patch(location, attempts, xzSpread, ySpread, feature, FeatureConfiguration.NONE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static <FC extends FeatureConfiguration> BCLFeature
|
|
||||||
// patch(
|
|
||||||
// ResourceLocation location,
|
|
||||||
// int attempts,
|
|
||||||
// int xzSpread,
|
|
||||||
// int ySpread,
|
|
||||||
// Feature<FC> feature,
|
|
||||||
// FC config
|
|
||||||
// ) {
|
|
||||||
// final BCLFeature SINGLE = simple(location, ySpread, false, feature, config);
|
|
||||||
// return patch(location, attempts, xzSpread, ySpread, SINGLE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature
|
|
||||||
// wallPatch(
|
|
||||||
// ResourceLocation location,
|
|
||||||
// Block block,
|
|
||||||
// int attempts,
|
|
||||||
// int xzSpread,
|
|
||||||
// int ySpread
|
|
||||||
// ) {
|
|
||||||
// final BCLFeature SINGLE = simple(location, ySpread, false,
|
|
||||||
// org.betterx.bclib.api.v3.levelgen.features.BCLFeature.PLACE_BLOCK,
|
|
||||||
// new PlaceFacingBlockConfig(block, PlaceFacingBlockConfig.HORIZONTAL)
|
|
||||||
// );
|
|
||||||
// return patch(location, attempts, xzSpread, ySpread, SINGLE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Deprecated(forRemoval = true)
|
|
||||||
// public static BCLFeature
|
|
||||||
// patch(
|
|
||||||
// ResourceLocation location,
|
|
||||||
// int attempts,
|
|
||||||
// int xzSpread,
|
|
||||||
// int ySpread,
|
|
||||||
// BCLFeature single
|
|
||||||
// ) {
|
|
||||||
// ResourceLocation patchLocation = new ResourceLocation(location.getNamespace(), location.getPath() + "_patch");
|
|
||||||
//
|
|
||||||
// return BCLFeatureBuilder
|
|
||||||
// .start(patchLocation, Feature.RANDOM_PATCH)
|
|
||||||
// .buildAndRegister(new RandomPatchConfiguration(attempts, xzSpread, ySpread, single.getPlacedFeature()));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param <FC>
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.UserGrowableFeature} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public interface UserGrowableFeature<FC extends FeatureConfiguration> extends org.betterx.bclib.api.v3.levelgen.features.UserGrowableFeature<FC> {
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.blockpredicates;
|
|
||||||
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.blockpredicates.BlockPredicates;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.blockpredicates.IsFullShape;
|
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
|
|
||||||
import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicateType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.blockpredicates.BlockPredicates} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class Types {
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link BlockPredicates#FULL_SHAPE} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final BlockPredicateType<IsFullShape> FULL_SHAPE = BlockPredicates.FULL_SHAPE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param location
|
|
||||||
* @param codec
|
|
||||||
* @param <P>
|
|
||||||
* @return
|
|
||||||
* @deprecated Please use {@link BlockPredicates#register(ResourceLocation, Codec)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static <P extends BlockPredicate> BlockPredicateType<P> register(ResourceLocation location, Codec<P> codec) {
|
|
||||||
return BlockPredicates.register(location, codec);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ensureStaticInitialization() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.config;
|
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.BCLFeature;
|
|
||||||
|
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementFilter;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.config.ConditionFeatureConfig} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class ConditionFeatureConfig extends org.betterx.bclib.api.v3.levelgen.features.config.ConditionFeatureConfig {
|
|
||||||
|
|
||||||
public ConditionFeatureConfig(@NotNull PlacementFilter filter, @NotNull BCLFeature okFeature) {
|
|
||||||
super(filter, okFeature);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConditionFeatureConfig(
|
|
||||||
@NotNull PlacementFilter filter,
|
|
||||||
@NotNull BCLFeature okFeature,
|
|
||||||
@NotNull BCLFeature failFeature
|
|
||||||
) {
|
|
||||||
super(filter, okFeature, failFeature);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConditionFeatureConfig(@NotNull PlacementFilter filter, @NotNull Holder<PlacedFeature> okFeature) {
|
|
||||||
super(filter, okFeature);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConditionFeatureConfig(
|
|
||||||
@NotNull PlacementFilter filter,
|
|
||||||
@NotNull Holder<PlacedFeature> okFeature,
|
|
||||||
@NotNull Holder<PlacedFeature> failFeature
|
|
||||||
) {
|
|
||||||
super(filter, okFeature, failFeature);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ConditionFeatureConfig(
|
|
||||||
@NotNull PlacementModifier filter,
|
|
||||||
@NotNull Holder<PlacedFeature> okFeature,
|
|
||||||
@NotNull Optional<Holder<PlacedFeature>> failFeature
|
|
||||||
) {
|
|
||||||
super(filter, okFeature, failFeature);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.config;
|
|
||||||
|
|
||||||
import net.minecraft.util.random.SimpleWeightedRandomList;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public abstract class PlaceBlockFeatureConfig extends org.betterx.bclib.api.v3.levelgen.features.config.PlaceBlockFeatureConfig {
|
|
||||||
|
|
||||||
public PlaceBlockFeatureConfig(Block block) {
|
|
||||||
super(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlaceBlockFeatureConfig(BlockState state) {
|
|
||||||
super(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlaceBlockFeatureConfig(List<BlockState> states) {
|
|
||||||
super(states);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlaceBlockFeatureConfig(SimpleWeightedRandomList<BlockState> blocks) {
|
|
||||||
super(blocks);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlaceBlockFeatureConfig(BlockStateProvider blocks) {
|
|
||||||
super(blocks);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.config;
|
|
||||||
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.util.random.SimpleWeightedRandomList;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.config.PlaceFacingBlockConfig} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class PlaceFacingBlockConfig extends org.betterx.bclib.api.v3.levelgen.features.config.PlaceFacingBlockConfig {
|
|
||||||
|
|
||||||
public PlaceFacingBlockConfig(Block block, List<Direction> dir) {
|
|
||||||
super(block, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlaceFacingBlockConfig(BlockState state, List<Direction> dir) {
|
|
||||||
super(state, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlaceFacingBlockConfig(List<BlockState> states, List<Direction> dir) {
|
|
||||||
super(states, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlaceFacingBlockConfig(SimpleWeightedRandomList<BlockState> blocks, List<Direction> dir) {
|
|
||||||
super(blocks, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlaceFacingBlockConfig(BlockStateProvider blocks, List<Direction> dir) {
|
|
||||||
super(blocks, dir);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.config;
|
|
||||||
|
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.config.SequenceFeatureConfig instead}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class SequenceFeatureConfig extends org.betterx.bclib.api.v3.levelgen.features.config.SequenceFeatureConfig {
|
|
||||||
|
|
||||||
public SequenceFeatureConfig(List<Holder<PlacedFeature>> features) {
|
|
||||||
super(features);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.config;
|
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.structures.StructurePlacementType;
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.structures.StructureWorldNBT;
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.config.TemplateFeatureConfig} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class TemplateFeatureConfig extends org.betterx.bclib.api.v3.levelgen.features.config.TemplateFeatureConfig {
|
|
||||||
|
|
||||||
public TemplateFeatureConfig(ResourceLocation location, int offsetY, StructurePlacementType type) {
|
|
||||||
super(location, offsetY, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TemplateFeatureConfig(List<StructureWorldNBT> structures) {
|
|
||||||
super(structures);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.features;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.features.ConditionFeature} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class ConditionFeature extends org.betterx.bclib.api.v3.levelgen.features.features.ConditionFeature {
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.features;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.features.MarkPostProcessingFeature} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class MarkPostProcessingFeature extends org.betterx.bclib.api.v3.levelgen.features.features.MarkPostProcessingFeature {
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.features;
|
|
||||||
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.config.PlaceBlockFeatureConfig;
|
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.features.PlaceBlockFeature} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class PlaceBlockFeature<FC extends PlaceBlockFeatureConfig> extends org.betterx.bclib.api.v3.levelgen.features.features.PlaceBlockFeature<FC> {
|
|
||||||
|
|
||||||
public PlaceBlockFeature(Codec<FC> codec) {
|
|
||||||
super(codec);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,249 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.features;
|
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.config.ScatterFeatureConfig;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.UserGrowableFeature;
|
|
||||||
import org.betterx.bclib.util.BlocksHelper;
|
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
|
||||||
import net.minecraft.world.level.ServerLevelAccessor;
|
|
||||||
import net.minecraft.world.level.WorldGenLevel;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class ScatterFeature<FC extends ScatterFeatureConfig>
|
|
||||||
extends Feature<FC> implements UserGrowableFeature<FC> {
|
|
||||||
|
|
||||||
public ScatterFeature(Codec<FC> configCodec) {
|
|
||||||
super(configCodec);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean place(FeaturePlaceContext<FC> featurePlaceContext) {
|
|
||||||
final WorldGenLevel level = featurePlaceContext.level();
|
|
||||||
final BlockPos origin = featurePlaceContext.origin();
|
|
||||||
final RandomSource random = featurePlaceContext.random();
|
|
||||||
|
|
||||||
ScatterFeatureConfig config = featurePlaceContext.config();
|
|
||||||
Optional<Direction> direction = getTipDirection(level, origin, random, config);
|
|
||||||
if (direction.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
BlockPos basePos = origin.relative(direction.get(), -1);
|
|
||||||
|
|
||||||
|
|
||||||
int i = (int) (random.nextFloat() * (1 + config.maxHeight - config.minHeight) + config.minHeight);
|
|
||||||
growCenterPillar(level, origin, basePos, direction.get(), i, config, random);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void growCenterPillar(
|
|
||||||
LevelAccessor level,
|
|
||||||
BlockPos origin,
|
|
||||||
BlockPos basePos,
|
|
||||||
Direction direction,
|
|
||||||
int centerHeight,
|
|
||||||
ScatterFeatureConfig config,
|
|
||||||
RandomSource random
|
|
||||||
) {
|
|
||||||
if (config.isValidBase(level.getBlockState(basePos))) {
|
|
||||||
final Direction surfaceDirection = direction.getOpposite();
|
|
||||||
BlockPos.MutableBlockPos POS = new BlockPos.MutableBlockPos();
|
|
||||||
int adaptedHeight = freeHeight(level, direction, centerHeight, config, origin);
|
|
||||||
buildPillarWithBase(level, origin, basePos, direction, adaptedHeight, config, random, false);
|
|
||||||
|
|
||||||
final double distNormalizer = (config.maxSpread * Math.sqrt(2));
|
|
||||||
final int tryCount = config.spreadCount.sample(random);
|
|
||||||
for (int i = 0; i < tryCount; i++) {
|
|
||||||
int x = origin.getX() + (int) (random.nextGaussian() * config.maxSpread);
|
|
||||||
int z = origin.getZ() + (int) (random.nextGaussian() * config.maxSpread);
|
|
||||||
POS.set(x, basePos.getY(), z);
|
|
||||||
|
|
||||||
if (BlocksHelper.findSurroundingSurface(level, POS, surfaceDirection, 4, config::isValidBase)) {
|
|
||||||
int myHeight = freeHeight(
|
|
||||||
level,
|
|
||||||
direction,
|
|
||||||
centerHeight,
|
|
||||||
config,
|
|
||||||
POS
|
|
||||||
);
|
|
||||||
|
|
||||||
int dx = x - POS.getX();
|
|
||||||
int dz = z - POS.getZ();
|
|
||||||
float sizeFactor = (1 - (float) (Math.sqrt(dx * dx + dz * dz) / distNormalizer));
|
|
||||||
sizeFactor = (1 - (random.nextFloat() * config.sizeVariation)) * sizeFactor;
|
|
||||||
myHeight = (int) Math.min(Math.max(
|
|
||||||
config.minHeight,
|
|
||||||
config.minHeight + sizeFactor * (myHeight - config.minHeight)
|
|
||||||
), config.maxHeight);
|
|
||||||
|
|
||||||
BlockState baseState = level.getBlockState(POS.relative(direction.getOpposite()));
|
|
||||||
if (!config.isValidBase(baseState)) {
|
|
||||||
System.out.println("Starting from " + baseState + " at " + POS.relative(direction.getOpposite()));
|
|
||||||
}
|
|
||||||
buildPillarWithBase(level,
|
|
||||||
POS,
|
|
||||||
POS.relative(direction.getOpposite()),
|
|
||||||
direction,
|
|
||||||
myHeight,
|
|
||||||
config,
|
|
||||||
random, false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int freeHeight(
|
|
||||||
LevelAccessor level,
|
|
||||||
Direction direction,
|
|
||||||
int defaultHeight,
|
|
||||||
ScatterFeatureConfig config,
|
|
||||||
BlockPos POS
|
|
||||||
) {
|
|
||||||
int myHeight;
|
|
||||||
if (config.growWhileFree) {
|
|
||||||
myHeight = BlocksHelper.blockCount(
|
|
||||||
level,
|
|
||||||
POS,
|
|
||||||
direction,
|
|
||||||
config.maxHeight,
|
|
||||||
BlocksHelper::isFree
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
myHeight = defaultHeight;
|
|
||||||
}
|
|
||||||
return Math.max(config.minHeight, myHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildPillarWithBase(
|
|
||||||
LevelAccessor level,
|
|
||||||
BlockPos origin,
|
|
||||||
BlockPos basePos,
|
|
||||||
Direction direction,
|
|
||||||
int height,
|
|
||||||
ScatterFeatureConfig config,
|
|
||||||
RandomSource random,
|
|
||||||
boolean force
|
|
||||||
) {
|
|
||||||
if (force || BlocksHelper.isFreeSpace(level, origin, direction, height, BlocksHelper::isFree)) {
|
|
||||||
createPatchOfBaseBlocks(level, random, basePos, config);
|
|
||||||
BlockState bottom = config.bottomBlock.getState(random, origin);
|
|
||||||
if (bottom.canSurvive(level, origin)) {
|
|
||||||
buildPillar(level, origin, direction, height, config, random);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildPillar(
|
|
||||||
LevelAccessor level,
|
|
||||||
BlockPos origin,
|
|
||||||
Direction direction,
|
|
||||||
int height,
|
|
||||||
ScatterFeatureConfig config,
|
|
||||||
RandomSource random
|
|
||||||
) {
|
|
||||||
|
|
||||||
final BlockPos.MutableBlockPos POS = origin.mutable();
|
|
||||||
for (int size = 0; size < height; size++) {
|
|
||||||
BlockState state = config.createBlock(size, height - 1, random, POS);
|
|
||||||
BlocksHelper.setWithoutUpdate(level, POS, state);
|
|
||||||
POS.move(direction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Optional<Direction> getTipDirection(
|
|
||||||
LevelAccessor levelAccessor,
|
|
||||||
BlockPos blockPos,
|
|
||||||
RandomSource randomSource,
|
|
||||||
ScatterFeatureConfig config
|
|
||||||
) {
|
|
||||||
boolean onCeil = config.floorChance < 1 && config.isValidBase(levelAccessor.getBlockState(blockPos.above()));
|
|
||||||
boolean onFloor = config.floorChance > 0 && config.isValidBase(levelAccessor.getBlockState(blockPos.below()));
|
|
||||||
|
|
||||||
if (onCeil && onFloor) {
|
|
||||||
return Optional.of(config.isFloor(randomSource) ? Direction.DOWN : Direction.UP);
|
|
||||||
}
|
|
||||||
if (onCeil) {
|
|
||||||
return Optional.of(Direction.DOWN);
|
|
||||||
}
|
|
||||||
if (onFloor) {
|
|
||||||
return Optional.of(Direction.UP);
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createPatchOfBaseBlocks(
|
|
||||||
LevelAccessor levelAccessor,
|
|
||||||
RandomSource randomSource,
|
|
||||||
BlockPos blockPos,
|
|
||||||
ScatterFeatureConfig config
|
|
||||||
) {
|
|
||||||
if (config.baseState.isPresent() && config.baseReplaceChance > 0 && randomSource.nextFloat() < config.baseReplaceChance) {
|
|
||||||
final BlockState baseState = config.baseState.get();
|
|
||||||
BlockPos pos;
|
|
||||||
for (Direction direction : Direction.Plane.HORIZONTAL) {
|
|
||||||
if (randomSource.nextFloat() > config.chanceOfDirectionalSpread) continue;
|
|
||||||
pos = blockPos.relative(direction);
|
|
||||||
placeBaseBlockIfPossible(levelAccessor, pos, baseState);
|
|
||||||
|
|
||||||
if (randomSource.nextFloat() > config.chanceOfSpreadRadius2) continue;
|
|
||||||
pos = pos.relative(Direction.getRandom(randomSource));
|
|
||||||
placeBaseBlockIfPossible(levelAccessor, pos, baseState);
|
|
||||||
|
|
||||||
if (randomSource.nextFloat() > config.chanceOfSpreadRadius3) continue;
|
|
||||||
pos = pos.relative(Direction.getRandom(randomSource));
|
|
||||||
placeBaseBlockIfPossible(levelAccessor, pos, baseState);
|
|
||||||
}
|
|
||||||
placeBaseBlockIfPossible(levelAccessor, blockPos, baseState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void placeBaseBlockIfPossible(
|
|
||||||
LevelAccessor levelAccessor,
|
|
||||||
BlockPos blockPos,
|
|
||||||
BlockState baseState
|
|
||||||
) {
|
|
||||||
BlockState blockState = levelAccessor.getBlockState(blockPos);
|
|
||||||
if (BlocksHelper.isTerrain(blockState)) {
|
|
||||||
levelAccessor.setBlock(blockPos, baseState, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean grow(
|
|
||||||
ServerLevelAccessor level,
|
|
||||||
BlockPos origin,
|
|
||||||
RandomSource random,
|
|
||||||
FC config
|
|
||||||
) {
|
|
||||||
Optional<Direction> oDirection = getTipDirection(level, origin, random, config);
|
|
||||||
if (oDirection.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Direction direction = oDirection.get();
|
|
||||||
BlockPos basePos = origin.relative(direction, -1);
|
|
||||||
|
|
||||||
if (config.isValidBase(level.getBlockState(basePos))) {
|
|
||||||
int centerHeight = (int) (random.nextFloat() * (1 + config.maxHeight - config.minHeight) + config.minHeight);
|
|
||||||
centerHeight = freeHeight(
|
|
||||||
level,
|
|
||||||
direction,
|
|
||||||
centerHeight,
|
|
||||||
config,
|
|
||||||
origin.relative(direction, 1)
|
|
||||||
) + 1;
|
|
||||||
buildPillarWithBase(level, origin, basePos, direction, centerHeight, config, random, true);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.features;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.features.SequenceFeature} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class SequenceFeature extends org.betterx.bclib.api.v3.levelgen.features.features.SequenceFeature {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.features;
|
|
||||||
|
|
||||||
import org.betterx.bclib.util.BlocksHelper;
|
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public abstract class SurfaceFeature<T extends FeatureConfiguration> extends Feature<T> {
|
|
||||||
public static abstract class DefaultConfiguration extends SurfaceFeature<NoneFeatureConfiguration> {
|
|
||||||
protected DefaultConfiguration() {
|
|
||||||
super(NoneFeatureConfiguration.CODEC);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SurfaceFeature(Codec<T> codec) {
|
|
||||||
super(codec);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract boolean isValidSurface(BlockState state);
|
|
||||||
|
|
||||||
protected int minHeight(FeaturePlaceContext<T> ctx) {
|
|
||||||
return ctx.chunkGenerator().getSeaLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean place(FeaturePlaceContext<T> ctx) {
|
|
||||||
Optional<BlockPos> pos = BlocksHelper.findSurfaceBelow(
|
|
||||||
ctx.level(),
|
|
||||||
ctx.origin(),
|
|
||||||
minHeight(ctx),
|
|
||||||
this::isValidSurface
|
|
||||||
);
|
|
||||||
if (pos.isPresent()) {
|
|
||||||
generate(pos.get(), ctx);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void generate(BlockPos centerPos, FeaturePlaceContext<T> ctx);
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.features;
|
|
||||||
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.config.TemplateFeatureConfig;
|
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.features.TemplateFeature} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class TemplateFeature<FC extends TemplateFeatureConfig> extends org.betterx.bclib.api.v3.levelgen.features.features.TemplateFeature<FC> {
|
|
||||||
|
|
||||||
public TemplateFeature(Codec<FC> codec) {
|
|
||||||
super(codec);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.features;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
import net.minecraft.world.level.WorldGenLevel;
|
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.WeightedPlacedFeature;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.RandomFeatureConfiguration;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
|
||||||
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class WeightedRandomSelectorFeature extends Feature<RandomFeatureConfiguration> {
|
|
||||||
public WeightedRandomSelectorFeature() {
|
|
||||||
super(RandomFeatureConfiguration.CODEC);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean place(FeaturePlaceContext<RandomFeatureConfiguration> ctx) {
|
|
||||||
final WorldGenLevel level = ctx.level();
|
|
||||||
final ChunkGenerator generator = ctx.chunkGenerator();
|
|
||||||
final RandomFeatureConfiguration cfg = ctx.config();
|
|
||||||
final RandomSource random = ctx.random();
|
|
||||||
final BlockPos pos = ctx.origin();
|
|
||||||
|
|
||||||
PlacedFeature selected = cfg.defaultFeature.value();
|
|
||||||
if (!cfg.features.isEmpty()) {
|
|
||||||
final float totalWeight = cfg.features.stream().map(w -> w.chance).reduce(0.0f, (p, c) -> p + c);
|
|
||||||
float bar = random.nextFloat() * totalWeight;
|
|
||||||
|
|
||||||
for (WeightedPlacedFeature f : cfg.features) {
|
|
||||||
selected = f.feature.value();
|
|
||||||
bar -= f.chance;
|
|
||||||
if (bar < 0) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return selected.place(level, generator, random, pos);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.All} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class All extends org.betterx.bclib.api.v3.levelgen.features.placement.All {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.Debug} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class Debug extends org.betterx.bclib.api.v3.levelgen.features.placement.Debug {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.util.valueproviders.IntProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.Extend} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class Extend extends org.betterx.bclib.api.v3.levelgen.features.placement.Extend {
|
|
||||||
public Extend(Direction direction, IntProvider length) {
|
|
||||||
super(direction, length);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.FindSolidInDirection} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class FindSolidInDirection extends org.betterx.bclib.api.v3.levelgen.features.placement.FindSolidInDirection {
|
|
||||||
|
|
||||||
|
|
||||||
public FindSolidInDirection(Direction direction, int maxSearchDistance) {
|
|
||||||
super(direction, maxSearchDistance, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FindSolidInDirection(List<Direction> direction, int maxSearchDistance) {
|
|
||||||
super(direction, maxSearchDistance, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FindSolidInDirection(List<Direction> direction, int maxSearchDistance, boolean randomSelect) {
|
|
||||||
super(direction, maxSearchDistance, randomSelect, 0);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.ForAll} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class ForAll extends org.betterx.bclib.api.v3.levelgen.features.placement.ForAll {
|
|
||||||
|
|
||||||
public ForAll(List<PlacementModifier> modifiers) {
|
|
||||||
super(modifiers);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
import net.minecraft.core.Vec3i;
|
|
||||||
import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.Is} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class Is extends org.betterx.bclib.api.v3.levelgen.features.placement.Is {
|
|
||||||
|
|
||||||
public Is(BlockPredicate predicate, Optional<Vec3i> offset) {
|
|
||||||
super(predicate, offset);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.IsBasin} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class IsBasin extends org.betterx.bclib.api.v3.levelgen.features.placement.IsBasin {
|
|
||||||
|
|
||||||
public IsBasin(BlockPredicate predicate) {
|
|
||||||
super(predicate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IsBasin(BlockPredicate predicate, Optional<BlockPredicate> topPredicate) {
|
|
||||||
super(predicate, topPredicate);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
import net.minecraft.world.level.WorldGenLevel;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementContext;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementFilter;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementModifierType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests if there is air at two locations above the tested block position
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class IsEmptyAboveSampledFilter extends PlacementFilter {
|
|
||||||
private static final IsEmptyAboveSampledFilter DEFAULT = new IsEmptyAboveSampledFilter(4, 2);
|
|
||||||
private static final IsEmptyAboveSampledFilter DEFAULT1 = new IsEmptyAboveSampledFilter(1, 1);
|
|
||||||
private static final IsEmptyAboveSampledFilter DEFAULT2 = new IsEmptyAboveSampledFilter(1, 2);
|
|
||||||
|
|
||||||
private static final IsEmptyAboveSampledFilter BELOW_DEFAULT = new IsEmptyAboveSampledFilter(-4, -2);
|
|
||||||
private static final IsEmptyAboveSampledFilter BELOW_DEFAULT1 = new IsEmptyAboveSampledFilter(-1, -1);
|
|
||||||
private static final IsEmptyAboveSampledFilter BELOW_DEFAULT2 = new IsEmptyAboveSampledFilter(-1, -2);
|
|
||||||
public static final Codec<IsEmptyAboveSampledFilter> CODEC = RecordCodecBuilder.create((instance) -> instance
|
|
||||||
.group(
|
|
||||||
Codec.intRange(-32, 32).fieldOf("d1").orElse(4).forGetter((p) -> p.distance1),
|
|
||||||
Codec.intRange(-32, 32).fieldOf("d2").orElse(2).forGetter((p) -> p.distance1)
|
|
||||||
)
|
|
||||||
.apply(instance, IsEmptyAboveSampledFilter::new));
|
|
||||||
|
|
||||||
public static PlacementFilter emptyAbove4() {
|
|
||||||
return DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlacementFilter emptyAbove2() {
|
|
||||||
return DEFAULT2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlacementFilter emptyAbove() {
|
|
||||||
return DEFAULT1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlacementFilter emptyBelow4() {
|
|
||||||
return BELOW_DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlacementFilter emptyBelow2() {
|
|
||||||
return BELOW_DEFAULT2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlacementFilter emptyBelow() {
|
|
||||||
return BELOW_DEFAULT1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IsEmptyAboveSampledFilter(int d1, int d2) {
|
|
||||||
this.distance1 = d1;
|
|
||||||
this.distance2 = d2;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final int distance1;
|
|
||||||
private final int distance2;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean shouldPlace(PlacementContext ctx, RandomSource random, BlockPos pos) {
|
|
||||||
WorldGenLevel level = ctx.getLevel();
|
|
||||||
return level.isEmptyBlock(pos.above(distance1))
|
|
||||||
&& (distance1 == distance2 || level.isEmptyBlock(pos.above(distance2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PlacementModifierType<?> type() {
|
|
||||||
return PlacementModifiers.IS_EMPTY_ABOVE_SAMPLED_FILTER;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
import org.betterx.bclib.util.BlocksHelper;
|
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementContext;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementFilter;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementModifierType;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class MinEmptyFilter extends PlacementFilter {
|
|
||||||
private static final MinEmptyFilter DOWN = new MinEmptyFilter(Direction.DOWN, 2);
|
|
||||||
private static final MinEmptyFilter UP = new MinEmptyFilter(Direction.UP, 2);
|
|
||||||
public static final Codec<MinEmptyFilter> CODEC = RecordCodecBuilder.create((instance) -> instance
|
|
||||||
.group(
|
|
||||||
Direction.CODEC.fieldOf("dir").orElse(Direction.DOWN).forGetter((p) -> p.direction),
|
|
||||||
Codec.intRange(1, 32).fieldOf("dist").orElse(12).forGetter((p) -> p.distance)
|
|
||||||
)
|
|
||||||
.apply(instance, MinEmptyFilter::new));
|
|
||||||
|
|
||||||
private final Direction direction;
|
|
||||||
private final int distance;
|
|
||||||
|
|
||||||
protected MinEmptyFilter(Direction direction, int distance) {
|
|
||||||
this.direction = direction;
|
|
||||||
this.distance = distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlacementModifier down() {
|
|
||||||
return DOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlacementModifier down(int dist) {
|
|
||||||
return new MinEmptyFilter(Direction.DOWN, dist);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlacementModifier up() {
|
|
||||||
return UP;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlacementModifier up(int dist) {
|
|
||||||
return new MinEmptyFilter(Direction.UP, dist);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean shouldPlace(PlacementContext ctx, RandomSource randomSource, BlockPos pos) {
|
|
||||||
return BlocksHelper.isFreeSpace(
|
|
||||||
ctx.getLevel(),
|
|
||||||
pos.relative(direction),
|
|
||||||
direction,
|
|
||||||
distance - 1,
|
|
||||||
BlocksHelper::isFree
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PlacementModifierType<?> type() {
|
|
||||||
return PlacementModifiers.MIN_EMPTY_FILTER;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
import net.minecraft.core.Vec3i;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.Offset} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class Offset extends org.betterx.bclib.api.v3.levelgen.features.placement.Offset {
|
|
||||||
|
|
||||||
public Offset(Vec3i offset) {
|
|
||||||
super(offset);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.OnEveryLayer} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class OnEveryLayer extends org.betterx.bclib.api.v3.levelgen.features.placement.OnEveryLayer {
|
|
||||||
|
|
||||||
protected OnEveryLayer(Optional<Integer> minHeight, Optional<Integer> maxHeight) {
|
|
||||||
super(minHeight, maxHeight);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,133 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
import org.betterx.bclib.BCLib;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.placement.All;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.placement.Debug;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.placement.Extend;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.placement.FindSolidInDirection;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.placement.ForAll;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.placement.Is;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.placement.IsBasin;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.placement.Offset;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.placement.OnEveryLayer;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.placement.Stencil;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.placement.UnderEveryLayer;
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.placement.*;
|
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacementModifierType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class PlacementModifiers {
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers#NOISE_FILTER} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final PlacementModifierType<NoiseFilter> NOISE_FILTER = org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers.NOISE_FILTER;
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers#DEBUG} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final PlacementModifierType<Debug> DEBUG = org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers.DEBUG;
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final PlacementModifierType<IsEmptyAboveSampledFilter> IS_EMPTY_ABOVE_SAMPLED_FILTER = register(
|
|
||||||
"is_empty_above_sampled_filter",
|
|
||||||
IsEmptyAboveSampledFilter.CODEC
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final PlacementModifierType<MinEmptyFilter> MIN_EMPTY_FILTER = register(
|
|
||||||
"min_empty_filter",
|
|
||||||
MinEmptyFilter.CODEC
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers#FOR_ALL} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final PlacementModifierType<ForAll> FOR_ALL = org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers.FOR_ALL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers#SOLID_IN_DIR} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final PlacementModifierType<FindSolidInDirection> SOLID_IN_DIR = org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers.SOLID_IN_DIR;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers#STENCIL} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final PlacementModifierType<Stencil> STENCIL = org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers.STENCIL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers#ALL} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final PlacementModifierType<All> ALL = org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers.ALL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers#IS_BASIN} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final PlacementModifierType<IsBasin> IS_BASIN = org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers.IS_BASIN;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers#IS} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final PlacementModifierType<Is> IS = org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers.IS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers#OFFSET} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final PlacementModifierType<Offset> OFFSET = org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers.OFFSET;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers#EXTEND} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final PlacementModifierType<Extend> EXTEND = org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers.EXTEND;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers#ON_EVERY_LAYER} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final PlacementModifierType<OnEveryLayer> ON_EVERY_LAYER = org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers.ON_EVERY_LAYER;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers#UNDER_EVERY_LAYER} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final PlacementModifierType<UnderEveryLayer> UNDER_EVERY_LAYER = org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers.UNDER_EVERY_LAYER;
|
|
||||||
|
|
||||||
private static <P extends PlacementModifier> PlacementModifierType<P> register(String path, Codec<P> codec) {
|
|
||||||
return register(BCLib.makeID(path), codec);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param location
|
|
||||||
* @param codec
|
|
||||||
* @param <P>
|
|
||||||
* @return
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers#register(ResourceLocation, Codec)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static <P extends PlacementModifier> PlacementModifierType<P> register(
|
|
||||||
ResourceLocation location,
|
|
||||||
Codec<P> codec
|
|
||||||
) {
|
|
||||||
return org.betterx.bclib.api.v3.levelgen.features.placement.PlacementModifiers.register(location, codec);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void ensureStaticInitialization() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.Stencil} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class Stencil extends org.betterx.bclib.api.v3.levelgen.features.placement.Stencil {
|
|
||||||
|
|
||||||
public Stencil(Boolean[] stencil, int selectOneIn) {
|
|
||||||
super(stencil, selectOneIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Stencil(List<Boolean> stencil, int selectOneIn) {
|
|
||||||
super(stencil, selectOneIn);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.levelgen.features.placement;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.placement.UnderEveryLayer} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class UnderEveryLayer
|
|
||||||
extends org.betterx.bclib.api.v3.levelgen.features.placement.UnderEveryLayer {
|
|
||||||
|
|
||||||
protected UnderEveryLayer(Optional<Integer> minHeight, Optional<Integer> maxHeight) {
|
|
||||||
super(minHeight, maxHeight);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,6 @@ package org.betterx.bclib.api.v2.poi;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.tags.TagKey;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.entity.ai.village.poi.PoiManager;
|
import net.minecraft.world.entity.ai.village.poi.PoiManager;
|
||||||
|
@ -97,22 +96,4 @@ public class BCLPoiType {
|
||||||
|
|
||||||
return record.map(poiRecord -> poiRecord.getPos());
|
return record.map(poiRecord -> poiRecord.getPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param location
|
|
||||||
* @param matchingStates
|
|
||||||
* @param maxTickets
|
|
||||||
* @param validRanges
|
|
||||||
* @return
|
|
||||||
* @deprecated Please use {@link org.betterx.bclib.api.v2.poi.PoiManager#register(ResourceLocation, Set, int, int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static BCLPoiType register(
|
|
||||||
ResourceLocation location,
|
|
||||||
Set<BlockState> matchingStates,
|
|
||||||
int maxTickets,
|
|
||||||
int validRanges
|
|
||||||
) {
|
|
||||||
return org.betterx.bclib.api.v2.poi.PoiManager.register(location, matchingStates, maxTickets, validRanges);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.tag;
|
|
||||||
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.world.level.biome.Biome;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBiomeTags}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class CommonBiomeTags {
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBiomeTags#IN_NETHER}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Biome> IN_NETHER = org.betterx.worlds.together.tag.v3.CommonBiomeTags.IN_NETHER;
|
|
||||||
}
|
|
|
@ -1,131 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.tag;
|
|
||||||
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class CommonBlockTags {
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#BARREL}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> BARREL = org.betterx.worlds.together.tag.v3.CommonBlockTags.BARREL;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#BOOKSHELVES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> BOOKSHELVES = org.betterx.worlds.together.tag.v3.CommonBlockTags.BOOKSHELVES;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#CHEST}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> CHEST = org.betterx.worlds.together.tag.v3.CommonBlockTags.CHEST;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#END_STONES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> END_STONES = org.betterx.worlds.together.tag.v3.CommonBlockTags.END_STONES;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#GEN_END_STONES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> GEN_END_STONES = org.betterx.worlds.together.tag.v3.CommonBlockTags.GEN_END_STONES;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#IMMOBILE}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> IMMOBILE = org.betterx.worlds.together.tag.v3.CommonBlockTags.IMMOBILE;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#LEAVES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> LEAVES = org.betterx.worlds.together.tag.v3.CommonBlockTags.LEAVES;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#NETHERRACK}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> NETHERRACK = org.betterx.worlds.together.tag.v3.CommonBlockTags.NETHERRACK;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#MYCELIUM}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> MYCELIUM = org.betterx.worlds.together.tag.v3.CommonBlockTags.MYCELIUM;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#NETHER_MYCELIUM}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> NETHER_MYCELIUM = org.betterx.worlds.together.tag.v3.CommonBlockTags.NETHER_MYCELIUM;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#NETHER_PORTAL_FRAME}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> NETHER_PORTAL_FRAME = org.betterx.worlds.together.tag.v3.CommonBlockTags.NETHER_PORTAL_FRAME;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#NETHER_STONES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> NETHER_STONES = org.betterx.worlds.together.tag.v3.CommonBlockTags.NETHER_STONES;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#NETHER_ORES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> NETHER_ORES = org.betterx.worlds.together.tag.v3.CommonBlockTags.NETHER_ORES;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#END_ORES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> END_ORES = org.betterx.worlds.together.tag.v3.CommonBlockTags.END_ORES;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#SAPLINGS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> SAPLINGS = org.betterx.worlds.together.tag.v3.CommonBlockTags.SAPLINGS;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#SOUL_GROUND}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> SOUL_GROUND = org.betterx.worlds.together.tag.v3.CommonBlockTags.SOUL_GROUND;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#WOODEN_BARREL}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> WOODEN_BARREL = org.betterx.worlds.together.tag.v3.CommonBlockTags.WOODEN_BARREL;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#WOODEN_CHEST}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> WOODEN_CHEST = org.betterx.worlds.together.tag.v3.CommonBlockTags.WOODEN_CHEST;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#WORKBENCHES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> WORKBENCHES = org.betterx.worlds.together.tag.v3.CommonBlockTags.WORKBENCHES;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#DRAGON_IMMUNE}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> DRAGON_IMMUNE = org.betterx.worlds.together.tag.v3.CommonBlockTags.DRAGON_IMMUNE;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#MINABLE_WITH_HAMMER}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> MINABLE_WITH_HAMMER = org.betterx.worlds.together.tag.v3.CommonBlockTags.MINABLE_WITH_HAMMER;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#IS_OBSIDIAN}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> IS_OBSIDIAN = org.betterx.worlds.together.tag.v3.CommonBlockTags.IS_OBSIDIAN;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#TERRAIN}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> TERRAIN = org.betterx.worlds.together.tag.v3.CommonBlockTags.TERRAIN;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonBlockTags#NETHER_TERRAIN}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> NETHER_TERRAIN = org.betterx.worlds.together.tag.v3.CommonBlockTags.NETHER_TERRAIN;
|
|
||||||
}
|
|
|
@ -1,73 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.tag;
|
|
||||||
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonItemTags}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class CommonItemTags {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonItemTags#HAMMERS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public final static TagKey<Item> HAMMERS = org.betterx.worlds.together.tag.v3.CommonItemTags.HAMMERS;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonItemTags#BARREL}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> BARREL = org.betterx.worlds.together.tag.v3.CommonItemTags.BARREL;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonItemTags#CHEST}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> CHEST = org.betterx.worlds.together.tag.v3.CommonItemTags.CHEST;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonItemTags#SHEARS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> SHEARS = org.betterx.worlds.together.tag.v3.CommonItemTags.SHEARS;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonItemTags#FURNACES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> FURNACES = org.betterx.worlds.together.tag.v3.CommonItemTags.FURNACES;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonItemTags#IRON_INGOTS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> IRON_INGOTS = org.betterx.worlds.together.tag.v3.CommonItemTags.IRON_INGOTS;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonItemTags#LEAVES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> LEAVES = org.betterx.worlds.together.tag.v3.CommonItemTags.LEAVES;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonItemTags#SAPLINGS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> SAPLINGS = org.betterx.worlds.together.tag.v3.CommonItemTags.SAPLINGS;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonItemTags#SOUL_GROUND}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> SOUL_GROUND = org.betterx.worlds.together.tag.v3.CommonItemTags.SOUL_GROUND;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonItemTags#WOODEN_BARREL}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> WOODEN_BARREL = org.betterx.worlds.together.tag.v3.CommonItemTags.WOODEN_BARREL;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonItemTags#WOODEN_CHEST}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> WOODEN_CHEST = org.betterx.worlds.together.tag.v3.CommonItemTags.WOODEN_CHEST;
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.v3.CommonItemTags#WORKBENCHES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> WORKBENCHES = org.betterx.worlds.together.tag.v3.CommonItemTags.WORKBENCHES;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,162 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.tag;
|
|
||||||
|
|
||||||
import net.minecraft.tags.BlockTags;
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link BlockTags}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class NamedBlockTags {
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#ANVIL}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> ANVIL = BlockTags.ANVIL;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#BUTTONS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> BUTTONS = BlockTags.BUTTONS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#CLIMBABLE}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> CLIMBABLE = BlockTags.CLIMBABLE;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#DOORS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> DOORS = BlockTags.DOORS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#FENCES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> FENCES = BlockTags.FENCES;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#FENCE_GATES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> FENCE_GATES = BlockTags.FENCE_GATES;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#LEAVES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> LEAVES = BlockTags.LEAVES;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#LOGS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> LOGS = BlockTags.LOGS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#LOGS_THAT_BURN}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> LOGS_THAT_BURN = BlockTags.LOGS_THAT_BURN;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#NYLIUM}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> NYLIUM = BlockTags.NYLIUM;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#PLANKS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> PLANKS = BlockTags.PLANKS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#PRESSURE_PLATES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> PRESSURE_PLATES = BlockTags.PRESSURE_PLATES;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#SAPLINGS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> SAPLINGS = BlockTags.SAPLINGS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#SIGNS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> SIGNS = BlockTags.SIGNS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#SLABS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> SLABS = BlockTags.SLABS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#STAIRS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> STAIRS = BlockTags.STAIRS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#STONE_PRESSURE_PLATES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> STONE_PRESSURE_PLATES = BlockTags.STONE_PRESSURE_PLATES;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#TRAPDOORS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> TRAPDOORS = BlockTags.TRAPDOORS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WALLS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> WALLS = BlockTags.WALLS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_BUTTONS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> WOODEN_BUTTONS = BlockTags.WOODEN_BUTTONS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_DOORS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> WOODEN_DOORS = BlockTags.WOODEN_DOORS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_FENCES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> WOODEN_FENCES = BlockTags.WOODEN_FENCES;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_PRESSURE_PLATES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> WOODEN_PRESSURE_PLATES = BlockTags.WOODEN_PRESSURE_PLATES;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_SLABS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> WOODEN_SLABS = BlockTags.WOODEN_SLABS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_STAIRS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> WOODEN_STAIRS = BlockTags.WOODEN_STAIRS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_TRAPDOORS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> WOODEN_TRAPDOORS = BlockTags.WOODEN_TRAPDOORS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#SOUL_FIRE_BASE_BLOCKS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> SOUL_FIRE_BASE_BLOCKS = BlockTags.SOUL_FIRE_BASE_BLOCKS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#SOUL_SPEED_BLOCKS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> SOUL_SPEED_BLOCKS = BlockTags.SOUL_SPEED_BLOCKS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#BEACON_BASE_BLOCKS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> BEACON_BASE_BLOCKS = BlockTags.BEACON_BASE_BLOCKS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#STONE_BRICKS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> STONE_BRICKS = BlockTags.STONE_BRICKS;
|
|
||||||
}
|
|
|
@ -1,128 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.tag;
|
|
||||||
|
|
||||||
import net.minecraft.tags.ItemTags;
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link ItemTags}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class NamedItemTags {
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#BUTTONS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> BUTTONS = ItemTags.BUTTONS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#DOORS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> DOORS = ItemTags.DOORS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#FENCES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> FENCES = ItemTags.FENCES;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#LEAVES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> LEAVES = ItemTags.LEAVES;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#LOGS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> LOGS = ItemTags.LOGS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#LOGS_THAT_BURN}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> LOGS_THAT_BURN = ItemTags.LOGS_THAT_BURN;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#PLANKS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> PLANKS = ItemTags.PLANKS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#SAPLINGS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> SAPLINGS = ItemTags.SAPLINGS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#SIGNS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> SIGNS = ItemTags.SIGNS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#SLABS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> SLABS = ItemTags.SLABS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#STAIRS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> STAIRS = ItemTags.STAIRS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#TRAPDOORS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> TRAPDOORS = ItemTags.TRAPDOORS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#WOODEN_BUTTONS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> WOODEN_BUTTONS = ItemTags.WOODEN_BUTTONS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#WOODEN_DOORS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> WOODEN_DOORS = ItemTags.WOODEN_DOORS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#WOODEN_FENCES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> WOODEN_FENCES = ItemTags.WOODEN_FENCES;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#WOODEN_PRESSURE_PLATES}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> WOODEN_PRESSURE_PLATES = ItemTags.WOODEN_PRESSURE_PLATES;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#WOODEN_SLABS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> WOODEN_SLABS = ItemTags.WOODEN_SLABS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#WOODEN_STAIRS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> WOODEN_STAIRS = ItemTags.WOODEN_STAIRS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#WOODEN_TRAPDOORS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> WOODEN_TRAPDOORS = ItemTags.WOODEN_TRAPDOORS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#BEACON_PAYMENT_ITEMS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> BEACON_PAYMENT_ITEMS = ItemTags.BEACON_PAYMENT_ITEMS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#STONE_BRICKS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> STONE_BRICKS = ItemTags.STONE_BRICKS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#STONE_CRAFTING_MATERIALS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> STONE_CRAFTING_MATERIALS = ItemTags.STONE_CRAFTING_MATERIALS;
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link net.minecraft.tags.ItemTags#STONE_TOOL_MATERIALS}
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> STONE_TOOL_MATERIALS = ItemTags.STONE_TOOL_MATERIALS;
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.tag;
|
|
||||||
|
|
||||||
import org.betterx.worlds.together.tag.v3.MineableTags;
|
|
||||||
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link MineableTags}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class NamedMineableTags {
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link MineableTags#AXE} instead
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> AXE = MineableTags.AXE;
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link MineableTags#HOE} instead
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> HOE = MineableTags.HOE;
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link MineableTags#PICKAXE} instead
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> PICKAXE = MineableTags.PICKAXE;
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link MineableTags#SHEARS} instead
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> SHEARS = MineableTags.SHEARS;
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link MineableTags#SHOVEL} instead
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> SHOVEL = MineableTags.SHOVEL;
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link MineableTags#SWORD} instead
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> SWORD = MineableTags.SWORD;
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link MineableTags#HAMMER} instead
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Block> HAMMER = MineableTags.HAMMER;
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.tag;
|
|
||||||
|
|
||||||
import org.betterx.worlds.together.tag.v3.ToolTags;
|
|
||||||
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link ToolTags}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class NamedToolTags {
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link ToolTags#FABRIC_AXES} instead
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> FABRIC_AXES = ToolTags.FABRIC_AXES;
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link ToolTags#FABRIC_HOES} instead
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> FABRIC_HOES = ToolTags.FABRIC_HOES;
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link ToolTags#FABRIC_PICKAXES} instead
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> FABRIC_PICKAXES = ToolTags.FABRIC_PICKAXES;
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link ToolTags#FABRIC_SHEARS} instead
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> FABRIC_SHEARS = ToolTags.FABRIC_SHEARS;
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link ToolTags#FABRIC_SHOVELS} instead
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> FABRIC_SHOVELS = ToolTags.FABRIC_SHOVELS;
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link ToolTags#FABRIC_SWORDS} instead
|
|
||||||
**/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static final TagKey<Item> FABRIC_SWORDS = ToolTags.FABRIC_SWORDS;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,282 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.tag;
|
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
|
||||||
import org.betterx.worlds.together.mixin.common.DiggerItemAccessor;
|
|
||||||
import org.betterx.worlds.together.tag.v3.TagManager;
|
|
||||||
import org.betterx.worlds.together.tag.v3.TagRegistry;
|
|
||||||
|
|
||||||
import net.minecraft.core.DefaultedRegistry;
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.tags.TagLoader;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.ItemLike;
|
|
||||||
import net.minecraft.world.level.biome.Biome;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagManager}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class TagAPI {
|
|
||||||
private static final Map<String, TagType<?>> TYPES = Maps.newHashMap();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagManager#BLOCKS}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static TagType.RegistryBacked<Block> BLOCKS = registerType(Registry.BLOCK);
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagManager#ITEMS}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static TagType.RegistryBacked<Item> ITEMS = registerType(Registry.ITEM);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagManager#BIOMES}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static TagType.Simple<Biome> BIOMES = registerType(
|
|
||||||
Registry.BIOME_REGISTRY,
|
|
||||||
"tags/worldgen/biome",
|
|
||||||
b -> BiomeAPI.getBiomeID(b)
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagManager#registerType(DefaultedRegistry)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static <T> TagType.RegistryBacked<T> registerType(DefaultedRegistry<T> registry) {
|
|
||||||
TagType<T> type = new TagType.RegistryBacked<>(registry);
|
|
||||||
return (TagType.RegistryBacked<T>) TYPES.computeIfAbsent(type.directory, (dir) -> type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagManager#registerType(Registry, String)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static <T> TagType.Simple<T> registerType(Registry<T> registry, String directory) {
|
|
||||||
return registerType(registry.key(), directory, (o) -> registry.getKey(o));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagManager#registerType(ResourceKey, String, Function)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static <T> TagType.Simple<T> registerType(
|
|
||||||
ResourceKey<? extends Registry<T>> registry,
|
|
||||||
String directory,
|
|
||||||
Function<T, ResourceLocation> locationProvider
|
|
||||||
) {
|
|
||||||
return (TagType.Simple<T>) TYPES.computeIfAbsent(
|
|
||||||
directory,
|
|
||||||
(dir) -> new TagType.Simple<>(
|
|
||||||
registry,
|
|
||||||
dir,
|
|
||||||
locationProvider
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagManager#registerType(ResourceKey, String)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static <T> TagType.UnTyped<T> registerType(ResourceKey<? extends Registry<T>> registry, String directory) {
|
|
||||||
return (TagType.UnTyped<T>) TYPES.computeIfAbsent(directory, (dir) -> new TagType.UnTyped<>(registry, dir));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagRegistry#makeTag(String, String)} on {@link TagManager#BIOMES}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static TagKey<Biome> makeBiomeTag(String modID, String name) {
|
|
||||||
return TagManager.BIOMES.makeTag(new ResourceLocation(modID, name));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagRegistry.Biomes#makeStructureTag(String, String)} on {@link TagManager#BIOMES}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static TagKey<Biome> makeStructureTag(String modID, String name) {
|
|
||||||
return TagManager.BIOMES.makeStructureTag(modID, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagRegistry#makeTag(String, String)} on {@link TagManager#BLOCKS}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static TagKey<Block> makeBlockTag(String modID, String name) {
|
|
||||||
return TagManager.BLOCKS.makeTag(new ResourceLocation(modID, name));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagRegistry#makeTag(ResourceLocation)} on {@link TagManager#BLOCKS}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static TagKey<Block> makeBlockTag(ResourceLocation id) {
|
|
||||||
return TagManager.BLOCKS.makeTag(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagRegistry#makeTag(String, String)} on {@link TagManager#ITEMS}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static TagKey<Item> makeItemTag(String modID, String name) {
|
|
||||||
return TagManager.ITEMS.makeTag(new ResourceLocation(modID, name));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagRegistry#makeTag(ResourceLocation)} on {@link TagManager#ITEMS}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static TagKey<Item> makeItemTag(ResourceLocation id) {
|
|
||||||
return TagManager.ITEMS.makeTag(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagRegistry#makeCommonTag(String)} on {@link TagManager#BLOCKS}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static TagKey<Block> makeCommonBlockTag(String name) {
|
|
||||||
return TagManager.BLOCKS.makeCommonTag(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagRegistry#makeCommonTag(String)} on {@link TagManager#ITEMS}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static TagKey<Item> makeCommonItemTag(String name) {
|
|
||||||
return TagManager.ITEMS.makeCommonTag(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagRegistry#makeCommonTag(String)} on {@link TagManager#BIOMES}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static TagKey<Biome> makeCommonBiomeTag(String name) {
|
|
||||||
return TagManager.BIOMES.makeCommonTag(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes basic tags. Should be called only in BCLib main class.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void init() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Please use {@link TagManager}.BIOMES.add(biome, tagIDs) instead
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@SafeVarargs
|
|
||||||
public static void addBiomeTags(Biome biome, TagKey<Biome>... tagIDs) {
|
|
||||||
TagManager.BIOMES.add(biome, tagIDs);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Please use {@link TagManager}.BIOMES.add(tagID, biomes) instead
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void addBiomeTag(TagKey<Biome> tagID, Biome... biomes) {
|
|
||||||
TagManager.BIOMES.add(tagID, biomes);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Please use {@link TagManager}.BLOCKS.add(block, tagIDs) instead
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@SafeVarargs
|
|
||||||
public static void addBlockTags(Block block, TagKey<Block>... tagIDs) {
|
|
||||||
TagManager.BLOCKS.add(block, tagIDs);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Please use {@link TagManager}.BIOMES.add(tagID, blocks) instead
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void addBlockTag(TagKey<Block> tagID, Block... blocks) {
|
|
||||||
TagManager.BLOCKS.add(tagID, blocks);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Please use {@link TagManager}.ITEMS.add(item, tagIDs) instead
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@SafeVarargs
|
|
||||||
public static void addItemTags(ItemLike item, TagKey<Item>... tagIDs) {
|
|
||||||
TagManager.ITEMS.add(item.asItem(), tagIDs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void addItemTag(TagKey<Item> tagID, ItemLike... items) {
|
|
||||||
for (ItemLike i : items) {
|
|
||||||
TagManager.ITEMS.add(i.asItem(), tagID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Please use {@link TagManager}.ITEMS.add(tagID, items) instead
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void addItemTag(TagKey<Item> tagID, Item... items) {
|
|
||||||
TagManager.ITEMS.add(tagID, items);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static <T> Map<ResourceLocation, List<TagLoader.EntryWithSource>> apply(
|
|
||||||
String directory,
|
|
||||||
Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap
|
|
||||||
) {
|
|
||||||
TagType<?> type = TYPES.get(directory);
|
|
||||||
if (type != null) {
|
|
||||||
type.apply(tagsMap);
|
|
||||||
}
|
|
||||||
return tagsMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param stack
|
|
||||||
* @param tag
|
|
||||||
* @return
|
|
||||||
* @deprecated call {@link TagManager#isToolWithMineableTag(ItemStack, TagKey)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static boolean isToolWithMineableTag(ItemStack stack, TagKey<Block> tag) {
|
|
||||||
if (stack.getItem() instanceof DiggerItemAccessor dig) {
|
|
||||||
return dig.bclib_getBlockTag().equals(tag);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,260 +0,0 @@
|
||||||
package org.betterx.bclib.api.v2.tag;
|
|
||||||
|
|
||||||
import org.betterx.bclib.BCLib;
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
|
||||||
import org.betterx.worlds.together.tag.v3.TagRegistry;
|
|
||||||
|
|
||||||
import net.minecraft.core.DefaultedRegistry;
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.tags.TagEntry;
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.tags.TagLoader;
|
|
||||||
import net.minecraft.tags.TagManager;
|
|
||||||
import net.minecraft.world.level.biome.Biome;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagRegistry}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class TagType<T> {
|
|
||||||
boolean isFrozen = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagRegistry.RegistryBacked}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static class RegistryBacked<T> extends Simple<T> {
|
|
||||||
private final DefaultedRegistry<T> registry;
|
|
||||||
|
|
||||||
RegistryBacked(DefaultedRegistry<T> registry) {
|
|
||||||
super(
|
|
||||||
registry.key(),
|
|
||||||
TagManager.getTagDir(registry.key()),
|
|
||||||
(T element) -> {
|
|
||||||
ResourceLocation id = registry.getKey(element);
|
|
||||||
if (id != registry.getDefaultKey()) {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.registry = registry;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TagKey<T> makeTag(ResourceLocation id) {
|
|
||||||
initializeTag(id);
|
|
||||||
return registry
|
|
||||||
.getTagNames()
|
|
||||||
.filter(tagKey -> tagKey.location().equals(id))
|
|
||||||
.findAny()
|
|
||||||
.orElse(TagKey.create(registry.key(), id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagRegistry.Simple}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static class Simple<T> extends TagType<T> {
|
|
||||||
Simple(
|
|
||||||
ResourceKey<? extends Registry<T>> registry,
|
|
||||||
String directory,
|
|
||||||
Function<T, ResourceLocation> locationProvider
|
|
||||||
) {
|
|
||||||
super(registry, directory, locationProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(TagKey<T> tagID, T... elements) {
|
|
||||||
super.add(tagID, elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(T element, TagKey<T>... tagIDs) {
|
|
||||||
super.add(element, tagIDs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public void add(ResourceLocation tagID, T... elements) {
|
|
||||||
super.add(tagID, elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public void add(T element, ResourceLocation... tagIDs) {
|
|
||||||
super.add(element, tagIDs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link TagRegistry.UnTyped}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static class UnTyped<T> extends TagType<T> {
|
|
||||||
UnTyped(
|
|
||||||
ResourceKey<? extends Registry<T>> registry,
|
|
||||||
String directory
|
|
||||||
) {
|
|
||||||
super(registry, directory, (t) -> {
|
|
||||||
throw new RuntimeException("Using Untyped TagType with Type-Dependant access. ");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String directory;
|
|
||||||
private final Map<ResourceLocation, Set<TagEntry>> tags = Maps.newConcurrentMap();
|
|
||||||
public final ResourceKey<? extends Registry<T>> registryKey;
|
|
||||||
private final Function<T, ResourceLocation> locationProvider;
|
|
||||||
|
|
||||||
private TagType(
|
|
||||||
ResourceKey<? extends Registry<T>> registry,
|
|
||||||
String directory,
|
|
||||||
Function<T, ResourceLocation> locationProvider
|
|
||||||
) {
|
|
||||||
this.registryKey = registry;
|
|
||||||
this.directory = directory;
|
|
||||||
this.locationProvider = locationProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void initializeTag(ResourceLocation tagID) {
|
|
||||||
getSetForTag(tagID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<TagEntry> getSetForTag(ResourceLocation tagID) {
|
|
||||||
return tags.computeIfAbsent(tagID, k -> Sets.newHashSet());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<TagEntry> getSetForTag(TagKey<T> tag) {
|
|
||||||
if (tag == null) {
|
|
||||||
return new HashSet<>();
|
|
||||||
}
|
|
||||||
return getSetForTag(tag.location());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get or create a {@link TagKey}.
|
|
||||||
*
|
|
||||||
* @param id - {@link ResourceLocation} of the tag;
|
|
||||||
* @return the corresponding TagKey {@link TagKey<T>}.
|
|
||||||
*/
|
|
||||||
public TagKey<T> makeTag(ResourceLocation id) {
|
|
||||||
return creatTagKey(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TagKey<T> creatTagKey(ResourceLocation id) {
|
|
||||||
initializeTag(id);
|
|
||||||
return TagKey.create(registryKey, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get or create a common {@link TagKey} (namespace is 'c').
|
|
||||||
*
|
|
||||||
* @param name - The name of the Tag;
|
|
||||||
* @return the corresponding TagKey {@link TagKey<T>}.
|
|
||||||
* @see <a href="https://fabricmc.net/wiki/tutorial:tags">Fabric Wiki (Tags)</a>
|
|
||||||
*/
|
|
||||||
public TagKey<T> makeCommonTag(String name) {
|
|
||||||
return creatTagKey(new ResourceLocation("c", name));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addUntyped(TagKey<T> tagID, ResourceLocation... elements) {
|
|
||||||
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
|
||||||
Set<TagEntry> set = getSetForTag(tagID);
|
|
||||||
for (ResourceLocation id : elements) {
|
|
||||||
if (id != null) {
|
|
||||||
set.add(TagEntry.element(id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addUntyped(ResourceLocation element, TagKey<T>... tagIDs) {
|
|
||||||
for (TagKey<T> tagID : tagIDs) {
|
|
||||||
addUntyped(tagID, element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addOtherTags(TagKey<T> tagID, TagKey<T>... tags) {
|
|
||||||
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
|
||||||
Set<TagEntry> set = getSetForTag(tagID);
|
|
||||||
for (TagKey<T> tag : tags) {
|
|
||||||
ResourceLocation id = tag.location();
|
|
||||||
if (id != null) {
|
|
||||||
set.add(TagEntry.tag(id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds one Tag to multiple Elements.
|
|
||||||
*
|
|
||||||
* @param tagID {@link TagKey< Biome >} tag ID.
|
|
||||||
* @param elements array of Elements to add into tag.
|
|
||||||
*/
|
|
||||||
protected void add(TagKey<T> tagID, T... elements) {
|
|
||||||
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
|
||||||
Set<TagEntry> set = getSetForTag(tagID);
|
|
||||||
for (T element : elements) {
|
|
||||||
ResourceLocation id = locationProvider.apply(element);
|
|
||||||
if (id != null) {
|
|
||||||
set.add(TagEntry.element(id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void add(T element, TagKey<T>... tagIDs) {
|
|
||||||
for (TagKey<T> tagID : tagIDs) {
|
|
||||||
add(tagID, element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
protected void add(ResourceLocation tagID, T... elements) {
|
|
||||||
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
|
||||||
Set<TagEntry> set = getSetForTag(tagID);
|
|
||||||
for (T element : elements) {
|
|
||||||
ResourceLocation id = locationProvider.apply(element);
|
|
||||||
if (id != null) {
|
|
||||||
set.add(TagEntry.element(id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
protected void add(T element, ResourceLocation... tagIDs) {
|
|
||||||
for (ResourceLocation tagID : tagIDs) {
|
|
||||||
add(tagID, element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void forEach(BiConsumer<ResourceLocation, Set<TagEntry>> consumer) {
|
|
||||||
tags.forEach(consumer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void apply(Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap) {
|
|
||||||
if (Registry.BIOME_REGISTRY.equals(registryKey)) InternalBiomeAPI._runBiomeTagAdders();
|
|
||||||
|
|
||||||
//this.isFrozen = true;
|
|
||||||
this.forEach((id, ids) -> apply(id, tagsMap.computeIfAbsent(id, key -> Lists.newArrayList()), ids));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<TagLoader.EntryWithSource> apply(
|
|
||||||
ResourceLocation id,
|
|
||||||
List<TagLoader.EntryWithSource> builder,
|
|
||||||
Set<TagEntry> ids
|
|
||||||
) {
|
|
||||||
ids.forEach(value -> builder.add(new TagLoader.EntryWithSource(value, BCLib.MOD_ID)));
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -21,7 +21,7 @@ public class BCLFeature<F extends Feature<FC>, FC extends FeatureConfiguration>
|
||||||
new PlaceBlockFeature<>(PlaceFacingBlockConfig.CODEC)
|
new PlaceBlockFeature<>(PlaceFacingBlockConfig.CODEC)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
public static final Feature<TemplateFeatureConfig> TEMPLATE = register(
|
public static final Feature<TemplateFeatureConfig> TEMPLATE = register(
|
||||||
BCLib.makeID("template"),
|
BCLib.makeID("template"),
|
||||||
new TemplateFeature(
|
new TemplateFeature(
|
||||||
|
@ -53,8 +53,7 @@ public class BCLFeature<F extends Feature<FC>, FC extends FeatureConfiguration>
|
||||||
public final GenerationStep.Decoration decoration;
|
public final GenerationStep.Decoration decoration;
|
||||||
|
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
@Deprecated(forRemoval = true)
|
BCLFeature(
|
||||||
public BCLFeature(
|
|
||||||
BCLConfigureFeature<F, FC> configuredFeature,
|
BCLConfigureFeature<F, FC> configuredFeature,
|
||||||
Holder<PlacedFeature> placed,
|
Holder<PlacedFeature> placed,
|
||||||
GenerationStep.Decoration decoration
|
GenerationStep.Decoration decoration
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.betterx.bclib.api.v3.levelgen.features.config;
|
package org.betterx.bclib.api.v3.levelgen.features.config;
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.BCLFeature;
|
import org.betterx.bclib.api.v3.levelgen.features.BCLFeature;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.betterx.bclib.api.v3.levelgen.features.config;
|
package org.betterx.bclib.api.v3.levelgen.features.config;
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.BCLFeature;
|
import org.betterx.bclib.api.v3.levelgen.features.BCLFeature;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
@ -23,11 +23,7 @@ public class SequenceFeatureConfig implements FeatureConfiguration {
|
||||||
|
|
||||||
private final List<Holder<PlacedFeature>> features;
|
private final List<Holder<PlacedFeature>> features;
|
||||||
|
|
||||||
public static SequenceFeatureConfig create(List<BCLFeature<?, ?>> features) {
|
public static SequenceFeatureConfig createSequence(List<BCLFeature<?, ?>> features) {
|
||||||
return new SequenceFeatureConfig(features.stream().map(f -> f.getPlacedFeature()).toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SequenceFeatureConfig createSequence(List<org.betterx.bclib.api.v3.levelgen.features.BCLFeature<?, ?>> features) {
|
|
||||||
return new SequenceFeatureConfig(features.stream().map(f -> f.getPlacedFeature()).toList());
|
return new SequenceFeatureConfig(features.stream().map(f -> f.getPlacedFeature()).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,6 @@ import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfigur
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public abstract class FeatureHangingSaplingBlock<F extends Feature<FC>, FC extends FeatureConfiguration> extends FeatureSaplingBlock {
|
public abstract class FeatureHangingSaplingBlock<F extends Feature<FC>, FC extends FeatureConfiguration> extends FeatureSaplingBlock {
|
||||||
|
|
||||||
private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12);
|
private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12);
|
||||||
|
@ -35,27 +33,6 @@ public abstract class FeatureHangingSaplingBlock<F extends Feature<FC>, FC exten
|
||||||
super(properties, featureSupplier);
|
super(properties, featureSupplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public FeatureHangingSaplingBlock(Function<BlockState, org.betterx.bclib.api.v2.levelgen.features.BCLFeature> featureSupplier) {
|
|
||||||
super(featureSupplier);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public FeatureHangingSaplingBlock(
|
|
||||||
Function<BlockState, org.betterx.bclib.api.v2.levelgen.features.BCLFeature> featureSupplier,
|
|
||||||
int light
|
|
||||||
) {
|
|
||||||
super(light, featureSupplier);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public FeatureHangingSaplingBlock(
|
|
||||||
BlockBehaviour.Properties properties,
|
|
||||||
Function<BlockState, org.betterx.bclib.api.v2.levelgen.features.BCLFeature> featureSupplier
|
|
||||||
) {
|
|
||||||
super(properties, featureSupplier);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canSurvive(BlockState blockState, LevelReader levelReader, BlockPos blockPos) {
|
public boolean canSurvive(BlockState blockState, LevelReader levelReader, BlockPos blockPos) {
|
||||||
final BlockPos target = blockPos.above();
|
final BlockPos target = blockPos.above();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.betterx.bclib.blocks;
|
package org.betterx.bclib.blocks;
|
||||||
|
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.BCLConfigureFeature;
|
import org.betterx.bclib.api.v3.levelgen.features.BCLConfigureFeature;
|
||||||
import org.betterx.bclib.api.v3.levelgen.features.BCLFeature;
|
|
||||||
import org.betterx.bclib.client.models.BasePatterns;
|
import org.betterx.bclib.client.models.BasePatterns;
|
||||||
import org.betterx.bclib.client.models.ModelsHelper;
|
import org.betterx.bclib.client.models.ModelsHelper;
|
||||||
import org.betterx.bclib.client.models.PatternsHelper;
|
import org.betterx.bclib.client.models.PatternsHelper;
|
||||||
|
@ -25,7 +24,6 @@ import net.minecraft.world.level.block.SaplingBlock;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
||||||
import net.minecraft.world.level.material.Material;
|
import net.minecraft.world.level.material.Material;
|
||||||
|
@ -40,7 +38,6 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class FeatureSaplingBlock<F extends Feature<FC>, FC extends FeatureConfiguration> extends SaplingBlock implements RenderLayerProvider, BlockModelProvider {
|
public class FeatureSaplingBlock<F extends Feature<FC>, FC extends FeatureConfiguration> extends SaplingBlock implements RenderLayerProvider, BlockModelProvider {
|
||||||
|
@ -84,56 +81,10 @@ public class FeatureSaplingBlock<F extends Feature<FC>, FC extends FeatureConfig
|
||||||
this.feature = featureSupplier;
|
this.feature = featureSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public FeatureSaplingBlock(Function<BlockState, org.betterx.bclib.api.v2.levelgen.features.BCLFeature> featureSupplier) {
|
|
||||||
this(
|
|
||||||
FabricBlockSettings.of(Material.PLANT)
|
|
||||||
.collidable(false)
|
|
||||||
.instabreak()
|
|
||||||
.sound(SoundType.GRASS)
|
|
||||||
.randomTicks(),
|
|
||||||
featureSupplier
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public FeatureSaplingBlock(
|
|
||||||
int light,
|
|
||||||
Function<BlockState, org.betterx.bclib.api.v2.levelgen.features.BCLFeature> featureSupplier
|
|
||||||
) {
|
|
||||||
this(
|
|
||||||
FabricBlockSettings.of(Material.PLANT)
|
|
||||||
.collidable(false)
|
|
||||||
.luminance(light)
|
|
||||||
.instabreak()
|
|
||||||
.sound(SoundType.GRASS)
|
|
||||||
.randomTicks(),
|
|
||||||
featureSupplier
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public FeatureSaplingBlock(
|
|
||||||
BlockBehaviour.Properties properties,
|
|
||||||
Function<BlockState, org.betterx.bclib.api.v2.levelgen.features.BCLFeature> featureSupplier
|
|
||||||
) {
|
|
||||||
super(null, properties);
|
|
||||||
this.feature = (s) -> featureSupplier.apply(s).getConfFeature();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BCLConfigureFeature<F, FC> getConfiguredFeature(BlockState state) {
|
protected BCLConfigureFeature<F, FC> getConfiguredFeature(BlockState state) {
|
||||||
return feature != null ? feature.get(state) : null;
|
return feature != null ? feature.get(state) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
protected org.betterx.bclib.api.v2.levelgen.features.BCLFeature getFeature(BlockState state) {
|
|
||||||
return new org.betterx.bclib.api.v2.levelgen.features.BCLFeature(new BCLFeature<>(
|
|
||||||
getConfiguredFeature(state),
|
|
||||||
null,
|
|
||||||
GenerationStep.Decoration.TOP_LAYER_MODIFICATION
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
|
@ -159,9 +110,8 @@ public class FeatureSaplingBlock<F extends Feature<FC>, FC extends FeatureConfig
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void advanceTree(ServerLevel world, BlockPos pos, BlockState blockState, RandomSource random) {
|
public void advanceTree(ServerLevel world, BlockPos pos, BlockState blockState, RandomSource random) {
|
||||||
var conf = getConfiguredFeature(blockState);
|
BCLConfigureFeature<F, FC> conf = getConfiguredFeature(blockState);
|
||||||
if (conf == null) getFeature(blockState).place(world, pos, random);
|
conf.placeInWorld(world, pos, random);
|
||||||
else conf.placeInWorld(world, pos, random);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
package org.betterx.bclib.client.gui.gridlayout;
|
|
||||||
|
|
||||||
import org.betterx.bclib.interfaces.TriConsumer;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
class GridCell extends GridCellDefinition {
|
|
||||||
public final float height;
|
|
||||||
Function<GridTransform, Object> componentPlacer;
|
|
||||||
TriConsumer<PoseStack, GridTransform, Object> customRender;
|
|
||||||
|
|
||||||
GridCell(
|
|
||||||
double width,
|
|
||||||
double height,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
Function<GridTransform, Object> componentPlacer,
|
|
||||||
TriConsumer<PoseStack, GridTransform, Object> customRender
|
|
||||||
) {
|
|
||||||
super(width, widthType);
|
|
||||||
this.height = (float) height;
|
|
||||||
this.componentPlacer = componentPlacer;
|
|
||||||
this.customRender = customRender;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected GridElement buildElementAt(int left, int top, int width, final List<GridElement> collector) {
|
|
||||||
return new GridElement(left, top, width, (int) this.height, componentPlacer, customRender);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,103 +0,0 @@
|
||||||
package org.betterx.bclib.client.gui.gridlayout;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.components.Checkbox;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
class SignalingCheckBox extends Checkbox {
|
|
||||||
private final Consumer<Boolean> onChange;
|
|
||||||
|
|
||||||
public SignalingCheckBox(
|
|
||||||
int left,
|
|
||||||
int top,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
Component component,
|
|
||||||
boolean checked,
|
|
||||||
Consumer<Boolean> onChange
|
|
||||||
) {
|
|
||||||
super(left, top, width, height, component, checked);
|
|
||||||
this.onChange = onChange;
|
|
||||||
if (onChange != null)
|
|
||||||
onChange.accept(checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPress() {
|
|
||||||
super.onPress();
|
|
||||||
if (onChange != null)
|
|
||||||
onChange.accept(this.selected());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public class GridCheckboxCell extends GridCell implements GridWidgetWithEnabledState {
|
|
||||||
private boolean checked;
|
|
||||||
private Checkbox lastCheckbox;
|
|
||||||
private boolean enabled;
|
|
||||||
private final float alpha;
|
|
||||||
|
|
||||||
GridCheckboxCell(
|
|
||||||
Component text,
|
|
||||||
boolean checked,
|
|
||||||
float alpha,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
double height
|
|
||||||
) {
|
|
||||||
this(text, checked, alpha, width, widthType, height, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
GridCheckboxCell(
|
|
||||||
Component text,
|
|
||||||
boolean checked,
|
|
||||||
float alpha,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
double height,
|
|
||||||
Consumer<Boolean> onChange
|
|
||||||
) {
|
|
||||||
super(width, height, widthType, null, null);
|
|
||||||
lastCheckbox = null;
|
|
||||||
enabled = true;
|
|
||||||
this.alpha = alpha;
|
|
||||||
this.componentPlacer = (transform) -> {
|
|
||||||
Checkbox cb = new SignalingCheckBox(transform.left, transform.top, transform.width, transform.height,
|
|
||||||
text,
|
|
||||||
checked,
|
|
||||||
(state) -> {
|
|
||||||
this.checked = state;
|
|
||||||
if (onChange != null) onChange.accept(state);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
cb.setAlpha(alpha);
|
|
||||||
lastCheckbox = cb;
|
|
||||||
setEnabled(enabled);
|
|
||||||
return cb;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isChecked() {
|
|
||||||
return checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled() {
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
|
||||||
if (lastCheckbox != null) {
|
|
||||||
lastCheckbox.active = enabled;
|
|
||||||
lastCheckbox.setAlpha(enabled ? alpha : (alpha * 0.5f));
|
|
||||||
}
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
package org.betterx.bclib.client.gui.gridlayout;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.layout.components.VerticalStack} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public class GridColumn extends GridContainer {
|
|
||||||
GridColumn(double width) {
|
|
||||||
super(width);
|
|
||||||
}
|
|
||||||
|
|
||||||
GridColumn(double width, GridLayout.GridValueType widthType) {
|
|
||||||
super(width, widthType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridRow addRow() {
|
|
||||||
return addRow(GridLayout.VerticalAlignment.TOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridRow addRow(GridLayout.VerticalAlignment align) {
|
|
||||||
GridRow row = new GridRow(
|
|
||||||
1.0,
|
|
||||||
widthType == GridLayout.GridValueType.INHERIT
|
|
||||||
? GridLayout.GridValueType.INHERIT
|
|
||||||
: GridLayout.GridValueType.PERCENTAGE,
|
|
||||||
align
|
|
||||||
);
|
|
||||||
this.cells.add(row);
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void addSpacerRow() {
|
|
||||||
this.addSpacerRow(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSpacerRow(int height) {
|
|
||||||
GridCell cell = new GridCell(1.0, height, GridLayout.GridValueType.PERCENTAGE, null, null);
|
|
||||||
this.cells.add(cell);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int calculateWidth(final int parentWidth) {
|
|
||||||
if (widthType == GridLayout.GridValueType.INHERIT) {
|
|
||||||
return cells.stream()
|
|
||||||
.filter(row -> row.widthType == GridLayout.GridValueType.INHERIT)
|
|
||||||
.map(row -> row.buildElement(0, 0, 1, 0, 0, null).width)
|
|
||||||
.reduce(0, (p, c) -> Math.max(p, c));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return super.calculateWidth(parentWidth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected GridElement buildElementAt(int left, int inTop, int width, final List<GridElement> collector) {
|
|
||||||
int height = 0;
|
|
||||||
int top = inTop;
|
|
||||||
|
|
||||||
if (widthType == GridLayout.GridValueType.INHERIT) {
|
|
||||||
width = calculateWidth(width);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (GridCellDefinition row : cells) {
|
|
||||||
GridElement element = row.buildElement(width, 0, 1, left, top, collector);
|
|
||||||
top += element.height;
|
|
||||||
height += element.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new GridElement(left, inTop, width, height);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package org.betterx.bclib.client.gui.gridlayout;
|
|
||||||
|
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridLayout.GridValueType;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public abstract class GridCustomRenderCell extends GridCell {
|
|
||||||
protected GridCustomRenderCell(double width, GridValueType widthType, double height) {
|
|
||||||
super(width, height, widthType, null, null);
|
|
||||||
this.customRender = this::onRender;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void onRender(PoseStack poseStack, GridTransform transform, Object context);
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package org.betterx.bclib.client.gui.gridlayout;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import net.minecraft.client.gui.GuiComponent;
|
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public class GridImageCell extends GridCell {
|
|
||||||
GridImageCell(
|
|
||||||
ResourceLocation location,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
double height,
|
|
||||||
float alpha,
|
|
||||||
int uvLeft,
|
|
||||||
int uvTop,
|
|
||||||
int uvWidth,
|
|
||||||
int uvHeight,
|
|
||||||
int resourceWidth,
|
|
||||||
int resourceHeight
|
|
||||||
) {
|
|
||||||
super(width, height, widthType, null, (poseStack, transform, context) -> {
|
|
||||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
|
||||||
RenderSystem.setShaderTexture(0, location);
|
|
||||||
RenderSystem.enableBlend();
|
|
||||||
RenderSystem.blendFunc(
|
|
||||||
GlStateManager.SourceFactor.SRC_ALPHA,
|
|
||||||
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA
|
|
||||||
);
|
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, alpha);
|
|
||||||
GuiComponent.blit(
|
|
||||||
poseStack,
|
|
||||||
transform.left,
|
|
||||||
transform.top,
|
|
||||||
transform.width,
|
|
||||||
transform.height,
|
|
||||||
uvLeft,
|
|
||||||
uvTop,
|
|
||||||
uvWidth,
|
|
||||||
uvHeight,
|
|
||||||
resourceWidth,
|
|
||||||
resourceHeight
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,234 +0,0 @@
|
||||||
package org.betterx.bclib.client.gui.gridlayout;
|
|
||||||
|
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridLayout.GridValueType;
|
|
||||||
import org.betterx.bclib.interfaces.TriConsumer;
|
|
||||||
import org.betterx.bclib.util.Pair;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
abstract class GridCellDefinition {
|
|
||||||
public final float width;
|
|
||||||
public final GridLayout.GridValueType widthType;
|
|
||||||
|
|
||||||
public GridCellDefinition(double width, GridLayout.GridValueType widthType) {
|
|
||||||
this.width = (float) width;
|
|
||||||
this.widthType = widthType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int calculateWidth(final int parentWidth) {
|
|
||||||
if (widthType == GridLayout.GridValueType.CONSTANT) {
|
|
||||||
return (int) this.width;
|
|
||||||
} else if (widthType == GridValueType.PERCENTAGE) {
|
|
||||||
return (int) (this.width * parentWidth);
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final GridElement buildElement(
|
|
||||||
final int parentWidth,
|
|
||||||
final int autoWidth,
|
|
||||||
final float autoWidthSum,
|
|
||||||
int left,
|
|
||||||
final int top,
|
|
||||||
final List<GridElement> collector
|
|
||||||
) {
|
|
||||||
final int width = widthType == GridValueType.FILL
|
|
||||||
? (int) ((this.width / autoWidthSum) * autoWidth)
|
|
||||||
: calculateWidth(parentWidth);
|
|
||||||
|
|
||||||
final GridElement el = buildElementAt(left, top, width, collector);
|
|
||||||
if (collector != null) {
|
|
||||||
collector.add(el);
|
|
||||||
}
|
|
||||||
return el;
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract protected GridElement buildElementAt(int left, int top, int width, final List<GridElement> collector);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
class GridElement extends GridTransform {
|
|
||||||
final Function<GridTransform, Object> componentPlacer;
|
|
||||||
final TriConsumer<PoseStack, GridTransform, Object> customRender;
|
|
||||||
Object renderContext;
|
|
||||||
|
|
||||||
GridElement(
|
|
||||||
int left,
|
|
||||||
int top,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
Function<GridTransform, Object> componentPlacer,
|
|
||||||
TriConsumer<PoseStack, GridTransform, Object> customRender
|
|
||||||
) {
|
|
||||||
super(left, top, width, height);
|
|
||||||
this.componentPlacer = componentPlacer;
|
|
||||||
this.customRender = customRender;
|
|
||||||
}
|
|
||||||
|
|
||||||
GridElement(int left, int top, int width, int height) {
|
|
||||||
this(left, top, width, height, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
GridTransform transformWithPadding(int leftPadding, int topPadding) {
|
|
||||||
return new GridTransform(left + leftPadding, top + topPadding, width, height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
abstract class GridContainer extends GridCellDefinition {
|
|
||||||
protected List<GridCellDefinition> cells;
|
|
||||||
|
|
||||||
public GridContainer(double width) {
|
|
||||||
this(width, GridLayout.GridValueType.CONSTANT);
|
|
||||||
}
|
|
||||||
|
|
||||||
GridContainer(double width, GridLayout.GridValueType widthType) {
|
|
||||||
super(width, widthType);
|
|
||||||
cells = new LinkedList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.layout.components.Panel} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public class GridLayout extends GridColumn {
|
|
||||||
public static final int COLOR_WHITE = 0xFFFFFFFF;
|
|
||||||
public static final int COLOR_RED = 0xFFDB1F48;
|
|
||||||
public static final int COLOR_CYAN = 0xFF01949A;
|
|
||||||
public static final int COLOR_GREEN = 0xFF00FF00;
|
|
||||||
public static final int COLOR_DARK_GREEN = 0xFF007F00;
|
|
||||||
public static final int COLOR_YELLOW = 0xFFFAD02C;
|
|
||||||
public static final int COLOR_BLUE = 0xFF0000FF;
|
|
||||||
public static final int COLOR_GRAY = 0xFF7F7F7F;
|
|
||||||
|
|
||||||
public final GridScreen screen;
|
|
||||||
public final int screenHeight;
|
|
||||||
public final int sidePadding;
|
|
||||||
public final int initialTopPadding;
|
|
||||||
public final boolean centerVertically;
|
|
||||||
private int height;
|
|
||||||
private int topPadding;
|
|
||||||
|
|
||||||
private List<GridElement> elements;
|
|
||||||
|
|
||||||
public GridLayout(GridScreen screen) {
|
|
||||||
this(screen, 0, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridLayout(GridScreen screen, int topPadding, boolean centerVertically) {
|
|
||||||
this(screen, topPadding, 20, centerVertically);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridLayout(GridScreen screen, int topPadding, int sidePadding, boolean centerVertically) {
|
|
||||||
super(screen.width - 2 * sidePadding, GridValueType.CONSTANT);
|
|
||||||
this.screen = screen;
|
|
||||||
this.screenHeight = screen.height;
|
|
||||||
height = 0;
|
|
||||||
this.topPadding = topPadding;
|
|
||||||
this.sidePadding = sidePadding;
|
|
||||||
this.initialTopPadding = topPadding;
|
|
||||||
this.centerVertically = centerVertically;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTopPadding() {
|
|
||||||
return topPadding;
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildLayout() {
|
|
||||||
elements = new LinkedList<>();
|
|
||||||
GridElement el = this.buildElement((int) this.width, 0, 1, 0, 0, elements);
|
|
||||||
this.height = el.height;
|
|
||||||
if (centerVertically && el.height + initialTopPadding < screenHeight) {
|
|
||||||
topPadding = (screenHeight - el.height) >> 1;
|
|
||||||
} else {
|
|
||||||
topPadding = initialTopPadding;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Pair<AbstractWidget, Integer>> movableWidgets = new LinkedList<>();
|
|
||||||
|
|
||||||
public void finalizeLayout() {
|
|
||||||
buildLayout();
|
|
||||||
|
|
||||||
elements
|
|
||||||
.stream()
|
|
||||||
.filter(element -> element.componentPlacer != null)
|
|
||||||
.forEach(element -> {
|
|
||||||
final GridTransform transform = element.transformWithPadding(sidePadding, topPadding);
|
|
||||||
final Object context = element.componentPlacer.apply(transform);
|
|
||||||
if (element.customRender != null) {
|
|
||||||
element.renderContext = context;
|
|
||||||
} else if (context instanceof AbstractWidget) {
|
|
||||||
final AbstractWidget widget = (AbstractWidget) context;
|
|
||||||
movableWidgets.add(new Pair(widget, widget.y));
|
|
||||||
screen.addRenderableWidget(widget);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render(PoseStack poseStack) {
|
|
||||||
if (elements == null) return;
|
|
||||||
elements
|
|
||||||
.stream()
|
|
||||||
.filter(element -> element.customRender != null)
|
|
||||||
.forEach(element -> element.customRender.accept(
|
|
||||||
poseStack,
|
|
||||||
element.transformWithPadding(sidePadding, topPadding),
|
|
||||||
element.renderContext
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public enum VerticalAlignment {
|
|
||||||
TOP, CENTER, BOTTOM
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Alignment {
|
|
||||||
LEFT, CENTER, RIGHT
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines how a measurement value is interpreted
|
|
||||||
*/
|
|
||||||
public enum GridValueType {
|
|
||||||
/**
|
|
||||||
* The value is a constant pixel size
|
|
||||||
*/
|
|
||||||
CONSTANT,
|
|
||||||
/**
|
|
||||||
* The Value is relative to the parent size
|
|
||||||
*/
|
|
||||||
PERCENTAGE,
|
|
||||||
/**
|
|
||||||
* The value will be set to fill up the remaining space (i.e. when this is applied to a width of a row element,
|
|
||||||
* a {@link #FILL}-type may be used to right align (FILL - CONSTANT) or center (FILL - CONSTANT - FILL) elements.
|
|
||||||
*/
|
|
||||||
FILL,
|
|
||||||
/**
|
|
||||||
* Calculate size based on child-elements
|
|
||||||
*/
|
|
||||||
INHERIT
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
package org.betterx.bclib.client.gui.gridlayout;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.Font;
|
|
||||||
import net.minecraft.client.gui.components.MultiLineLabel;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public class GridMessageCell extends GridCell {
|
|
||||||
private final Font font;
|
|
||||||
private Component text;
|
|
||||||
private MultiLineLabel lastLabel;
|
|
||||||
private GridTransform lastTransform;
|
|
||||||
|
|
||||||
GridMessageCell(
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
GridLayout.Alignment contentAlignment,
|
|
||||||
Font font,
|
|
||||||
Component text
|
|
||||||
) {
|
|
||||||
this(width, widthType, contentAlignment, font, text, GridLayout.COLOR_WHITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
GridMessageCell(
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
GridLayout.Alignment contentAlignment,
|
|
||||||
Font font,
|
|
||||||
Component text,
|
|
||||||
int color
|
|
||||||
) {
|
|
||||||
super(width, -1, widthType, null, null);
|
|
||||||
this.font = font;
|
|
||||||
this.text = text;
|
|
||||||
|
|
||||||
customRender = (poseStack, transform, context) -> {
|
|
||||||
//MultiLineLabel label = (MultiLineLabel) context;
|
|
||||||
if (contentAlignment == GridLayout.Alignment.CENTER) {
|
|
||||||
lastLabel.renderCentered(
|
|
||||||
poseStack,
|
|
||||||
transform.width / 2 + transform.left,
|
|
||||||
transform.top,
|
|
||||||
font.lineHeight,
|
|
||||||
color
|
|
||||||
);
|
|
||||||
} else if (contentAlignment == GridLayout.Alignment.LEFT) {
|
|
||||||
lastLabel.renderLeftAligned(poseStack, transform.left, transform.top, font.lineHeight, color);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setText(Component text) {
|
|
||||||
this.text = text;
|
|
||||||
if (lastTransform != null) {
|
|
||||||
create(lastTransform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private MultiLineLabel getLabel(GridTransform transform) {
|
|
||||||
return lastLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void create(GridTransform transform) {
|
|
||||||
this.lastTransform = transform;
|
|
||||||
this.lastLabel = MultiLineLabel.create(font, text, transform.width);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected GridElement buildElementAt(int left, int top, int width, List<GridElement> collector) {
|
|
||||||
create(new GridTransform(left, top, width, 0));
|
|
||||||
int promptLines = this.lastLabel.getLineCount() + 1;
|
|
||||||
int height = promptLines * 9;
|
|
||||||
|
|
||||||
return new GridElement(left, top, width, height, this::getLabel, customRender);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,455 +0,0 @@
|
||||||
package org.betterx.bclib.client.gui.gridlayout;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.Font;
|
|
||||||
import net.minecraft.client.gui.components.Button;
|
|
||||||
import net.minecraft.client.gui.components.Button.OnPress;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.layout.components.HorizontalStack} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public class GridRow extends GridContainer {
|
|
||||||
public final GridLayout.VerticalAlignment alignment;
|
|
||||||
|
|
||||||
GridRow(double width) {
|
|
||||||
this(width, GridLayout.VerticalAlignment.TOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
GridRow(double width, GridLayout.GridValueType widthType) {
|
|
||||||
this(width, widthType, GridLayout.VerticalAlignment.CENTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
GridRow(double width, GridLayout.VerticalAlignment alignment) {
|
|
||||||
super(width);
|
|
||||||
this.alignment = alignment;
|
|
||||||
}
|
|
||||||
|
|
||||||
GridRow(double width, GridLayout.GridValueType widthType, GridLayout.VerticalAlignment alignment) {
|
|
||||||
super(width, widthType);
|
|
||||||
this.alignment = alignment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridColumn addColumn(double width, GridLayout.GridValueType widthType) {
|
|
||||||
GridColumn cell = new GridColumn(width, widthType);
|
|
||||||
this.cells.add(cell);
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCell addComponent(double height, Function<GridTransform, Object> componentPlacer) {
|
|
||||||
return addComponent(1.0, GridLayout.GridValueType.PERCENTAGE, height, componentPlacer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCell addComponent(
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
double height,
|
|
||||||
Function<GridTransform, Object> componentPlacer
|
|
||||||
) {
|
|
||||||
GridCell cell = new GridCell(width, height, widthType, componentPlacer, null);
|
|
||||||
this.cells.add(cell);
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public GridCell addButton(Component text, double height, OnPress onPress) {
|
|
||||||
return addButton(text, 1.0, GridLayout.GridValueType.PERCENTAGE, height, onPress);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCell addButton(Component text, float alpha, double height, OnPress onPress) {
|
|
||||||
return addButton(text, alpha, 1.0, GridLayout.GridValueType.PERCENTAGE, height, onPress);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCell addButton(Component text, double height, Font font, OnPress onPress) {
|
|
||||||
return addButton(text, 1.0f, height, font, onPress);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCell addButton(Component text, float alpha, double height, Font font, OnPress onPress) {
|
|
||||||
final int width = font.width(text.getVisualOrderText()) + 24;
|
|
||||||
return addButton(text, alpha, width, GridLayout.GridValueType.CONSTANT, height, onPress);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCell addButton(
|
|
||||||
Component text,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
double height,
|
|
||||||
OnPress onPress
|
|
||||||
) {
|
|
||||||
return addButton(text, 1.0f, width, widthType, height, onPress);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCell addButton(
|
|
||||||
Component text,
|
|
||||||
float alpha,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
double height,
|
|
||||||
OnPress onPress
|
|
||||||
) {
|
|
||||||
GridCell cell = new GridCell(width, height, widthType, (transform) -> {
|
|
||||||
Button customButton = new Button(
|
|
||||||
transform.left,
|
|
||||||
transform.top,
|
|
||||||
transform.width,
|
|
||||||
transform.height,
|
|
||||||
text,
|
|
||||||
onPress
|
|
||||||
);
|
|
||||||
customButton.setAlpha(alpha);
|
|
||||||
return customButton;
|
|
||||||
}, null);
|
|
||||||
this.cells.add(cell);
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCheckboxCell addCheckbox(Component text, boolean checked, Font font, Consumer<Boolean> onChange) {
|
|
||||||
final int width = font.width(text.getVisualOrderText()) + 24 + 2 * 12;
|
|
||||||
return addCheckbox(text, checked, width, widthType, onChange);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCheckboxCell addCheckbox(
|
|
||||||
Component text, boolean checked, double width,
|
|
||||||
GridLayout.GridValueType widthType, Consumer<Boolean> onChange
|
|
||||||
) {
|
|
||||||
|
|
||||||
GridCheckboxCell cell = new GridCheckboxCell(text, checked, 1.0f, width, widthType, 20, onChange);
|
|
||||||
this.cells.add(cell);
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCheckboxCell addCheckbox(Component text, boolean checked, int height) {
|
|
||||||
return addCheckbox(text, checked, 1.0f, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCheckboxCell addCheckbox(Component text, boolean checked, float alpha, int height) {
|
|
||||||
return addCheckbox(text, checked, alpha, 1.0, GridLayout.GridValueType.PERCENTAGE, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCheckboxCell addCheckbox(Component text, boolean checked, int height, Font font) {
|
|
||||||
return addCheckbox(text, checked, 1.0f, height, font);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCheckboxCell addCheckbox(Component text, boolean checked, float alpha, int height, Font font) {
|
|
||||||
final int width = font.width(text.getVisualOrderText()) + 24 + 2 * 12;
|
|
||||||
return addCheckbox(text, checked, alpha, width, GridLayout.GridValueType.CONSTANT, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCheckboxCell addCheckbox(
|
|
||||||
Component text,
|
|
||||||
boolean checked,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
int height
|
|
||||||
) {
|
|
||||||
return addCheckbox(text, checked, 1.0f, width, widthType, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCheckboxCell addCheckbox(
|
|
||||||
Component text,
|
|
||||||
boolean checked,
|
|
||||||
float alpha,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
int height
|
|
||||||
) {
|
|
||||||
GridCheckboxCell cell = new GridCheckboxCell(text, checked, alpha, width, widthType, height);
|
|
||||||
this.cells.add(cell);
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCustomRenderCell addCustomRender(GridCustomRenderCell cell) {
|
|
||||||
this.cells.add(cell);
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCell addImage(ResourceLocation location, int width, int height) {
|
|
||||||
return addImage(location, 1.0f, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCell addImage(ResourceLocation location, float alpha, int width, int height) {
|
|
||||||
return addImage(
|
|
||||||
location,
|
|
||||||
alpha,
|
|
||||||
width,
|
|
||||||
GridLayout.GridValueType.CONSTANT,
|
|
||||||
height,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
width,
|
|
||||||
height
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCell addImage(
|
|
||||||
ResourceLocation location,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
int height,
|
|
||||||
int resourceWidth,
|
|
||||||
int resourceHeight
|
|
||||||
) {
|
|
||||||
return addImage(location, 1.0f, width, widthType, height, resourceWidth, resourceHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCell addImage(
|
|
||||||
ResourceLocation location,
|
|
||||||
float alpha,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
int height,
|
|
||||||
int resourceWidth,
|
|
||||||
int resourceHeight
|
|
||||||
) {
|
|
||||||
return addImage(
|
|
||||||
location,
|
|
||||||
alpha,
|
|
||||||
width,
|
|
||||||
widthType,
|
|
||||||
height,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
resourceWidth,
|
|
||||||
resourceWidth,
|
|
||||||
resourceWidth,
|
|
||||||
resourceHeight
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCell addImage(
|
|
||||||
ResourceLocation location,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
int height,
|
|
||||||
int uvLeft,
|
|
||||||
int uvTop,
|
|
||||||
int uvWidth,
|
|
||||||
int uvHeight,
|
|
||||||
int resourceWidth,
|
|
||||||
int resourceHeight
|
|
||||||
) {
|
|
||||||
return addImage(
|
|
||||||
location,
|
|
||||||
1.0f,
|
|
||||||
width,
|
|
||||||
widthType,
|
|
||||||
height,
|
|
||||||
uvLeft,
|
|
||||||
uvTop,
|
|
||||||
uvWidth,
|
|
||||||
uvHeight,
|
|
||||||
resourceWidth,
|
|
||||||
resourceHeight
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridCell addImage(
|
|
||||||
ResourceLocation location,
|
|
||||||
float alpha,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
int height,
|
|
||||||
int uvLeft,
|
|
||||||
int uvTop,
|
|
||||||
int uvWidth,
|
|
||||||
int uvHeight,
|
|
||||||
int resourceWidth,
|
|
||||||
int resourceHeight
|
|
||||||
) {
|
|
||||||
GridCell cell = new GridImageCell(
|
|
||||||
location,
|
|
||||||
width,
|
|
||||||
widthType,
|
|
||||||
height,
|
|
||||||
alpha,
|
|
||||||
uvLeft,
|
|
||||||
uvTop,
|
|
||||||
uvWidth,
|
|
||||||
uvHeight,
|
|
||||||
resourceWidth,
|
|
||||||
resourceHeight
|
|
||||||
);
|
|
||||||
this.cells.add(cell);
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public GridColumn addFiller() {
|
|
||||||
return addFiller(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridColumn addFiller(float portion) {
|
|
||||||
GridColumn cell = new GridColumn(portion, GridLayout.GridValueType.FILL);
|
|
||||||
this.cells.add(cell);
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSpacer() {
|
|
||||||
addSpacer(12);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSpacer(int width) {
|
|
||||||
GridCell cell = new GridCell(width, 0, GridLayout.GridValueType.CONSTANT, null, null);
|
|
||||||
this.cells.add(cell);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public GridMessageCell addMessage(Component text, Font font, GridLayout.Alignment contentAlignment) {
|
|
||||||
return addMessage(text, font, GridLayout.COLOR_WHITE, contentAlignment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridMessageCell addMessage(Component text, Font font, int color, GridLayout.Alignment contentAlignment) {
|
|
||||||
return addMessage(text, 1.0, GridLayout.GridValueType.PERCENTAGE, font, color, contentAlignment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridMessageCell addMessage(
|
|
||||||
Component text,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
Font font,
|
|
||||||
GridLayout.Alignment contentAlignment
|
|
||||||
) {
|
|
||||||
return addMessage(text, width, widthType, font, GridLayout.COLOR_WHITE, contentAlignment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridMessageCell addMessage(
|
|
||||||
Component text,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
Font font,
|
|
||||||
int color,
|
|
||||||
GridLayout.Alignment contentAlignment
|
|
||||||
) {
|
|
||||||
GridMessageCell cell = new GridMessageCell(width, widthType, contentAlignment, font, text, color);
|
|
||||||
this.cells.add(cell);
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridStringCell addString(Component text, GridScreen parent) {
|
|
||||||
return this.addString(text, GridLayout.COLOR_WHITE, parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public GridStringCell addString(Component text, int color, GridScreen parent) {
|
|
||||||
final int width = parent.getWidth(text);
|
|
||||||
return this.addString(
|
|
||||||
text,
|
|
||||||
width,
|
|
||||||
GridLayout.GridValueType.CONSTANT,
|
|
||||||
color,
|
|
||||||
GridLayout.Alignment.CENTER,
|
|
||||||
parent
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridStringCell addString(Component text, GridLayout.Alignment contentAlignment, GridScreen parent) {
|
|
||||||
return this.addString(text, GridLayout.COLOR_WHITE, contentAlignment, parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridStringCell addString(
|
|
||||||
Component text,
|
|
||||||
int color,
|
|
||||||
GridLayout.Alignment contentAlignment,
|
|
||||||
GridScreen parent
|
|
||||||
) {
|
|
||||||
return this.addString(text, 1.0, GridLayout.GridValueType.PERCENTAGE, color, contentAlignment, parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridStringCell addString(
|
|
||||||
Component text,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
GridLayout.Alignment contentAlignment,
|
|
||||||
GridScreen parent
|
|
||||||
) {
|
|
||||||
return addString(text, width, widthType, GridLayout.COLOR_WHITE, contentAlignment, parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridStringCell addString(
|
|
||||||
Component text,
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
int color,
|
|
||||||
GridLayout.Alignment contentAlignment,
|
|
||||||
GridScreen parent
|
|
||||||
) {
|
|
||||||
GridStringCell cell = new GridStringCell(
|
|
||||||
width,
|
|
||||||
widthType,
|
|
||||||
parent.getFont().lineHeight,
|
|
||||||
contentAlignment,
|
|
||||||
parent,
|
|
||||||
text,
|
|
||||||
color
|
|
||||||
);
|
|
||||||
this.cells.add(cell);
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected GridElement buildElementAt(int inLeft, int top, int width, final List<GridElement> collector) {
|
|
||||||
int height = 0;
|
|
||||||
int left = inLeft;
|
|
||||||
if (widthType == GridLayout.GridValueType.INHERIT) {
|
|
||||||
final int originalWidth = width;
|
|
||||||
width = cells.stream()
|
|
||||||
.filter(row -> row.widthType == GridLayout.GridValueType.CONSTANT || row.widthType == GridLayout.GridValueType.INHERIT)
|
|
||||||
.map(row -> row.buildElement(0, 0, 1, 0, 0, null).width)
|
|
||||||
.reduce(0, (p, c) -> p + c);
|
|
||||||
}
|
|
||||||
|
|
||||||
final int inheritedWidth = width;
|
|
||||||
final int fixedWidth = cells.stream()
|
|
||||||
.filter(col -> col.widthType != GridLayout.GridValueType.FILL)
|
|
||||||
.map(col -> col.calculateWidth(inheritedWidth))
|
|
||||||
.reduce(0, (p, c) -> p + c);
|
|
||||||
final float autoWidthSum = cells.stream()
|
|
||||||
.filter(col -> col.widthType == GridLayout.GridValueType.FILL)
|
|
||||||
.map(col -> col.width)
|
|
||||||
.reduce(0.0f, (p, c) -> p + c);
|
|
||||||
final int autoWidth = width - fixedWidth;
|
|
||||||
|
|
||||||
if (alignment == GridLayout.VerticalAlignment.TOP) {
|
|
||||||
for (GridCellDefinition col : cells) {
|
|
||||||
GridElement element = col.buildElement(width, autoWidth, autoWidthSum, left, top, collector);
|
|
||||||
left += element.width;
|
|
||||||
height = Math.max(height, element.height);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//first iteration will collect heights, second one will transform top position for alignment
|
|
||||||
Map<GridCellDefinition, GridElement> cache = new HashMap<>();
|
|
||||||
for (GridCellDefinition col : cells) {
|
|
||||||
GridElement element = col.buildElement(width, autoWidth, autoWidthSum, left, top, null);
|
|
||||||
left += element.width;
|
|
||||||
height = Math.max(height, element.height);
|
|
||||||
cache.put(col, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
left = inLeft;
|
|
||||||
for (GridCellDefinition col : cells) {
|
|
||||||
GridElement element = cache.get(col);
|
|
||||||
final int topOffset = (alignment == GridLayout.VerticalAlignment.BOTTOM)
|
|
||||||
? (height - element.height)
|
|
||||||
: (height - element.height) >> 1;
|
|
||||||
element = col.buildElement(width, autoWidth, autoWidthSum, left, top + topOffset, collector);
|
|
||||||
left += element.width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return new GridElement(inLeft, top, width, height);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,269 +0,0 @@
|
||||||
package org.betterx.bclib.client.gui.gridlayout;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.vertex.*;
|
|
||||||
import net.minecraft.client.gui.Font;
|
|
||||||
import net.minecraft.client.gui.components.Widget;
|
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
|
||||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link org.betterx.ui.vanilla.LayoutScreen} or {@link org.betterx.ui.vanilla.LayoutScreenWithIcon} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public abstract class GridScreen extends Screen {
|
|
||||||
protected GridLayout grid = null;
|
|
||||||
public final int topPadding;
|
|
||||||
public final int sidePadding;
|
|
||||||
public final boolean centerVertically;
|
|
||||||
@Nullable
|
|
||||||
public final Screen parent;
|
|
||||||
|
|
||||||
protected int scrollPos = 0;
|
|
||||||
|
|
||||||
public GridScreen(Component title) {
|
|
||||||
this(null, title);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridScreen(@Nullable Screen parent, Component title) {
|
|
||||||
this(parent, title, 0, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridScreen(Component title, int topPadding, boolean centerVertically) {
|
|
||||||
this(null, title, topPadding, 20, centerVertically);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridScreen(@Nullable Screen parent, Component title, int topPadding, boolean centerVertically) {
|
|
||||||
this(parent, title, topPadding, 20, centerVertically);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridScreen(Component title, int topPadding, int sidePadding, boolean centerVertically) {
|
|
||||||
this(null, title, topPadding, sidePadding, centerVertically);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GridScreen(
|
|
||||||
@Nullable Screen parent,
|
|
||||||
Component title,
|
|
||||||
int topPadding,
|
|
||||||
int sidePadding,
|
|
||||||
boolean centerVertically
|
|
||||||
) {
|
|
||||||
super(title);
|
|
||||||
|
|
||||||
this.parent = parent;
|
|
||||||
this.topPadding = topPadding;
|
|
||||||
this.sidePadding = sidePadding;
|
|
||||||
this.centerVertically = centerVertically;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClose() {
|
|
||||||
this.minecraft.setScreen(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Font getFont() {
|
|
||||||
return this.font;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPauseScreen() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends GuiEventListener & Widget & NarratableEntry> T addRenderableWidget(T guiEventListener) {
|
|
||||||
return super.addRenderableWidget(guiEventListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addTitle() {
|
|
||||||
grid.addRow().addString(this.title, GridLayout.Alignment.CENTER, this);
|
|
||||||
grid.addSpacerRow(15);
|
|
||||||
}
|
|
||||||
|
|
||||||
final protected void init() {
|
|
||||||
super.init();
|
|
||||||
this.grid = new GridLayout(this, this.topPadding, this.sidePadding, this.centerVertically);
|
|
||||||
|
|
||||||
addTitle();
|
|
||||||
|
|
||||||
initLayout();
|
|
||||||
grid.finalizeLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void initLayout();
|
|
||||||
|
|
||||||
protected void renderScreen(PoseStack poseStack, int i, int j, float f) {
|
|
||||||
super.render(poseStack, i, j, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render(PoseStack poseStack, int i, int j, float f) {
|
|
||||||
this.renderDirtBackground(i);
|
|
||||||
renderGrid(poseStack);
|
|
||||||
super.render(poseStack, i, j, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void renderGrid(PoseStack poseStack) {
|
|
||||||
if (grid != null) {
|
|
||||||
if (isScrollable()) {
|
|
||||||
for (var item : grid.movableWidgets) {
|
|
||||||
item.first.y = item.second + scrollPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
renderScroll(poseStack);
|
|
||||||
|
|
||||||
poseStack.pushPose();
|
|
||||||
poseStack.translate(0, scrollPos, 0);
|
|
||||||
grid.render(poseStack);
|
|
||||||
poseStack.popPose();
|
|
||||||
} else {
|
|
||||||
grid.render(poseStack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getWidth(Component text, Font font) {
|
|
||||||
return font.width(text.getVisualOrderText());
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth(Component text) {
|
|
||||||
return getWidth(text, getFont());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setScrollPos(int sp) {
|
|
||||||
scrollPos = Math.max(getMaxScrollPos(), Math.min(0, sp));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getScrollPos() {
|
|
||||||
return scrollPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getScrollHeight() {
|
|
||||||
if (grid != null) return grid.getHeight() + topPadding;
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxScrollPos() {
|
|
||||||
return height - (getScrollHeight() + topPadding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isScrollable() {
|
|
||||||
return height < getScrollHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMouseOverScroller(double x, double y) {
|
|
||||||
return y >= 0 && y <= height && x >= width - SCROLLER_WIDTH && x <= width;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean scrolling = false;
|
|
||||||
|
|
||||||
protected void updateScrollingState(double x, double y, int i) {
|
|
||||||
this.scrolling = i == 0 && x >= width - SCROLLER_WIDTH && x < width;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int SCROLLER_WIDTH = 6;
|
|
||||||
|
|
||||||
private void renderScroll(PoseStack poseStack) {
|
|
||||||
final int y1 = height;
|
|
||||||
final int y0 = 0;
|
|
||||||
final int yd = y1 - y0;
|
|
||||||
final int maxPosition = getScrollHeight() + topPadding;
|
|
||||||
|
|
||||||
final int x0 = width - SCROLLER_WIDTH;
|
|
||||||
final int x1 = width;
|
|
||||||
|
|
||||||
Tesselator tesselator = Tesselator.getInstance();
|
|
||||||
BufferBuilder bufferBuilder = tesselator.getBuilder();
|
|
||||||
RenderSystem.disableTexture();
|
|
||||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
|
||||||
int widgetHeight = (int) ((float) (yd * yd) / (float) maxPosition);
|
|
||||||
widgetHeight = Mth.clamp(widgetHeight, 32, yd - 8);
|
|
||||||
float relPos = (float) this.getScrollPos() / this.getMaxScrollPos();
|
|
||||||
int top = (int) (relPos * (yd - widgetHeight)) + y0;
|
|
||||||
if (top < y0) {
|
|
||||||
top = y0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
|
|
||||||
|
|
||||||
//scroller background
|
|
||||||
bufferBuilder.vertex(x0, y1, 0.0D).color(0, 0, 0, 255).endVertex();
|
|
||||||
bufferBuilder.vertex(x1, y1, 0.0D).color(0, 0, 0, 255).endVertex();
|
|
||||||
bufferBuilder.vertex(x1, y0, 0.0D).color(0, 0, 0, 255).endVertex();
|
|
||||||
bufferBuilder.vertex(x0, y0, 0.0D).color(0, 0, 0, 255).endVertex();
|
|
||||||
|
|
||||||
//scroll widget shadow
|
|
||||||
bufferBuilder.vertex(x0, top + widgetHeight, 0.0D).color(128, 128, 128, 255).endVertex();
|
|
||||||
bufferBuilder.vertex(x1, top + widgetHeight, 0.0D).color(128, 128, 128, 255).endVertex();
|
|
||||||
bufferBuilder.vertex(x1, top, 0.0D).color(128, 128, 128, 255).endVertex();
|
|
||||||
bufferBuilder.vertex(x0, top, 0.0D).color(128, 128, 128, 255).endVertex();
|
|
||||||
|
|
||||||
//scroll widget
|
|
||||||
bufferBuilder.vertex(x0, top + widgetHeight - 1, 0.0D)
|
|
||||||
.color(192, 192, 192, 255)
|
|
||||||
.endVertex();
|
|
||||||
bufferBuilder.vertex(x1 - 1, top + widgetHeight - 1, 0.0D)
|
|
||||||
.color(192, 192, 192, 255)
|
|
||||||
.endVertex();
|
|
||||||
bufferBuilder.vertex(x1 - 1, top, 0.0D).color(192, 192, 192, 255).endVertex();
|
|
||||||
bufferBuilder.vertex(x0, top, 0.0D).color(192, 192, 192, 255).endVertex();
|
|
||||||
tesselator.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean mouseClicked(double x, double y, int i) {
|
|
||||||
this.updateScrollingState(x, y, i);
|
|
||||||
if (this.scrolling) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return super.mouseClicked(x, y, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean mouseDragged(double xAbs, double yAbs, int i, double dX, double dY) {
|
|
||||||
if (super.mouseDragged(xAbs, yAbs, i, dX, dY)) {
|
|
||||||
return true;
|
|
||||||
} else if (i == 0 && this.scrolling) {
|
|
||||||
if (yAbs < 0) {
|
|
||||||
this.setScrollPos(0);
|
|
||||||
} else if (yAbs > height) {
|
|
||||||
this.setScrollPos(this.getMaxScrollPos());
|
|
||||||
} else {
|
|
||||||
this.setScrollPos((int) (this.getScrollPos() - dY * 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean mouseScrolled(double d, double e, double f) {
|
|
||||||
if (isScrollable()) {
|
|
||||||
setScrollPos((int) (scrollPos + f * 10));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean keyPressed(int keyCode, int j, int k) {
|
|
||||||
if (super.keyPressed(keyCode, j, k)) {
|
|
||||||
return true;
|
|
||||||
} else if (keyCode == 264) {
|
|
||||||
this.mouseScrolled(0, -1.0f, 0);
|
|
||||||
return true;
|
|
||||||
} else if (keyCode == 265) {
|
|
||||||
this.mouseScrolled(0, 1.0, 0);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
package org.betterx.bclib.client.gui.gridlayout;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiComponent;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public class GridStringCell extends GridCell {
|
|
||||||
private Component text;
|
|
||||||
|
|
||||||
GridStringCell(
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
int height,
|
|
||||||
GridLayout.Alignment contentAlignment,
|
|
||||||
GridScreen parent,
|
|
||||||
Component text
|
|
||||||
) {
|
|
||||||
this(width, widthType, height, contentAlignment, parent, text, GridLayout.COLOR_WHITE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GridStringCell(
|
|
||||||
double width,
|
|
||||||
GridLayout.GridValueType widthType,
|
|
||||||
int height,
|
|
||||||
GridLayout.Alignment contentAlignment,
|
|
||||||
GridScreen parent,
|
|
||||||
Component text,
|
|
||||||
int color
|
|
||||||
) {
|
|
||||||
super(width, height, widthType, null, null);
|
|
||||||
this.text = text;
|
|
||||||
this.customRender = (poseStack, transform, context) -> {
|
|
||||||
if (contentAlignment == GridLayout.Alignment.CENTER) {
|
|
||||||
GuiComponent.drawCenteredString(
|
|
||||||
poseStack,
|
|
||||||
parent.getFont(),
|
|
||||||
this.text,
|
|
||||||
transform.width / 2 + transform.left,
|
|
||||||
transform.top,
|
|
||||||
color
|
|
||||||
);
|
|
||||||
} else if (contentAlignment == GridLayout.Alignment.LEFT) {
|
|
||||||
GuiComponent.drawString(poseStack, parent.getFont(), this.text, transform.left, transform.top, color);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setText(Component newText) {
|
|
||||||
this.text = newText;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package org.betterx.bclib.client.gui.gridlayout;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public class GridTransform {
|
|
||||||
public final int left;
|
|
||||||
public final int top;
|
|
||||||
public final int width;
|
|
||||||
public final int height;
|
|
||||||
|
|
||||||
GridTransform(int left, int top, int width, int height) {
|
|
||||||
this.left = left;
|
|
||||||
this.top = top;
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "{" + "left=" + left + ", top=" + top + ", width=" + width + ", height=" + height + '}';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package org.betterx.bclib.client.gui.gridlayout;
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public interface GridWidgetWithEnabledState {
|
|
||||||
boolean isEnabled();
|
|
||||||
void setEnabled(boolean enabled);
|
|
||||||
}
|
|
|
@ -1,8 +1,8 @@
|
||||||
package org.betterx.bclib.client.gui.screens;
|
package org.betterx.bclib.client.gui.screens;
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.HelloClient;
|
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.HelloClient;
|
||||||
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
|
|
||||||
import org.betterx.bclib.util.Triple;
|
import org.betterx.bclib.util.Triple;
|
||||||
|
import org.betterx.ui.ColorUtil;
|
||||||
import org.betterx.ui.layout.components.HorizontalStack;
|
import org.betterx.ui.layout.components.HorizontalStack;
|
||||||
import org.betterx.ui.layout.components.LayoutComponent;
|
import org.betterx.ui.layout.components.LayoutComponent;
|
||||||
import org.betterx.ui.layout.components.Text;
|
import org.betterx.ui.layout.components.Text;
|
||||||
|
@ -196,29 +196,29 @@ public class ModListScreen extends BCLibLayoutScreen {
|
||||||
final int state = t.second;
|
final int state = t.second;
|
||||||
final String stateString = t.third;
|
final String stateString = t.third;
|
||||||
|
|
||||||
int color = GridLayout.COLOR_RED;
|
int color = ColorUtil.RED;
|
||||||
final String typeText;
|
final String typeText;
|
||||||
if (state == STATE_VERSION || state == STATE_VERSION_NOT_OFFERED || state == STATE_VERSION_CLIENT_ONLY) {
|
if (state == STATE_VERSION || state == STATE_VERSION_NOT_OFFERED || state == STATE_VERSION_CLIENT_ONLY) {
|
||||||
typeText = "[VERSION]";
|
typeText = "[VERSION]";
|
||||||
if (state == STATE_VERSION_NOT_OFFERED) {
|
if (state == STATE_VERSION_NOT_OFFERED) {
|
||||||
color = GridLayout.COLOR_YELLOW;
|
color = ColorUtil.YELLOW;
|
||||||
} else if (state == STATE_VERSION_CLIENT_ONLY) {
|
} else if (state == STATE_VERSION_CLIENT_ONLY) {
|
||||||
color = GridLayout.COLOR_DARK_GREEN;
|
color = ColorUtil.DARK_GREEN;
|
||||||
}
|
}
|
||||||
} else if (state == STATE_MISSING || state == STATE_MISSING_NOT_OFFERED) {
|
} else if (state == STATE_MISSING || state == STATE_MISSING_NOT_OFFERED) {
|
||||||
typeText = "[MISSING]";
|
typeText = "[MISSING]";
|
||||||
if (state == STATE_MISSING_NOT_OFFERED) {
|
if (state == STATE_MISSING_NOT_OFFERED) {
|
||||||
color = GridLayout.COLOR_YELLOW;
|
color = ColorUtil.YELLOW;
|
||||||
}
|
}
|
||||||
} else if (state == STATE_SERVER_MISSING || state == STATE_SERVER_MISSING_CLIENT_MOD) {
|
} else if (state == STATE_SERVER_MISSING || state == STATE_SERVER_MISSING_CLIENT_MOD) {
|
||||||
if (state == STATE_SERVER_MISSING_CLIENT_MOD) {
|
if (state == STATE_SERVER_MISSING_CLIENT_MOD) {
|
||||||
color = GridLayout.COLOR_CYAN;
|
color = ColorUtil.AQUA;
|
||||||
typeText = "[OK]";
|
typeText = "[OK]";
|
||||||
} else {
|
} else {
|
||||||
typeText = "[NOT ON SERVER]";
|
typeText = "[NOT ON SERVER]";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
color = GridLayout.COLOR_DARK_GREEN;
|
color = ColorUtil.DARK_GREEN;
|
||||||
typeText = "[OK]";
|
typeText = "[OK]";
|
||||||
}
|
}
|
||||||
Component dash = Component.literal("-");
|
Component dash = Component.literal("-");
|
||||||
|
@ -237,7 +237,7 @@ public class ModListScreen extends BCLibLayoutScreen {
|
||||||
row = grid.addRow();
|
row = grid.addRow();
|
||||||
row.addSpacer(4 + dashText.getContentWidth());
|
row.addSpacer(4 + dashText.getContentWidth());
|
||||||
row.addText(fit(), fit(), Component.literal(stateString))
|
row.addText(fit(), fit(), Component.literal(stateString))
|
||||||
.setColor(GridLayout.COLOR_GRAY);
|
.setColor(ColorUtil.GRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
grid.addSpacer(4);
|
grid.addSpacer(4);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.betterx.bclib.integration;
|
package org.betterx.bclib.integration;
|
||||||
|
|
||||||
import org.betterx.bclib.BCLib;
|
import org.betterx.bclib.BCLib;
|
||||||
import org.betterx.bclib.api.v2.levelgen.features.BCLFeature;
|
|
||||||
import org.betterx.worlds.together.tag.v3.TagManager;
|
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||||
|
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
|
@ -14,9 +13,7 @@ import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
|
||||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||||
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
@ -64,25 +61,6 @@ public abstract class ModIntegration {
|
||||||
return FabricLoader.getInstance().isModLoaded(modID);
|
return FabricLoader.getInstance().isModLoaded(modID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public BCLFeature getFeature(String featureID, String placedFeatureID, GenerationStep.Decoration featureStep) {
|
|
||||||
ResourceLocation id = getID(featureID);
|
|
||||||
Feature<?> feature = Registry.FEATURE.get(id);
|
|
||||||
Holder<PlacedFeature> featurePlaced = BuiltinRegistries.PLACED_FEATURE.getHolder(getFeatureKey(placedFeatureID))
|
|
||||||
.orElse(null);
|
|
||||||
return new BCLFeature(
|
|
||||||
id,
|
|
||||||
feature,
|
|
||||||
featureStep,
|
|
||||||
featurePlaced.value().getFeatures().map(f -> f.config()).findFirst().orElse(null),
|
|
||||||
featurePlaced
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public BCLFeature getFeature(String name, GenerationStep.Decoration featureStep) {
|
|
||||||
return getFeature(name, name, featureStep);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfiguredFeature<?, ?> getConfiguredFeature(String name) {
|
public ConfiguredFeature<?, ?> getConfiguredFeature(String name) {
|
||||||
return BuiltinRegistries.CONFIGURED_FEATURE.get(getID(name));
|
return BuiltinRegistries.CONFIGURED_FEATURE.get(getID(name));
|
||||||
|
|
|
@ -3,36 +3,18 @@ package org.betterx.bclib.items;
|
||||||
import org.betterx.bclib.BCLib;
|
import org.betterx.bclib.BCLib;
|
||||||
|
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.RecordItem;
|
import net.minecraft.world.item.RecordItem;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
public class BaseDiscItem extends RecordItem {
|
public class BaseDiscItem {
|
||||||
/**
|
public static RecordItem create(
|
||||||
* @param comparatorOutput
|
int comparatorOutput,
|
||||||
* @param sound
|
SoundEvent sound,
|
||||||
* @param settings
|
Item.Properties settings,
|
||||||
* @deprecated Please use {@link BaseDiscItem#create(int, SoundEvent, Properties, int)} instead
|
int lengthInSeconds
|
||||||
*/
|
) {
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public BaseDiscItem(int comparatorOutput, SoundEvent sound, Properties settings) {
|
|
||||||
this(comparatorOutput, sound, settings, 30);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param comparatorOutput
|
|
||||||
* @param sound
|
|
||||||
* @param settings
|
|
||||||
* @param lengthInSeconds
|
|
||||||
* @deprecated Please use {@link BaseDiscItem#create(int, SoundEvent, Properties, int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public BaseDiscItem(int comparatorOutput, SoundEvent sound, Properties settings, int lengthInSeconds) {
|
|
||||||
super(comparatorOutput, sound, settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RecordItem create(int comparatorOutput, SoundEvent sound, Properties settings, int lengthInSeconds) {
|
|
||||||
for (Constructor<?> c : RecordItem.class.getDeclaredConstructors()) {
|
for (Constructor<?> c : RecordItem.class.getDeclaredConstructors()) {
|
||||||
if (c.getParameterCount() == 4) {
|
if (c.getParameterCount() == 4) {
|
||||||
var types = c.getParameterTypes();
|
var types = c.getParameterTypes();
|
||||||
|
@ -40,7 +22,7 @@ public class BaseDiscItem extends RecordItem {
|
||||||
if (
|
if (
|
||||||
types[0].isAssignableFrom(int.class)
|
types[0].isAssignableFrom(int.class)
|
||||||
&& types[1].isAssignableFrom(SoundEvent.class)
|
&& types[1].isAssignableFrom(SoundEvent.class)
|
||||||
&& types[2].isAssignableFrom(Properties.class)
|
&& types[2].isAssignableFrom(Item.Properties.class)
|
||||||
&& types[3].isAssignableFrom(int.class)
|
&& types[3].isAssignableFrom(int.class)
|
||||||
) {
|
) {
|
||||||
c.setAccessible(true);
|
c.setAccessible(true);
|
||||||
|
@ -57,7 +39,7 @@ public class BaseDiscItem extends RecordItem {
|
||||||
if (
|
if (
|
||||||
types[0].isAssignableFrom(int.class)
|
types[0].isAssignableFrom(int.class)
|
||||||
&& types[1].isAssignableFrom(SoundEvent.class)
|
&& types[1].isAssignableFrom(SoundEvent.class)
|
||||||
&& types[2].isAssignableFrom(Properties.class)
|
&& types[2].isAssignableFrom(Item.Properties.class)
|
||||||
) {
|
) {
|
||||||
c.setAccessible(true);
|
c.setAccessible(true);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package org.betterx.bclib.presets;
|
|
||||||
|
|
||||||
import org.betterx.worlds.together.tag.v3.TagRegistry;
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorPreset;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link org.betterx.worlds.together.flatLevel.FlatLevelPresets} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class FlatLevelPresets {
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link org.betterx.worlds.together.flatLevel.FlatLevelPresets#FLAT_LEVEL_PRESETS} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static TagRegistry.Simple<FlatLevelGeneratorPreset> FLAT_LEVEL_PRESETS = org.betterx.worlds.together.flatLevel.FlatLevelPresets.FLAT_LEVEL_PRESETS;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link org.betterx.worlds.together.flatLevel.FlatLevelPresets#register(ResourceLocation)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static ResourceKey<FlatLevelGeneratorPreset> register(ResourceLocation loc) {
|
|
||||||
return org.betterx.worlds.together.flatLevel.FlatLevelPresets.register(loc);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,7 +7,6 @@ import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.ClipContext.Fluid;
|
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
@ -326,17 +325,6 @@ public class BlocksHelper {
|
||||||
return state.getFluidState().getType() instanceof LavaFluid;
|
return state.getFluidState().getType() instanceof LavaFluid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if block is {@link Fluid} or not.
|
|
||||||
*
|
|
||||||
* @param state - {@link BlockState} to check.
|
|
||||||
* @return {@code true} if block is fluid and {@code false} if not.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static boolean isFluidOld(BlockState state) {
|
|
||||||
return !state.getFluidState().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isFluid(BlockState state) {
|
public static boolean isFluid(BlockState state) {
|
||||||
return state.getMaterial().isLiquid();
|
return state.getMaterial().isLiquid();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.betterx.bclib.util;
|
package org.betterx.bclib.util;
|
||||||
|
|
||||||
|
import org.betterx.ui.ColorUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -1,165 +0,0 @@
|
||||||
package org.betterx.bclib.util;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.NativeImage;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
import net.fabricmc.fabric.impl.client.indigo.renderer.helper.ColorHelper;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class ColorUtil {
|
|
||||||
private static final float[] FLOAT_BUFFER = new float[4];
|
|
||||||
private static final int ALPHA = 255 << 24;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#color(int, int, int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int color(int r, int g, int b) {
|
|
||||||
return ALPHA | (r << 16) | (g << 8) | b;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#color(String)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int color(String hex) {
|
|
||||||
int r = Integer.parseInt(hex.substring(0, 2), 16);
|
|
||||||
int g = Integer.parseInt(hex.substring(2, 4), 16);
|
|
||||||
int b = Integer.parseInt(hex.substring(4, 6), 16);
|
|
||||||
return color(r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#toIntArray(int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int[] toIntArray(int color) {
|
|
||||||
return new int[]{(color >> 24) & 255, (color >> 16) & 255, (color >> 8) & 255, color & 255};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#toFloatArray(int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static float[] toFloatArray(int color) {
|
|
||||||
FLOAT_BUFFER[0] = ((color >> 16 & 255) / 255.0F);
|
|
||||||
FLOAT_BUFFER[1] = ((color >> 8 & 255) / 255.0F);
|
|
||||||
FLOAT_BUFFER[2] = ((color & 255) / 255.0F);
|
|
||||||
FLOAT_BUFFER[3] = ((color >> 24 & 255) / 255.0F);
|
|
||||||
|
|
||||||
return FLOAT_BUFFER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#RGBtoHSB(int, int, int, float[])} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static float[] RGBtoHSB(int r, int g, int b, float[] hsbvals) {
|
|
||||||
return org.betterx.ui.ColorUtil.RGBtoHSB(r, g, b, hsbvals);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#HSBtoRGB(float, float, float)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int HSBtoRGB(float hue, float saturation, float brightness) {
|
|
||||||
return org.betterx.ui.ColorUtil.HSBtoRGB(hue, saturation, brightness);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#parseHex(String)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int parseHex(String hexColor) {
|
|
||||||
return org.betterx.ui.ColorUtil.parseHex(hexColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#toABGR(int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int toABGR(int color) {
|
|
||||||
int r = (color >> 16) & 255;
|
|
||||||
int g = (color >> 8) & 255;
|
|
||||||
int b = color & 255;
|
|
||||||
return 0xFF000000 | b << 16 | g << 8 | r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#ABGRtoARGB(int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int ABGRtoARGB(int color) {
|
|
||||||
int a = (color >> 24) & 255;
|
|
||||||
int b = (color >> 16) & 255;
|
|
||||||
int g = (color >> 8) & 255;
|
|
||||||
int r = color & 255;
|
|
||||||
return a << 24 | r << 16 | g << 8 | b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#colorBrigtness(int, float)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int colorBrigtness(int color, float val) {
|
|
||||||
RGBtoHSB((color >> 16) & 255, (color >> 8) & 255, color & 255, FLOAT_BUFFER);
|
|
||||||
FLOAT_BUFFER[2] += val / 10.0F;
|
|
||||||
FLOAT_BUFFER[2] = Mth.clamp(FLOAT_BUFFER[2], 0.0F, 1.0F);
|
|
||||||
return HSBtoRGB(FLOAT_BUFFER[0], FLOAT_BUFFER[1], FLOAT_BUFFER[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#applyTint(int, int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int applyTint(int color, int tint) {
|
|
||||||
return colorBrigtness(ColorHelper.multiplyColor(color, tint), 1.5F);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#colorDistance(int, int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int colorDistance(int color1, int color2) {
|
|
||||||
int r1 = (color1 >> 16) & 255;
|
|
||||||
int g1 = (color1 >> 8) & 255;
|
|
||||||
int b1 = color1 & 255;
|
|
||||||
int r2 = (color2 >> 16) & 255;
|
|
||||||
int g2 = (color2 >> 8) & 255;
|
|
||||||
int b2 = color2 & 255;
|
|
||||||
return MHelper.sqr(r1 - r2) + MHelper.sqr(g1 - g2) + MHelper.sqr(b1 - b2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Map<ResourceLocation, Integer> colorPalette = Maps.newHashMap();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#extractColor(Item)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public static int extractColor(Item item) {
|
|
||||||
return org.betterx.ui.ColorUtil.extractColor(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#loadImage(ResourceLocation, int, int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public static NativeImage loadImage(ResourceLocation image, int w, int h) {
|
|
||||||
return org.betterx.ui.ColorUtil.loadImage(image, w, h);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,72 +0,0 @@
|
||||||
package org.betterx.bclib.util;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.Level;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.worlds.together.util.Logger} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public final class Logger {
|
|
||||||
private static final org.apache.logging.log4j.Logger LOGGER = LogManager.getLogger();
|
|
||||||
private final String modPref;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please use {@link org.betterx.worlds.together.util.Logger#Logger(String)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public Logger(String modID) {
|
|
||||||
this.modPref = "[" + modID + "] ";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void log(Level level, String message) {
|
|
||||||
LOGGER.log(level, modPref + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void log(Level level, String message, Object... params) {
|
|
||||||
LOGGER.log(level, modPref + message, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void debug(Object message) {
|
|
||||||
this.log(Level.DEBUG, message.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void debug(Object message, Object... params) {
|
|
||||||
this.log(Level.DEBUG, message.toString(), params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void catching(Throwable ex) {
|
|
||||||
this.error(ex.getLocalizedMessage());
|
|
||||||
LOGGER.catching(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void info(String message) {
|
|
||||||
this.log(Level.INFO, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void info(String message, Object... params) {
|
|
||||||
this.log(Level.INFO, message, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void warning(String message, Object... params) {
|
|
||||||
this.log(Level.WARN, message, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void warning(String message, Object obj, Exception ex) {
|
|
||||||
LOGGER.warn(modPref + message, obj, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void error(String message) {
|
|
||||||
this.log(Level.ERROR, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void error(String message, Object obj, Exception ex) {
|
|
||||||
LOGGER.error(modPref + message, obj, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void error(String message, Exception ex) {
|
|
||||||
LOGGER.error(modPref + message, ex);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,12 +19,6 @@ public class MethodReplace {
|
||||||
MethodReplace.item = item;
|
MethodReplace.item = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void addBlockReplace(Block block, Function<BlockStateBase, Boolean> blockReplace) {
|
|
||||||
MethodReplace.blockReplace = blockReplace;
|
|
||||||
MethodReplace.block = block;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Function<ItemStack, Boolean> getItemReplace(Item item) {
|
public static Function<ItemStack, Boolean> getItemReplace(Item item) {
|
||||||
if (MethodReplace.item != item) {
|
if (MethodReplace.item != item) {
|
||||||
|
@ -34,15 +28,4 @@ public class MethodReplace {
|
||||||
itemReplace = null;
|
itemReplace = null;
|
||||||
return replace;
|
return replace;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static Function<BlockStateBase, Boolean> getBlockReplace(Block block) {
|
|
||||||
if (MethodReplace.block != block) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Function<BlockStateBase, Boolean> replace = blockReplace;
|
|
||||||
blockReplace = null;
|
|
||||||
return replace;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,439 +0,0 @@
|
||||||
package org.betterx.bclib.util;
|
|
||||||
|
|
||||||
import org.betterx.bclib.BCLib;
|
|
||||||
import org.betterx.worlds.together.WorldsTogether;
|
|
||||||
import org.betterx.worlds.together.util.PathUtil;
|
|
||||||
|
|
||||||
import net.fabricmc.loader.api.*;
|
|
||||||
import net.fabricmc.loader.api.metadata.*;
|
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.google.gson.stream.JsonReader;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.FileSystem;
|
|
||||||
import java.nio.file.FileSystems;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class ModUtil {
|
|
||||||
private static Map<String, ModInfo> mods;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#invalidateCachedMods()}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void invalidateCachedMods() {
|
|
||||||
mods = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#getMods()} ()}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static Map<String, ModInfo> getMods() {
|
|
||||||
if (mods != null) return mods;
|
|
||||||
|
|
||||||
mods = new HashMap<>();
|
|
||||||
PathUtil.fileWalker(PathUtil.MOD_FOLDER.toFile(), false, (ModUtil::accept));
|
|
||||||
|
|
||||||
return mods;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ModMetadata readJSON(InputStream is, String sourceFile) throws IOException {
|
|
||||||
try (com.google.gson.stream.JsonReader reader = new JsonReader(new InputStreamReader(
|
|
||||||
is,
|
|
||||||
StandardCharsets.UTF_8
|
|
||||||
))) {
|
|
||||||
JsonObject data = JsonParser.parseReader(reader)
|
|
||||||
.getAsJsonObject();
|
|
||||||
Version ver;
|
|
||||||
try {
|
|
||||||
ver = SemanticVersion.parse(data.get("version").getAsString());
|
|
||||||
} catch (VersionParsingException e) {
|
|
||||||
BCLib.LOGGER.error("Unable to parse Version in " + sourceFile);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.get("id") == null) {
|
|
||||||
BCLib.LOGGER.error("Unable to read ID in " + sourceFile);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.get("name") == null) {
|
|
||||||
BCLib.LOGGER.error("Unable to read name in " + sourceFile);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ModMetadata() {
|
|
||||||
@Override
|
|
||||||
public Version getVersion() {
|
|
||||||
return ver;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getType() {
|
|
||||||
return "fabric";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return data.get("id")
|
|
||||||
.getAsString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<String> getProvides() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ModEnvironment getEnvironment() {
|
|
||||||
JsonElement env = data.get("environment");
|
|
||||||
if (env == null) {
|
|
||||||
BCLib.LOGGER.warning("No environment specified in " + sourceFile);
|
|
||||||
//return ModEnvironment.UNIVERSAL;
|
|
||||||
}
|
|
||||||
final String environment = env == null ? "" : env.getAsString()
|
|
||||||
.toLowerCase(Locale.ROOT);
|
|
||||||
|
|
||||||
if (environment.isEmpty() || environment.equals("*") || environment.equals("\"*\"") || environment.equals(
|
|
||||||
"common")) {
|
|
||||||
JsonElement entrypoints = data.get("entrypoints");
|
|
||||||
boolean hasClient = true;
|
|
||||||
|
|
||||||
//check if there is an actual client entrypoint
|
|
||||||
if (entrypoints != null && entrypoints.isJsonObject()) {
|
|
||||||
JsonElement client = entrypoints.getAsJsonObject()
|
|
||||||
.get("client");
|
|
||||||
if (client != null && client.isJsonArray()) {
|
|
||||||
hasClient = client.getAsJsonArray()
|
|
||||||
.size() > 0;
|
|
||||||
} else if (client == null || !client.isJsonPrimitive()) {
|
|
||||||
hasClient = false;
|
|
||||||
} else if (!client.getAsJsonPrimitive()
|
|
||||||
.isString()) {
|
|
||||||
hasClient = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (hasClient == false) return ModEnvironment.SERVER;
|
|
||||||
return ModEnvironment.UNIVERSAL;
|
|
||||||
} else if (environment.equals("client")) {
|
|
||||||
return ModEnvironment.CLIENT;
|
|
||||||
} else if (environment.equals("server")) {
|
|
||||||
return ModEnvironment.SERVER;
|
|
||||||
} else {
|
|
||||||
BCLib.LOGGER.error("Unable to read environment in " + sourceFile);
|
|
||||||
return ModEnvironment.UNIVERSAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<ModDependency> getDepends() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<ModDependency> getRecommends() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<ModDependency> getSuggests() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<ModDependency> getConflicts() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<ModDependency> getBreaks() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<ModDependency> getDependencies() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return data.get("name")
|
|
||||||
.getAsString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<Person> getAuthors() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<Person> getContributors() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ContactInformation getContact() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<String> getLicense() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<String> getIconPath(int size) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean containsCustomValue(String key) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CustomValue getCustomValue(String key) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, CustomValue> getCustomValues() {
|
|
||||||
return new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean containsCustomElement(String key) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JsonElement getCustomElement(String key) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#getModInfo(String)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static ModInfo getModInfo(String modID) {
|
|
||||||
return getModInfo(modID, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#getModInfo(String, boolean)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static ModInfo getModInfo(String modID, boolean matchVersion) {
|
|
||||||
getMods();
|
|
||||||
final ModInfo mi = mods.get(modID);
|
|
||||||
if (mi == null || (matchVersion && !org.betterx.worlds.together.util.ModUtil.getModVersion(modID)
|
|
||||||
.equals(mi.getVersion())))
|
|
||||||
return null;
|
|
||||||
return mi;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#getModVersion(String)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static String getModVersion(String modID) {
|
|
||||||
if (modID == WorldsTogether.MOD_ID) modID = BCLib.MOD_ID;
|
|
||||||
|
|
||||||
Optional<ModContainer> optional = FabricLoader.getInstance()
|
|
||||||
.getModContainer(modID);
|
|
||||||
if (optional.isPresent()) {
|
|
||||||
ModContainer modContainer = optional.get();
|
|
||||||
return org.betterx.worlds.together.util.ModUtil.ModInfo.versionToString(modContainer.getMetadata()
|
|
||||||
.getVersion());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return org.betterx.worlds.together.util.ModUtil.getModVersionFromJar(modID);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#getModVersionFromJar(String)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static String getModVersionFromJar(String modID) {
|
|
||||||
final ModInfo mi = getModInfo(modID, false);
|
|
||||||
if (mi != null) return mi.getVersion();
|
|
||||||
|
|
||||||
return "0.0.0";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#convertModVersion(String)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int convertModVersion(String version) {
|
|
||||||
if (version.isEmpty()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
int res = 0;
|
|
||||||
final String semanticVersionPattern = "(\\d+)\\.(\\d+)(\\.(\\d+))?\\D*";
|
|
||||||
final Matcher matcher = Pattern.compile(semanticVersionPattern)
|
|
||||||
.matcher(version);
|
|
||||||
if (matcher.find()) {
|
|
||||||
if (matcher.groupCount() > 0)
|
|
||||||
res = matcher.group(1) == null ? 0 : ((Integer.parseInt(matcher.group(1)) & 0xFF) << 22);
|
|
||||||
if (matcher.groupCount() > 1)
|
|
||||||
res |= matcher.group(2) == null ? 0 : ((Integer.parseInt(matcher.group(2)) & 0xFF) << 14);
|
|
||||||
if (matcher.groupCount() > 3)
|
|
||||||
res |= matcher.group(4) == null ? 0 : Integer.parseInt(matcher.group(4)) & 0x3FFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#convertModVersion(int)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static String convertModVersion(int version) {
|
|
||||||
int a = (version >> 22) & 0xFF;
|
|
||||||
int b = (version >> 14) & 0xFF;
|
|
||||||
int c = version & 0x3FFF;
|
|
||||||
return String.format(Locale.ROOT, "%d.%d.%d", a, b, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#isLargerVersion(String, String)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static boolean isLargerVersion(String v1, String v2) {
|
|
||||||
return org.betterx.worlds.together.util.ModUtil.convertModVersion(v1) > org.betterx.worlds.together.util.ModUtil.convertModVersion(
|
|
||||||
v2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#isLargerOrEqualVersion(String, String)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static boolean isLargerOrEqualVersion(String v1, String v2) {
|
|
||||||
return org.betterx.worlds.together.util.ModUtil.convertModVersion(v1) >= org.betterx.worlds.together.util.ModUtil.convertModVersion(
|
|
||||||
v2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void accept(Path file) {
|
|
||||||
try {
|
|
||||||
URI uri = URI.create("jar:" + file.toUri());
|
|
||||||
|
|
||||||
FileSystem fs;
|
|
||||||
// boolean doClose = false;
|
|
||||||
try {
|
|
||||||
fs = FileSystems.getFileSystem(uri);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// doClose = true;
|
|
||||||
fs = FileSystems.newFileSystem(file);
|
|
||||||
}
|
|
||||||
if (fs != null) {
|
|
||||||
try {
|
|
||||||
Path modMetaFile = fs.getPath("fabric.mod.json");
|
|
||||||
if (modMetaFile != null) {
|
|
||||||
try (InputStream is = Files.newInputStream(modMetaFile)) {
|
|
||||||
//ModMetadata mc = ModMetadataParser.parseMetadata(is, uri.toString(), new LinkedList<String>());
|
|
||||||
ModMetadata mc = readJSON(is, uri.toString());
|
|
||||||
if (mc != null) {
|
|
||||||
mods.put(mc.getId(), new ModInfo(mc, file));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
BCLib.LOGGER.error("Error for " + uri + ": " + e);
|
|
||||||
}
|
|
||||||
//if (doClose) fs.close();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
BCLib.LOGGER.error("Error for " + file.toUri() + ": " + e);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil.ModInfo}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static class ModInfo {
|
|
||||||
public final ModMetadata metadata;
|
|
||||||
public final Path jarPath;
|
|
||||||
|
|
||||||
ModInfo(ModMetadata metadata, Path jarPath) {
|
|
||||||
this.metadata = metadata;
|
|
||||||
this.jarPath = jarPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil.ModInfo#versionToString(Version)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static String versionToString(Version v) {
|
|
||||||
if (v instanceof SemanticVersion) {
|
|
||||||
return org.betterx.worlds.together.util.ModUtil.ModInfo.versionToString((SemanticVersion) v);
|
|
||||||
}
|
|
||||||
return org.betterx.worlds.together.util.ModUtil.convertModVersion(
|
|
||||||
org.betterx.worlds.together.util.ModUtil.convertModVersion(v.toString())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil.ModInfo#versionToString(SemanticVersion)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static String versionToString(SemanticVersion v) {
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
boolean first = true;
|
|
||||||
final int cCount = Math.min(v.getVersionComponentCount(), 3);
|
|
||||||
for (int i = 0; i < cCount; i++) {
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
stringBuilder.append('.');
|
|
||||||
}
|
|
||||||
|
|
||||||
stringBuilder.append(v.getVersionComponent(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return stringBuilder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "ModInfo{" + "id=" + metadata.getId() + ", version=" + metadata.getVersion() + ", jarPath=" + jarPath + '}';
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVersion() {
|
|
||||||
if (metadata == null) {
|
|
||||||
return "0.0.0";
|
|
||||||
}
|
|
||||||
return org.betterx.worlds.together.util.ModUtil.ModInfo.versionToString(metadata.getVersion());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
package org.betterx.bclib.util;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public class PathUtil {
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#GAME_FOLDER}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public final static Path GAME_FOLDER = org.betterx.worlds.together.util.PathUtil.GAME_FOLDER;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#MOD_FOLDER}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public final static Path MOD_FOLDER = org.betterx.worlds.together.util.PathUtil.MOD_FOLDER;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#MOD_BAK_FOLDER}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public final static Path MOD_BAK_FOLDER = org.betterx.worlds.together.util.PathUtil.MOD_BAK_FOLDER;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#isChildOf(Path, Path)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static boolean isChildOf(Path parent, Path child) {
|
|
||||||
return org.betterx.worlds.together.util.PathUtil.isChildOf(parent, child);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#fileWalker(File, Consumer)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void fileWalker(File path, Consumer<Path> pathConsumer) {
|
|
||||||
org.betterx.worlds.together.util.PathUtil.fileWalker(path, pathConsumer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#fileWalker(File, boolean, Consumer)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static void fileWalker(File path, boolean recursive, Consumer<Path> pathConsumer) {
|
|
||||||
org.betterx.worlds.together.util.PathUtil.fileWalker(path, recursive, pathConsumer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#humanReadableFileSize(long)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static String humanReadableFileSize(long size) {
|
|
||||||
return org.betterx.worlds.together.util.PathUtil.humanReadableFileSize(size);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.betterx.worlds.together.tag.v3;
|
package org.betterx.worlds.together.tag.v3;
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
|
||||||
import org.betterx.worlds.together.WorldsTogether;
|
import org.betterx.worlds.together.WorldsTogether;
|
||||||
|
|
||||||
import net.minecraft.core.DefaultedRegistry;
|
import net.minecraft.core.DefaultedRegistry;
|
||||||
|
@ -100,24 +99,6 @@ public class TagRegistry<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds one Tag to multiple Elements.
|
|
||||||
*
|
|
||||||
* @param tagID {@link TagKey< Biome >} tag ID.
|
|
||||||
* @param elements array of Elements to add into tag.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public void add(TagKey<Biome> tagID, BCLBiome... elements) {
|
|
||||||
if (isFrozen) WorldsTogether.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
|
||||||
Set<TagEntry> set = getSetForTag(tagID);
|
|
||||||
for (BCLBiome element : elements) {
|
|
||||||
ResourceLocation id = element.getID();
|
|
||||||
if (id != null) {
|
|
||||||
set.add(TagEntry.element(id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagKey<Biome> makeStructureTag(String modID, String name) {
|
public TagKey<Biome> makeStructureTag(String modID, String name) {
|
||||||
return makeTag(modID, "has_structure/" + name);
|
return makeTag(modID, "has_structure/" + name);
|
||||||
}
|
}
|
||||||
|
@ -274,25 +255,6 @@ public class TagRegistry<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
protected void add(ResourceLocation tagID, T... elements) {
|
|
||||||
if (isFrozen) WorldsTogether.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
|
||||||
Set<TagEntry> set = getSetForTag(tagID);
|
|
||||||
for (T element : elements) {
|
|
||||||
ResourceLocation id = locationProvider.apply(element);
|
|
||||||
if (id != null) {
|
|
||||||
set.add(TagEntry.element(id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
protected void add(T element, ResourceLocation... tagIDs) {
|
|
||||||
for (ResourceLocation tagID : tagIDs) {
|
|
||||||
add(tagID, element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void forEach(BiConsumer<ResourceLocation, Set<TagEntry>> consumer) {
|
public void forEach(BiConsumer<ResourceLocation, Set<TagEntry>> consumer) {
|
||||||
tags.forEach(consumer);
|
tags.forEach(consumer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue