Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.15.2] Register WorldCarver


Tyrrel
 Share

Recommended Posts

I've been having trouble figuring out how to correctly register a custom CaveWorldCarver for 1.15.2.  I'm using Deferred Registries.
 

public class CarverInit {
    public static final DeferredRegister<WorldCarver<?>> CARVERS = new DeferredRegister<>(
            ForgeRegistries.WORLD_CARVERS, Derpium.MOD_ID);

    public static final RegistryObject<WorldCarver<ProbabilityConfig>> DARK_CARVER = CARVERS.register("dark_carver",
            () -> new ModCaveCarver(ProbabilityConfig::deserialize));
}

 

Am I doing this incorrectly, or are there more steps that should be followed?  I have the necessary reference in my main class, and have moved that around as well to no avail.  Minecraft keeps giving me "Registry Object not found" errors when I attempt to use this in a biome.

Link to comment
Share on other sites

I've found that some things don't work quite right with DeferredRegister, and moving it over to a proper registry event makes it work.

Just for grins have you tried that?

 

Also, you should post the whole project as a github repo, makes it much easier to see the big picture. Also please post the debug.log. More info == better!!

Link to comment
Share on other sites

I moved to using an Object Holder and registry event and that seems to be working a bit better.  However, I am now running into a null pointer exception when attempting to load the dimension I have this carver/biome in.

 

@Mod.EventBusSubscriber(modid = Derpium.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
@ObjectHolder(Derpium.MOD_ID)
public class CarverInit {
    public static final WorldCarver<ProbabilityConfig> dark_carver = null;

    @SubscribeEvent
    public static void registerCarver(final RegistryEvent.Register<WorldCarver<?>> event) {
        event.getRegistry().register(new ModCaveCarver(ProbabilityConfig::deserialize).setRegistryName(
                "dark_carver"));
    }
}

 

I don't work with Object Holders often, this was just how I did items in the past when I was first learning those.  How would I go about calling the registry for my new carver here?

 

public class DarkDerpiumBiome extends Biome {
    public DarkDerpiumBiome(Builder biomeBuilder) {
        super(biomeBuilder);
        this.addCarver(GenerationStage.Carving.AIR, Biome.createCarver(CarverInit.dark_carver,
                new ProbabilityConfig(0.2f)));
        DefaultBiomeFeatures.addSedimentDisks(this);
        DefaultBiomeFeatures.addMushrooms(this);
        DefaultBiomeFeatures.addSprings(this);
        this.addSpawn(EntityClassification.AMBIENT, new Biome.SpawnListEntry(EntityType.BAT, 10, 8, 8));
        this.addSpawn(EntityClassification.WATER_CREATURE, new Biome.SpawnListEntry(EntityType.SQUID, 2, 1, 4));

    }

 

As for posting my debug.log, it appears to be too large to use pastebin and I am unable to attach it here.  Suggestions?

Edited by Tyrrel
Link to comment
Share on other sites

I figured it out!  Posting relevant code for the future generations below.

public class DarkDerpiumBiome extends Biome {
    public DarkDerpiumBiome(Builder biomeBuilder) {
        super(biomeBuilder);
        this.addCarver(GenerationStage.Carving.AIR, Biome.createCarver(new 	ModCaveCarver(ProbabilityConfig::deserialize),
                new ProbabilityConfig(0.2f)));
        DefaultBiomeFeatures.addSedimentDisks(this);
        DefaultBiomeFeatures.addMushrooms(this);
        DefaultBiomeFeatures.addSprings(this);
        this.addSpawn(EntityClassification.AMBIENT, new Biome.SpawnListEntry(EntityType.BAT, 10, 8, 8));
        this.addSpawn(EntityClassification.WATER_CREATURE, new Biome.SpawnListEntry(EntityType.SQUID, 2, 1, 4));

    }
@Mod.EventBusSubscriber(modid = Derpium.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
@ObjectHolder(Derpium.MOD_ID)
public class CarverInit {
    @SubscribeEvent
    public static void registerCarver(final RegistryEvent.Register<WorldCarver<?>> event) {
        event.getRegistry().register(new ModCaveCarver(ProbabilityConfig::deserialize).setRegistryName(
                "dark_carver"));
    }
}
public class ModCaveCarver extends CaveWorldCarver {
    public ModCaveCarver(Function<Dynamic<?>, ? extends ProbabilityConfig> p_i49929_1_) {
        super(p_i49929_1_, 138);
        this.carvableBlocks = ImmutableSet.of(Blocks.BONE_BLOCK, Blocks.STONE);
        this.carvableFluids = ImmutableSet.of(Fluids.WATER);
    }

    @Override
    protected int generateCaveStartY(Random p_222726_1_) {
        return p_222726_1_.nextInt(this.maxHeight);
    }

    @Override
    protected int func_222724_a() {
        return 10;
    }

    @Override
    protected float generateCaveRadius(Random rand) {
        return (rand.nextFloat() * 2.0F + rand.nextFloat()) * 2.0F;
    }

    @Override
    protected double func_222725_b() {
        return 5.0D;
    }

    @Override
    protected boolean func_225556_a_(IChunk p_225556_1_, Function<BlockPos, Biome> p_225556_2_, BitSet p_225556_3_, Random p_225556_4_, BlockPos.Mutable p_225556_5_, BlockPos.Mutable p_225556_6_, BlockPos.Mutable p_225556_7_, int p_225556_8_, int p_225556_9_, int p_225556_10_, int p_225556_11_, int p_225556_12_, int p_225556_13_, int p_225556_14_, int p_225556_15_, AtomicBoolean p_225556_16_) {
        int i = p_225556_13_ | p_225556_15_ << 4 | p_225556_14_ << 8;
        if (p_225556_3_.get(i)) {
            return false;
        } else {
            p_225556_3_.set(i);
            p_225556_5_.setPos(p_225556_11_, p_225556_14_, p_225556_12_);
            if (this.func_222706_a(p_225556_1_.getBlockState(p_225556_5_))) {
                BlockState blockstate;
                if (p_225556_14_ <= 31) {
                    blockstate = WATER.getBlockState();
                } else {
                    blockstate = CAVE_AIR;
                }

                p_225556_1_.setBlockState(p_225556_5_, blockstate, false);
                return true;
            } else {
                return false;
            }
        }
    }
}

 

Link to comment
Share on other sites

6 hours ago, Cryptic_Skybox said:

I used this code in trying to create a carver of my own, and I keep getting an error for "func_222706_a"... any ideas?

You may be using a different version of mappings, so the names could potentially be different. Look at method signatures in the class that method belongs to to figure out what it has been renamed.

When reporting errors, you should really share the full log, and your code, because without them, every attempt to help is 100% guesswork :)

 

*edit: Also, you should probably just start a new thread with your issue, as this thread is someone elses, and has already been resolved, and is basically just here for reference.

Edited by Ugdhar
Link to comment
Share on other sites

9 hours ago, Ugdhar said:

You may be using a different version of mappings, so the names could potentially be different. Look at method signatures in the class that method belongs to to figure out what it has been renamed.

When reporting errors, you should really share the full log, and your code, because without them, every attempt to help is 100% guesswork :)

 

*edit: Also, you should probably just start a new thread with your issue, as this thread is someone elses, and has already been resolved, and is basically just here for reference.

Yeah that helped a ton! And ill be sure to include code and make a new post next time haha.

Link to comment
Share on other sites

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

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Yep, it's what the title says I only found out how to generate flowers and didn't find the the thingy with all the configured features are Would be nice if someone could help! Thanks
    • I started a server with PlayerRevive/Tombstone mod and when I die and I respawn I don't stop dying. Also I have a Issue with FramedBlocks: when I put one block of this mod, the server crashes and closes. I put here the server log: [16:55:36 ERROR]: Exception caught during firing event: Cannot invoke "net.minecraft.world.World.func_201670_d()" because "this.field_145850_b" is null         Index: 11         Listeners:                 0: HIGHEST                 1: ASM: class ovh.corail.tombstone.event.EventHandler onServerTick(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V                 2: NORMAL                 3: ASM: class com.mrcrayfish.guns.common.DelayedTask onServerTick(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V                 4: ASM: class shadows.placebo.util.PlaceboTaskQueue tick(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V                 5: ASM: com.dairymoose.modernlife.core.ModernLifeCommon@501855c1 onServerTick(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V                 6: ASM: com.github.alexthe666.citadel.server.CitadelEvents@7bca1184 onServerTickEvent(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V                 7: ASM: me.ichun.mods.ichunutil.common.core.EventHandlerServer@41275fcc onServerTick(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V                 8: ASM: net.minecraftforge.common.ForgeInternalHandler@5495b2c1 onServerTick(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V                 9: ASM: class com.simibubi.create.events.CommonEvents onServerTick(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V                 10: ASM: class net.geforcemods.securitycraft.SCEventHandler onServerTick(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V                 11: ASM: class xfacthd.framedblocks.common.util.EventHandler onServerTick(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V                 12: ASM: class com.hollingsworth.arsnouveau.api.event.EventQueue serverTick(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V                 13: ASM: com.mrcrayfish.obfuscate.common.data.SyncedPlayerData@2c57ecfc onServerTick(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V                 14: ASM: noppes.npcs.ServerTickHandler@30710a3e onServerTick(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V                 15: ASM: com.sk89q.worldedit.forge.ThreadSafeCache@37b339fc tickStart(Lnet/minecraftforge/event/TickEvent;)V                 16: LOWEST                 17: ASM: ovh.corail.tombstone.proxy.ServerProxy@5a4a21ad onServerTick(Lnet/minecraftforge/event/TickEvent$ServerTickEvent;)V java.lang.NullPointerException: Cannot invoke "net.minecraft.world.World.func_201670_d()" because "this.field_145850_b" is null         at xfacthd.framedblocks.common.tileentity.FramedTileEntity.checkSolidStateOnLoad(FramedTileEntity.java:539)         at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)         at xfacthd.framedblocks.common.util.EventHandler.onServerTick(EventHandler.java:84)         at net.minecraftforge.eventbus.ASMEventHandler_485_EventHandler_onServerTick_ServerTickEvent.invoke(.dynamic)         at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85)         at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302)         at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283)         at net.minecraftforge.fml.hooks.BasicEventHooks.onPreServerTick(BasicEventHooks.java:113)         at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:1001)         at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:818)         at net.minecraft.server.MinecraftServer.func_240783_a_(MinecraftServer.java:269)         at java.base/java.lang.Thread.run(Thread.java:833) [16:55:36 ERROR]: Encountered an unexpected exception [16:55:36 FATAL]: Preparing crash report with UUID 62ce1105-b5dd-4f30-9af8-999e3f1f687f [16:55:37 ERROR]: This crash report has been saved to: /home/container/./crash-reports/crash-2022-09-29_16.55.36-server.txt
    • Been looking everywhere, just hope this helps someone. As of 1.19.2 the only way that doesn't cause problems would be to use push(). Unless someone is brighter than me lol.   @SubscribeEvent public static void onLivingJump(LivingEvent.LivingJumpEvent event){ float jumpMultiplier = 0.07F; if (event.getEntity() instanceof Player){ event.getEntity().push(0,jumpMultiplier,0); }  
  • Topics

×
×
  • Create New...

Important Information

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