I have been working on a mod which adds minerals, the problem is that when they are generated, they ignore the maximum and minimum height that is established.
The main:
@Mod("examplemod")
public class ExampleMod {
public static ExampleMod instance;
public static final String modid = "examplemod";
private static final Logger LOGGER = LogManager.getLogger("examplemod");
public static final CreativeModeTab examplemod = new ExampleTab();
public ExampleMod() {
instance = this;
ExampleBlocks.BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());
ExampleItems.ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
ModLoadingContext.get().registerConfig(Type.COMMON, ExampleModConfig.SPEC, "example-common.toml");
MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, OreGeneration::generateOres);
MinecraftForge.EVENT_BUS.register(this);
}
private void setup(final FMLCommonSetupEvent event) {
LOGGER.info("Hello from preinit");
LOGGER.info("Dirt block >> {}", Blocks.DIRT.getRegistryName());
}
@OnlyIn(Dist.CLIENT)
public void clientSetup(FMLClientSetupEvent event) {
LOGGER.info("Hello from client setup");
}
@SubscribeEvent
public void serverStarting(FMLServerStartingEvent event) {
LOGGER.info("Hello from server starting");
}
@EventBusSubscriber(bus = Bus.MOD)
public static class RegistryEvents {
public RegistryEvents() {
}
@SubscribeEvent
public static void registerBlocks(final RegistryEvent.Register<Block> event) {
LOGGER.info("Hello from Register Block");
}
@SubscribeEvent
public static void registerItems(final RegistryEvent.Register<Item> event) {
LOGGER.info("Hello from Register Item");
}
@SubscribeEvent
public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) {
LOGGER.info("Hello from Register Entity");
}
@SubscribeEvent
public static void registerEnchantments(final RegistryEvent.Register<Enchantment> event) {
LOGGER.info("Hello from Register Enchantment");
}
@SubscribeEvent
public static void registerSounds(final RegistryEvent.Register<SoundEvent> event) {
LOGGER.info("Hello from Register Sound");
}
}
}
OreGeneration:
public class OreGeneration {
public OreGeneration() {
}
public static void generateOres(final BiomeLoadingEvent event) {
if (!event.getCategory().equals(Biome.BiomeCategory.NETHER) && !event.getCategory().equals(Biome.BiomeCategory.THEEND)) {
exampleOreGenerate(event.getGeneration(), Predicates.NATURAL_STONE, ((Block) ExampleBlocks.EXAMPLE_ORE.get()).defaultBlockState(), (Integer) ExampleConfig.EXAMPLE_ORE_SIZE.get(), (Integer) ExampleConfig.EXAMPLE_ORE_MIN_HEIGHT.get(), (Integer) ExampleConfig.EXAMPLE_ORE_MAX_HEIGHT.get(), (Integer) ExampleConfig.EXAMPLE_ORE_AMOUNT.get());
}
}
private static void exampleOreGenerate(BiomeGenerationSettingsBuilder settings, RuleTest fillerType, BlockState state, int veinSize, int minHeight, int maxHeight, int amount) {
settings.addFeature(Decoration.UNDERGROUND_ORES, (ConfiguredFeature)((ConfiguredFeature)((ConfiguredFeature) Feature.ORE.configured(new OreConfiguration(fillerType, state, veinSize)).rangeUniform(VerticalAnchor.aboveBottom(minHeight), VerticalAnchor.belowTop(maxHeight))).squared()).count(amount));
}
}
The configuration:
public class ExampleConfig {
public static final Builder BUILDER = new Builder();
public static final ForgeConfigSpec SPEC;
public static final ConfigValue<Boolean> EXAMPLE_ORE_GENERATION;
public static final ConfigValue<Integer> EXAMPLE_ORE_SIZE;
public static final ConfigValue<Integer> EXAMPLE_ORE_MIN_HEIGHT;
public static final ConfigValue<Integer> EXAMPLE_ORE_MAX_HEIGHT;
public static final ConfigValue<Integer> EXAMPLE_ORE_AMOUNT;
public ExampleConfig() {
}
static {
BUILDER.push("Example ore generation");
EXAMPLE_ORE_GENERATION = BUILDER.define("Generate example ore", true);
EXAMPLE_ORE_SIZE = BUILDER.define("Example ore vein size", 8);
EXAMPLE_ORE_MIN_HEIGHT = BUILDER.define("Minimum example ore generation height", 16);
EXAMPLE_ORE_MAX_HEIGHT = BUILDER.define("Maximum example ore generation height", 32);
EXAMPLE_ORE_AMOUNT = BUILDER.define("Amount of generate example ore", 31); <- This is the value
BUILDER.pop();
SPEC = BUILDER.build();
}
}
It seems that the problem is in the "amount" parameter, since if I change it, it will not The mineral is generated, or it is generated as it should not, if I set it to a value of 16 or less, the mineral is not generated, but if I set it to a value of 17 or greater, it is generated ignoring the maximum and minimum height established.