Jump to content

Recommended Posts

Posted (edited)

Hello. I want my ore to generate on the clay of rivers and lakes so I have try the following:
 

public class ModOreGen {
    public static void generateOre() {
        for (Biome biome : ForgeRegistries.BIOMES) {
            ConfiguredPlacement config = Placement.COUNT_RANGE.configure(new CountRangeConfig(30, 0, 0, 200));
            biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.create("CLAY", "clay", new BlockMatcher(Blocks.CLAY)), ModBlocks.EMBER_CLAY.get().getDefaultState(), 2)).withPlacement(config));
        }
    }
}

That I call in the main class as follows:
 

    private void setup(final FMLCommonSetupEvent event) {
        DeferredWorkQueue.runLater(ModOreGen::generateOre);
    }

But it doesn't seem to work.
I was hopping someone can tell me how to make this work. Thanks in advance! 😃
 

 

My full main just in case:
 

package mod.edelmeyder.dharma;

import mod.edelmeyder.dharma.init.ModBlocks;
import mod.edelmeyder.dharma.init.ModItemGroups;
import mod.edelmeyder.dharma.init.ModItems;
import mod.edelmeyder.dharma.world.gen.ModOreGen;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DeferredWorkQueue;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.IForgeRegistry;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;


@Mod(Dharma.MODID)
@EventBusSubscriber(modid = Dharma.MODID, bus = EventBusSubscriber.Bus.MOD)
public class Dharma {
    public static final String MODID = "dharma";

    public static final Logger LOGGER = LogManager.getLogger();
    public Dharma() {
        LOGGER.debug("Namaste from Dharma");
        final IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
        eventBus.addListener(this::setup);

        ModItems.ITEMS.register(eventBus);
        ModBlocks.BLOCKS.register(eventBus);

    }

    @SubscribeEvent
    public static void onRegisterItems(final RegistryEvent.Register<Item> event) {
        final IForgeRegistry<Item> registry = event.getRegistry();

        ModBlocks.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(block -> {
            final Item.Properties properties = new Item.Properties().group(ModItemGroups.DHARMA);
            final BlockItem blockItem = new BlockItem(block, properties);
            blockItem.setRegistryName(block.getRegistryName());
            registry.register(blockItem);
        });
    }

    private void setup(final FMLCommonSetupEvent event) {
        DeferredWorkQueue.runLater(ModOreGen::generateOre);
    }
}

 

Edited by Edelmeyder
Posted
10 hours ago, Beethoven92 said:

try using the Placement#COUNT_TOP_SOLID and set a high frequency..try and tweak the values to your liking

Like this?
 

public class ModOreGen {
    public static void generateOre() {
        for (Biome biome : ForgeRegistries.BIOMES) {
            ConfiguredPlacement config = Placement.COUNT_TOP_SOLID.configure(new FrequencyConfig(100));
            biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.create("CLAY", "clay", new BlockMatcher(Blocks.CLAY)), ModBlocks.EMBER_CLAY.get().getDefaultState(), 2)).withPlacement(config));
            Dharma.LOGGER.debug(biome.getDisplayName().toString() + "added ember clay");
        }
    }
}

If so, it didn't work, I tried with frequency 1, 5, 10 and 100 and nothing...
I added that debug line to make sure the method was running and it is.

I also made this weird debug feature to find the ore if they would generate:
 

@SubscribeEvent
    public static void TestJumpEvent(LivingEvent.LivingJumpEvent event){
        LivingEntity entity = event.getEntityLiving();
        World world = entity.world;
        if (entity.getHeldItemMainhand().getItem() == ModBlocks.EMBER_CLAY.get().asItem()){
            Minecraft.getInstance().player.sendChatMessage("Hello");
            for (int y = 0; y < 156; y++){
                for (int x = entity.getPosition().getX() - 250; x < entity.getPosition().getX() + 250; x++){
                    for (int z = entity.getPosition().getZ() - 250; z < entity.getPosition().getZ() + 250; z++){
                        if (world.getBlockState(new BlockPos(x,y,z)) == ModBlocks.EMBER_CLAY.get().getDefaultState()) {
                            Minecraft.getInstance().player.sendChatMessage(x + " " + y + " " + z);
                        }
                    }
                }
            }
            Minecraft.getInstance().player.sendChatMessage("Bye");
        }
    }

And it finds the ember clay when I place it either manually or with the fill command... But didn't found none naturally generated...

Posted

I managed to make it work.
I don't know why but apparently this line was not working:

ConfiguredPlacement config = Placement.COUNT_RANGE.configure(new CountRangeConfig(30, 0, 0, 200));

So I moved it inside the brackets for withPlacement() and it works. Like so:
 

public class ModOreGen {
    public static void generateOre() {
        for (Biome biome : ForgeRegistries.BIOMES) {
            biome.addFeature(Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.create("CLAY", "clay", new BlockMatcher(Blocks.CLAY)), ModBlocks.EMBER_CLAY.get().getDefaultState(), 6)).withPlacement(Placement.COUNT_RANGE.configure(new CountRangeConfig(500, 50, 0, 70))));
            Dharma.LOGGER.debug(biome.getDisplayName().toString() + "added ember clay");
        }
    }
}

With those values I get at least 1 ember clay block in almost every clay patch.

Posted

It works because you raised the rarity from 30 to 500, thats a big step 😉 ...it was tecnically working even before..but the rarity was too low...remember you were trying to replace clay blocks...and think about how few of them generates in the world (compared to stone for example)...so with rarity set to 30 the chances for your block to generate were simply too low

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.