Jump to content

Recommended Posts

Posted

As the title says, I have tried from practically meaningless code to copying minecraft code itself, and nothing works, Minecraft does not crash, but no ore is generated, everything works except that no ore is generated.

 

The main class here:

package jp.gianka.gworld;

import jp.gianka.gworld.elements.blocks.GWorldBlocks;
import jp.gianka.gworld.elements.items.GWorldItems;
import jp.gianka.gworld.elements.tab.GWorldTab;
import jp.gianka.gworld.elements.world.ores.OreGeneration;
import jp.gianka.gworld.elements.world.ores.OrePlacements;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@Mod(GWorld.MODID)
public class GWorld {
    public static final String MODID = "gworld";
    private static final Logger LOGGER = LogManager.getLogger();
    public static final CreativeModeTab gworld = new GWorldTab();

    public GWorld() {
        IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();

        GWorldBlocks.BLOCKS.register(eventBus);
        GWorldItems.ITEMS.register(eventBus);

        eventBus.addListener(this::setup);
        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event) {
        OreGeneration.registerFeatures();
        OrePlacements.registerPlacements();
        LOGGER.info("Dirt Block >> {}", Blocks.DIRT.getRegistryName());
    }
}

 

 

OreGeneration:

 

package jp.gianka.gworld.elements.world.ores;

import jp.gianka.gworld.GWorld;
import jp.gianka.gworld.elements.blocks.GWorldBlocks;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.data.worldgen.features.OreFeatures;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration.TargetBlockState;

import java.util.List;

public class OreGeneration {
    public static List<TargetBlockState> ORE_KYPTOITE_TARGET_LIST = List.of(OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, GWorldBlocks.KYPTOITE_ORE.get().defaultBlockState()), OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, GWorldBlocks.DEEPSLATE_KYPTOITE_ORE.get().defaultBlockState()));
    public static ConfiguredFeature<?, ?> ORE_KYPTOITE = Feature.ORE.configured(new OreConfiguration(ORE_KYPTOITE_TARGET_LIST, 16));

    public static void registerFeatures() {
        Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(GWorld.MODID, "ore_kyptoite_small"), ORE_KYPTOITE);
    }
}

 

 

OrePlacements:

 

package jp.gianka.gworld.elements.world.ores;

import jp.gianka.gworld.GWorld;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.placement.*;
import net.minecraftforge.event.world.BiomeLoadingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

import java.util.List;

public class OrePlacements {
    public static PlacedFeature ORE_KYPTOITE = OreGeneration.ORE_KYPTOITE.placed(commonOrePlacement(32, HeightRangePlacement.triangle(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(16))));

    private static List<PlacementModifier> orePlacement(PlacementModifier count, PlacementModifier height) {
        return List.of(count, InSquarePlacement.spread(), height, BiomeFilter.biome());
    }

    private static List<PlacementModifier> commonOrePlacement(int count, PlacementModifier height) {
        return orePlacement(CountPlacement.of(count), height);
    }

    private static List<PlacementModifier> rareOrePlacement(int count, PlacementModifier height) {
        return orePlacement(RarityFilter.onAverageOnceEvery(count), height);
    }

    public static void registerPlacements() {
        Registry.register(BuiltinRegistries.PLACED_FEATURE, new ResourceLocation(GWorld.MODID, "ore_kyptoite_small"), ORE_KYPTOITE);
    }

    @SubscribeEvent
    public static void registerBiomeModification(BiomeLoadingEvent event) {
        if (true) {
            event.getGeneration().getFeatures(Decoration.UNDERGROUND_ORES).add(() -> ORE_KYPTOITE);
        }
    }
}

 

 

Blocks:

 

package jp.gianka.gworld.elements.blocks;

import jp.gianka.gworld.GWorld;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.OreBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

public class GWorldBlocks {
    public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, GWorld.MODID);
    public static final RegistryObject<OreBlock> DEEPSLATE_KYPTOITE_ORE = BLOCKS.register("deepslate_kyptoite_ore", () -> new OreBlock(Properties.of(Material.STONE).strength(15F, 1500F).requiresCorrectToolForDrops().lightLevel((state) -> {
        return 15;
    }).sound(SoundType.DEEPSLATE), UniformInt.of(20,50)));
    public static final RegistryObject<OreBlock> KYPTOITE_ORE = BLOCKS.register("kyptoite_ore", () -> new OreBlock(Properties.of(Material.STONE).strength(15F, 1500F).requiresCorrectToolForDrops().lightLevel((state) -> {
        return 15;
    }).sound(SoundType.STONE), UniformInt.of(20, 50)));
}

 

 

Please someone tell me what I'm doing wrong....  :'c

Posted

I already registered the OreGeneration and OrePlacements classes, but now I get the following error:

---- Minecraft Crash Report ----
// Why did you do that?

Time: 7/2/22 03:04
Description: Mod loading error has occurred

java.lang.Exception: Mod Loading has failed
	at net.minecraftforge.logging.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:69) ~[forge-1.18.1-39.0.66_mapped_parchment_2022.01.23-1.18.1.jar%2376%2382!/:?] {re:classloading}
	at net.minecraftforge.client.loading.ClientModLoader.completeModLoading(ClientModLoader.java:183) ~[forge-1.18.1-39.0.66_mapped_parchment_2022.01.23-1.18.1.jar%2376%2382!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.lambda$new$1(Minecraft.java:553) ~[forge-1.18.1-39.0.66_mapped_parchment_2022.01.23-1.18.1.jar%2377!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.Util.ifElse(Util.java:409) ~[forge-1.18.1-39.0.66_mapped_parchment_2022.01.23-1.18.1.jar%2377!/:?] {re:classloading}
	at net.minecraft.client.Minecraft.lambda$new$2(Minecraft.java:547) ~[forge-1.18.1-39.0.66_mapped_parchment_2022.01.23-1.18.1.jar%2377!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screens.LoadingOverlay.render(LoadingOverlay.java:135) ~[forge-1.18.1-39.0.66_mapped_parchment_2022.01.23-1.18.1.jar%2377!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:875) ~[forge-1.18.1-39.0.66_mapped_parchment_2022.01.23-1.18.1.jar%2377!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:1040) ~[forge-1.18.1-39.0.66_mapped_parchment_2022.01.23-1.18.1.jar%2377!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:660) ~[forge-1.18.1-39.0.66_mapped_parchment_2022.01.23-1.18.1.jar%2377!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:205) ~[forge-1.18.1-39.0.66_mapped_parchment_2022.01.23-1.18.1.jar%2377!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}
	at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:38) ~[fmlloader-1.18.1-39.0.66.jar%230!/:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.1.0.jar%2310!/:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.1.0.jar%2310!/:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.1.0.jar%2310!/:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.1.0.jar%2310!/:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.1.0.jar%2310!/:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.1.0.jar%2310!/:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.1.0.jar%2310!/:?] {}
	at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149) [bootstraplauncher-1.0.0.jar:?] {}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
	at java.util.Objects.requireNonNull(Objects.java:334) ~[?:?] {}
-- MOD gworld --
Details:
	Caused by 0: java.lang.ExceptionInInitializerError
		at java.lang.Class.forName0(Native Method) ~[?:?] {}
		at java.lang.Class.forName(Class.java:467) ~[?:?] {}
		at net.minecraftforge.fml.javafmlmod.AutomaticEventSubscriber.lambda$inject$6(AutomaticEventSubscriber.java:75) ~[javafmllanguage-1.18.1-39.0.66.jar%2378!/:?] {}
		at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?] {}
		at net.minecraftforge.fml.javafmlmod.AutomaticEventSubscriber.inject(AutomaticEventSubscriber.java:62) ~[javafmllanguage-1.18.1-39.0.66.jar%2378!/:?] {}
		at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:91) ~[javafmllanguage-1.18.1-39.0.66.jar%2378!/:?] {}
		at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:120) ~[fmlcore-1.18.1-39.0.66.jar%2380!/:?] {}
		at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) ~[?:?] {}
		at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) ~[?:?] {}
		at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?] {}
		at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?] {}
		at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?] {}
		at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?] {}
		at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?] {}

	Mod File: main
	Failure message: GWorld Mod (gworld) has failed to load correctly
		java.lang.ExceptionInInitializerError: null
	Mod Version: 0.0.0.3
	Mod Issue URL: NOT PROVIDED
	Exception message: java.lang.NullPointerException: Registry Object not present: gworld:kyptoite_ore
Stacktrace:
	at java.util.Objects.requireNonNull(Objects.java:334) ~[?:?] {}
	at net.minecraftforge.registries.RegistryObject.get(RegistryObject.java:116) ~[forge-1.18.1-39.0.66_mapped_parchment_2022.01.23-1.18.1.jar%2376%2382!/:?] {re:classloading}
	at jp.gianka.gworld.elements.world.ore.OreGeneration.<clinit>(OreGeneration.java:20) ~[%2381!/:?] {re:classloading}
	at java.lang.Class.forName0(Native Method) ~[?:?] {}
	at java.lang.Class.forName(Class.java:467) ~[?:?] {}
	at net.minecraftforge.fml.javafmlmod.AutomaticEventSubscriber.lambda$inject$6(AutomaticEventSubscriber.java:75) ~[javafmllanguage-1.18.1-39.0.66.jar%2378!/:?] {}
	at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?] {}
	at net.minecraftforge.fml.javafmlmod.AutomaticEventSubscriber.inject(AutomaticEventSubscriber.java:62) ~[javafmllanguage-1.18.1-39.0.66.jar%2378!/:?] {}
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:91) ~[javafmllanguage-1.18.1-39.0.66.jar%2378!/:?] {}
	at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:120) ~[fmlcore-1.18.1-39.0.66.jar%2380!/:?] {}
	at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) ~[?:?] {}
	at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) ~[?:?] {}
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?] {}
	at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?] {}
	at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?] {}
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?] {}
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?] {}


-- System Details --
Details:
	Minecraft Version: 1.18.1
	Minecraft Version ID: 1.18.1
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 17.0.2, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode, sharing), Oracle Corporation
	Memory: 920854528 bytes (878 MiB) / 1342177280 bytes (1280 MiB) up to 25769803776‬ bytes (24576‬ MiB)
	CPUs: 32
	Processor Vendor: AuthenticAMD
	Processor Name: AMD Processor Model Unknown
	Identifier: AuthenticAMD Family 16 Model 10 Stepping 0
	Microarchitecture: ZEN3
	Frequency (GHz): 4.61
	Number of physical packages: 1
	Number of physical CPUs: 32
	Number of logical CPUs: 64
	Graphics card #0 name: NVIDIA GeForce RTX™ 3090 Series
	Graphics card #0 vendor: Nvidia Corporation, Inc. (0x1002)
	Graphics card #0 VRAM (MB): 24576.00
	Graphics card #0 deviceId: 0x6939
	Graphics card #0 versionInfo: DriverVersion=511.65
	Memory slot #0 capacity (MB): 16384.00
	Memory slot #0 clockSpeed (GHz): 4.00
	Memory slot #0 type: DDR4
	Memory slot #1 capacity (MB): 16384.00
	Memory slot #1 clockSpeed (GHz): 4.00
	Memory slot #1 type: DDR4
	Memory slot #2 capacity (MB): 16384.00
	Memory slot #2 clockSpeed (GHz): 4.00
	Memory slot #2 type: DDR4
	Memory slot #3 capacity (MB): 16384.00
	Memory slot #3 clockSpeed (GHz): 4.00
	Memory slot #3 type: DDR4
	Virtual memory max (MB): 13234.48
	Virtual memory used (MB): 10920.84
	Swap memory total (MB): 5044.36
	Swap memory used (MB): 554.34
	JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
	ModLauncher: 9.1.0+9.1.0+main.6690ee51
	ModLauncher launch target: forgeclientuserdev
	ModLauncher naming: mcp
	ModLauncher services: 
		 mixin PLUGINSERVICE 
		 eventbus PLUGINSERVICE 
		 object_holder_definalize PLUGINSERVICE 
		 runtime_enum_extender PLUGINSERVICE 
		 capability_token_subclass PLUGINSERVICE 
		 accesstransformer PLUGINSERVICE 
		 runtimedistcleaner PLUGINSERVICE 
		 mixin TRANSFORMATIONSERVICE 
		 fml TRANSFORMATIONSERVICE 
	FML Language Providers: 
		[email protected]
		javafml@null
	Mod List: 
		forge-1.18.1-39.0.66_mapped_parchment_2022.01.23-1|Minecraft                     |minecraft                     |1.18.1              |COMMON_SET|Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f
		                                                  |Forge                         |forge                         |39.0.66             |COMMON_SET|Manifest: NOSIGNATURE
		main                                              |GWorld Mod                    |gworld                        |0.0.0.3             |ERROR     |Manifest: NOSIGNATURE
	Crash Report UUID: f07ddca9-6d6b-45e6-950a-30ba0713c8db
	FML: 39.0
	Forge: net.minecraftforge:39.0.66

 

Posted
12 hours ago, poopoodice said:

Can you post your code?

 

9 hours ago, Luis_ST said:

Did you register your DeferredRegister in your mod main class constructor 

Here is my code:

 

GWorld Main:

package jp.gianka.gworld;

import jp.gianka.gworld.elements.blocks.GWorldBlocks;
import jp.gianka.gworld.elements.items.GWorldItems;
import jp.gianka.gworld.elements.tab.GWorldTab;
import jp.gianka.gworld.elements.world.ore.OreGeneration;
import jp.gianka.gworld.elements.world.ore.OrePlacements;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@Mod(GWorld.MODID)
public class GWorld {
    public static final String MODID = "gworld";
    private static final Logger LOGGER = LogManager.getLogger();
    public static final CreativeModeTab gworld = new GWorldTab();

    public GWorld() {
        IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();

        GWorldBlocks.BLOCKS.register(eventBus);
        GWorldItems.ITEMS.register(eventBus);

        eventBus.addListener(this::setup);

        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event) {
        event.enqueueWork(() -> {
            OreGeneration.registerConfiguredFeatures();
            OrePlacements.registerPlacedFeatures();
        });
        LOGGER.info(Blocks.DIRT.getRegistryName());
    }
}

 

 

Register blocks:

 

package jp.gianka.gworld.elements.blocks;

import jp.gianka.gworld.GWorld;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.OreBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

public class GWorldBlocks {
    public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, GWorld.MODID);

    public static final RegistryObject<Block> DEEPSLATE_KYPTOITE_ORE = BLOCKS.register("deepslate_kyptoite_ore", () -> new OreBlock(Properties.of(Material.STONE).strength(15F, 1500F).requiresCorrectToolForDrops().lightLevel((state) -> {
        return 15;
    }).sound(SoundType.DEEPSLATE), UniformInt.of(25, 50)));
    public static final RegistryObject<Block> KYPTOITE_ORE = BLOCKS.register("kyptoite_ore", () -> new OreBlock(Properties.of(Material.STONE).strength(15F, 1500F).requiresCorrectToolForDrops().lightLevel((state) -> {
        return 15;
    }).sound(SoundType.STONE), UniformInt.of(25, 50)));
}

 

 

Register Items:

 

package jp.gianka.gworld.elements.items;

import jp.gianka.gworld.GWorld;
import jp.gianka.gworld.elements.blocks.GWorldBlocks;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Item.Properties;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

public class GWorldItems {
    public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, GWorld.MODID);

    public static final RegistryObject<Item> DEEPSLATE_KYPTOITE_ORE = ITEMS.register("deepslate_kyptoite_ore", () -> new BlockItem(GWorldBlocks.DEEPSLATE_KYPTOITE_ORE.get(), (new Properties()).tab(GWorld.gworld)));
    public static final RegistryObject<Item> KYPTOITE_GEM = ITEMS.register("kyptoite_gem", () -> new Item((new Properties()).tab(GWorld.gworld)));
    public static final RegistryObject<Item> KYPTOITE_ORE = ITEMS.register("kyptoite_ore", () -> new BlockItem(GWorldBlocks.KYPTOITE_ORE.get(), (new Properties()).tab(GWorld.gworld)));
}

 

 

Ore generation features:

 

package jp.gianka.gworld.elements.world.ore;

import jp.gianka.gworld.GWorld;
import jp.gianka.gworld.elements.blocks.GWorldBlocks;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.data.worldgen.features.OreFeatures;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration.TargetBlockState;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;

import java.util.List;

@EventBusSubscriber
public class OreGeneration {
    public static final List<TargetBlockState> ORE_KYPTOITE_TARGET_LIST = List.of(OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, GWorldBlocks.KYPTOITE_ORE.get().defaultBlockState()), OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, GWorldBlocks.DEEPSLATE_KYPTOITE_ORE.get().defaultBlockState()));
    public static final ConfiguredFeature<?, ?> ORE_KYPTOITE_SMALL = Feature.ORE.configured(new OreConfiguration(ORE_KYPTOITE_TARGET_LIST, 4, 0.5F));
    public static final ConfiguredFeature<?, ?> ORE_KYPTOITE_LARGE = Feature.ORE.configured(new OreConfiguration(ORE_KYPTOITE_TARGET_LIST, 12, 0.7F));
    public static final ConfiguredFeature<?, ?> ORE_KYPTOITE_BURIED = Feature.ORE.configured(new OreConfiguration(ORE_KYPTOITE_TARGET_LIST, 8, 1.0F));

    public static void registerConfiguredFeatures() {
        Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(GWorld.MODID, "ore_kyptoite_small"), ORE_KYPTOITE_SMALL);
        Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(GWorld.MODID, "ore_kyptoite_large"), ORE_KYPTOITE_LARGE);
        Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation(GWorld.MODID, "ore_kyptoite_buried"), ORE_KYPTOITE_BURIED);
    }
}

 

 

Ore placements features:

 

package jp.gianka.gworld.elements.world.ore;

import jp.gianka.gworld.GWorld;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.placement.*;
import net.minecraftforge.event.world.BiomeLoadingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;

import java.util.List;

@EventBusSubscriber
public class OrePlacements {
    public static final PlacedFeature ORE_KYPTOITE_SMALL = OreGeneration.ORE_KYPTOITE_SMALL.placed(commonOrePlacement(7, HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-80), VerticalAnchor.aboveBottom(80))));
    public static final PlacedFeature ORE_KYPTOITE_LARGE = OreGeneration.ORE_KYPTOITE_LARGE.placed(rareOrePlacement(9, HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-80), VerticalAnchor.aboveBottom(80))));
    public static final PlacedFeature ORE_KYPTOITE_BURIED = OreGeneration.ORE_KYPTOITE_BURIED.placed(commonOrePlacement(4, HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-80), VerticalAnchor.aboveBottom(80))));

    public static void registerPlacedFeatures() {
        Registry.register(BuiltinRegistries.PLACED_FEATURE, new ResourceLocation(GWorld.MODID, "ore_kyptoite_small"), ORE_KYPTOITE_SMALL);
        Registry.register(BuiltinRegistries.PLACED_FEATURE, new ResourceLocation(GWorld.MODID, "ore_kyptoite_large"), ORE_KYPTOITE_LARGE);
        Registry.register(BuiltinRegistries.PLACED_FEATURE, new ResourceLocation(GWorld.MODID, "ore_kyptoite_buried"), ORE_KYPTOITE_BURIED);
    }

    @SubscribeEvent
    public static void registerBiomeModification(BiomeLoadingEvent event) {
        if (true) {
            event.getGeneration().getFeatures(Decoration.UNDERGROUND_ORES).add(() -> {
                return ORE_KYPTOITE_SMALL;
            });
        }
        if (true) {
            event.getGeneration().getFeatures(Decoration.UNDERGROUND_ORES).add(() -> {
                return ORE_KYPTOITE_LARGE;
            });
        }
        if (true) {
            event.getGeneration().getFeatures(Decoration.UNDERGROUND_ORES).add(() -> {
                return ORE_KYPTOITE_BURIED;
            });
        }
    }

    private static List<PlacementModifier> orePlacement(PlacementModifier count, PlacementModifier height) {
        return List.of(count, InSquarePlacement.spread(), height, BiomeFilter.biome());
    }

    private static List<PlacementModifier> commonOrePlacement(int count, PlacementModifier height) {
        return orePlacement(CountPlacement.of(count), height);
    }

    private static List<PlacementModifier> rareOrePlacement(int rarityCount, PlacementModifier height) {
        return orePlacement(RarityFilter.onAverageOnceEvery(rarityCount), height);
    }
}

 

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.