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.