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

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

  • Author

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

  • Author

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;
            }
        }
    }
}

 

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

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.

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.