Jump to content

[Solved][1.16.5] Issue with Ore Generation


MonkeyKnight

Recommended Posts

I have been trying to generate an ore for my mod and have created a new feature and registered it. However, whenever I join a world, it immediately crashes. I cannot find anything useful in the crash report and am stumped. Can you find where I made a mistake?

Main Mod Class:

package com.monkey.ExampleMod;

import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStage.Decoration;
import net.minecraftforge.common.BiomeManager.BiomeType;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.world.BiomeLoadingEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
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;

import com.monkey.ExampleMod.capabilities.Examples;
import com.monkey.ExampleMod.capabilities.ExamplesProvider;
import com.monkey.ExampleMod.capabilities.ExamplesStorage;
import com.monkey.ExampleMod.capabilities.IExamples;
import com.monkey.ExampleMod.capabilities.IVersions;
import com.monkey.ExampleMod.capabilities.Versions;
import com.monkey.ExampleMod.capabilities.VersionsProvider;
import com.monkey.ExampleMod.capabilities.VersionsStorage;
import com.monkey.ExampleMod.events.ExampleStats;
import com.monkey.ExampleMod.init.BlockInit;
import com.monkey.ExampleMod.init.EffectsInit;
import com.monkey.ExampleMod.init.FeaturesInit;
import com.monkey.ExampleMod.init.ItemInit;
import com.monkey.ExampleMod.init.SoundInit;
import com.monkey.ExampleMod.init.TileEntityInit;


@Mod("ExampleMod")
@Mod.EventBusSubscriber(modid = ExampleMod.MOD_ID, bus = Bus.FORGE)
public class ExampleMod {

	public static final Logger LOGGER = LogManager.getLogger();
	public static final String MOD_ID = "ExampleMod";
	public static final ItemGroup ExampleMod_GROUP = new ExampleModGroup("ExampleModtab");

	public ExampleMod() {
		IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
		BlockInit.BLOCKS.register(bus);
		ItemInit.ITEMS.register(bus);
		EffectsInit.EFFECTS.register(bus);
		SoundInit.SOUNDS.register(bus);
		TileEntityInit.TILE_ENTITY.register(bus);
				
		MinecraftForge.EVENT_BUS.register(this);
		FMLJavaModLoadingContext.get().getModEventBus().addListener(ExampleMod::onCommonSetup);
	}
	
	@SubscribeEvent
	public static void onCommonSetup(FMLCommonSetupEvent event) {
		CapabilityManager.INSTANCE.register(IExample.class, new ExampleStorage(), Examples::new);
		CapabilityManager.INSTANCE.register(IExampleTwo.class, new ExampleTwoStorage(), ExampleTwo::new);
		RenderTypeLookup.setRenderLayer(BlockInit.FLASK_GLASS.get(), RenderType.translucent());
	}

	@SubscribeEvent
    public void onBiomeLoading(final BiomeLoadingEvent biome) {
        if(!(biome.getCategory() == Biome.Category.NETHER || biome.getCategory() == Biome.Category.THEEND))
        {
        	System.out.println("!");
            biome.getGeneration().getFeatures(Decoration.UNDERGROUND_ORES)
                .add(() -> FeaturesInit.ORE_SULFUR_CONFIG);
        }
    }
	
	@SubscribeEvent
	public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) {
		if (event.getObject() instanceof PlayerEntity) {
			event.addCapability(new ResourceLocation(ExampleMod.MOD_ID, "examples"), new ExamplesProvider());
			event.addCapability(new ResourceLocation(ExampleMod.MOD_ID, "versions"), new VersionsProvider());
		}
	}
	
	public static class ExampleModGroup extends ItemGroup {

		public ExampleModGroup(String label) {
			super(label);
		}

		@Override
		public ItemStack makeIcon() {
			return ItemInit.EXAMPLE_ICON.get().getDefaultInstance();
		}
	}
}

Feature Class:

package com.monkey.Example.init;

import com.monkey.Example.Example;

import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.WorldGenRegistries;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.IFeatureConfig;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;

@Mod.EventBusSubscriber(modid = Example.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class FeaturesInit {

    public static ConfiguredFeature<?, ?> ORE_SULFUR_CONFIG;

    @SubscribeEvent
    public void setup(FMLCommonSetupEvent event) {
        ORE_SULFUR_CONFIG = register("ore_sulfur",
            Feature.ORE.configured(
                new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, BlockInit.SULFUR_ORE.get().defaultBlockState(), 9)).range(64).squared().count(20));
    }

    private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String key, ConfiguredFeature<FC, ?> configuredFeature) {
        return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation(Example.MOD_ID, key), configuredFeature);
    }
}

 

 

Edited by MonkeyKnight
Link to comment
Share on other sites

  • MonkeyKnight changed the title to [Solved][1.16.5] Issue with Ore Generation

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
    • Update your drivers: https://www.amd.com/en/support/graphics/amd-radeon-r9-series/amd-radeon-r9-200-series/amd-radeon-r9-280x
  • Topics

×
×
  • Create New...

Important Information

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