Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I am making a mod which adds a few new ores. Some ores generate in the overworld and some in the nether the way I want it.

But now I want to generate ores in the end (replace endstone). What is the easiest and most uncomplicated method to do this?

I am new to forge modding and dont know very much about forge and java.

Thanks for Help!

 

EDIT: The ore now generates in the end! Thanks!

Edited by Maxi07

Add a configurated feature in the biome (probably an OreFeature if generated in clusters) with your own FillerBlockType created using FillerBlockType#create. If you're generating clusters of one, use ReplaceBlockFeature where you only need to provide a blockstate of the target and new state. Remember to call these methods within a DeferredWorkQueue within your FMLCommonSetupEvent as they are not thread-safe.

  • Author

But now I have another question about this:

What is a DeferredWorkQueue or DefferedRegister? My Mod works without this.

I am using the IForgeRegistry from the item register event to register my items (If I understand my own code right). Here is the code:

package maxi.ores_cores.init;

import maxi.ores_cores.OresCores;
import maxi.ores_cores.items.*;
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent.Register;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.registries.IForgeRegistry;

@EventBusSubscriber(modid = OresCores.MODID, bus = Bus.MOD)
public class RegisterItems {
	
	public static final EmoulriteIngotItem EMOULRITE_INGOT = new EmoulriteIngotItem();
	public static final EmoulriteFragmentItem EMOULRITE_FRAGMENT = new EmoulriteFragmentItem();
	public static final TeleriteIngotItem TELERITE_INGOT = new TeleriteIngotItem();

	@SubscribeEvent
	public static void registerItem(Register<Item> event) {
		final IForgeRegistry<Item> registry = event.getRegistry();
		registry.register(EMOULRITE_INGOT.setRegistryName(OresCores.MODID, "emoulrite_ingot"));
		registry.register(EMOULRITE_FRAGMENT.setRegistryName(OresCores.MODID, "emoulrite_fragment"));
		registry.register(TELERITE_INGOT.setRegistryName(OresCores.MODID, "telerite_ingot"));
	}
}

Because I am new my code isnt very good I think. I want to learn much more about java and forge to write better code and create better mods.

And here is the code for the ore gen for my end ore:

package maxi.ores_cores.world.gen;

import maxi.ores_cores.init.RegisterBlocks;
import net.minecraft.block.Blocks;
import net.minecraft.block.pattern.BlockMatcher;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.placement.ConfiguredPlacement;
import net.minecraft.world.gen.placement.CountRangeConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.registries.ForgeRegistries;

public class TeleriteOreGen {
	
	public static void generateOre() {
		for(Biome biome : ForgeRegistries.BIOMES) {
			ConfiguredPlacement<CountRangeConfig> genPlacementConfig = Placement.COUNT_RANGE.configure(new CountRangeConfig(1, 0, 0, 256));
			biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE
					.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.create("END_STONE", "end_stone", new BlockMatcher(Blocks.END_STONE)), RegisterBlocks.TELERITE_ORE.getDefaultState(), 6))
					.withPlacement(genPlacementConfig));
		}
	}

}
package maxi.ores_cores.init;

import maxi.ores_cores.OresCores;
import maxi.ores_cores.world.gen.*;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;

@EventBusSubscriber(modid = OresCores.MODID, bus = Bus.MOD)
public class RegisterWorldGen {

	@SubscribeEvent
	public static void registerWorldGen(FMLLoadCompleteEvent event) { //Should I use FMLCommonSetupEvent instead of FMLLoadCompleteEvent?
		EmoulriteOreGen.generateOre();
		TeleriteOreGen.generateOre();
	}
	
}

Is this code bad? It works, but I dont know if this is the best way.

12 hours ago, ChampionAsh5357 said:

Remember to call these methods within a DeferredWorkQueue within your FMLCommonSetupEvent as they are not thread-safe.

 

  • Author

Is this right? My IDE marks all as warnings because DeferredWorkQueue is deprecated. Should I just use @SuppressWarnings("deprecation")?

package maxi.ores_cores.init;

import maxi.ores_cores.OresCores;
import maxi.ores_cores.world.gen.*;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DeferredWorkQueue;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;

@EventBusSubscriber(modid = OresCores.MODID, bus = Bus.MOD)
public class RegisterWorldGen {

	@SubscribeEvent
	public static void registerWorldGen(FMLCommonSetupEvent event) {
		DeferredWorkQueue.runLater(new Runnable() {
			@Override
			public void run() {
				
				EmoulriteOreGen.generateOre();
				TeleriteOreGen.generateOre();
				
			}
		});
	}
	
}

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.