Jump to content

Blocking structures, liquids, initial creature spawns for Skyblock generation mod (1.12.2)


Recommended Posts

Posted

Hello all. I'm trying to create a simple Skyblock (void + a single spawn island) mod that preserves biomes (only as visible through F3) along with their sizes and distributions, including those created by mods like Biomes O'Plenty as an optional mod compatibility. The goal is to support the unique spawning and growing logic through mods (Pixelmon being front of mind) and to encourage building the island out to these locations. A map won't suffice in that it will be the same every time and will have restrictive hard world limits. I want to preserve existing Nether/End/mod dimension gen logic and to only modify the Overworld, at least for now. I'm doing this first in 1.12.2, though I plan to write it eventually for 1.16.5 and potentially beyond. This mod will be for single player and multiplayer servers.

I've identified two ways of doing this, both somewhat brittle due to the nature of the mod. The first is to block many of the world gen events or substitute my own post generation event that wipes the generation and substitutes a floating skyblock island if it is the spawn area. The second is to rewrite the entire vanilla + mod biome gen logic in a similar manner to Realistic Terrain Generation, with the added complexity that I don't want to change the biome size or borders (I'm admittedly not sure how this works. If there's simple logic for this and biomes borders are locked at chunk boundaries instead of something more freeform, this might not be tough) I'm concerned however that this would be a lot of excess code and class bloat, and small additions would break it. As such, and given that logically what I am doing is simply taking existing biome gen but totally voiding it and writing in a small island, the first seems simplest and most intuitive if possible

Eventually the plan is to also add a command + simple object that can generate a new island in a random location, set the player's spawn point to that island, and teleport them there. Not immediately relevant or important, but if others see unique concerns with this, I'm all ears.

The way I'm accomplishing the void and rewrite is to write a class WorldGenHandler, registered during the FMLPreInitializationEvent handler in the main mod class in the following manner:

MinecraftForge.TERRAIN_GEN_BUS.register(WorldGenHandler.class);

and in the class subscribe to a series of chunk loading, decoration, replace biome blocks, and init map gen events. I'm aware it's likely messy and redundant or contains methods that effectively do nothing in conjunction with others, but right now I'm spitballing and seeing what sticks:

 

package com.jks.skygenmod.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import net.minecraft.init.Blocks;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraft.world.gen.MapGenBase;
import net.minecraftforge.event.terraingen.BiomeEvent.GetVillageBlockID;
import net.minecraftforge.event.terraingen.ChunkGeneratorEvent.ReplaceBiomeBlocks;
import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
import net.minecraftforge.event.terraingen.InitMapGenEvent;
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import net.minecraftforge.event.world.BlockEvent.CreateFluidSourceEvent;
import net.minecraftforge.event.world.BlockEvent.FluidPlaceBlockEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@EventBusSubscriber
public class WorldGenHandler {
	private static final HashSet<InitMapGenEvent.EventType> permittedMapGenEvents 
		= new HashSet<InitMapGenEvent.EventType>(
				Arrays.asList(
						InitMapGenEvent.EventType.END_CITY,
						InitMapGenEvent.EventType.NETHER_BRIDGE,
						InitMapGenEvent.EventType.NETHER_CAVE
						)
				);
	
	@SubscribeEvent(priority=EventPriority.LOWEST, receiveCanceled=true)
	public static void onPopulate(PopulateChunkEvent.Populate event)
	{
		Logger logger = LogManager.getLogger(Reference.MOD_ID);
		logger.info("<< JKS SKYGEN >> BLOCK POPULATE OF TYPE {}", event.getType().name());
	    
		if (!event.getWorld().isRemote)
		{
		    event.setResult(Result.DENY);
		}
	}
	
	@SubscribeEvent(priority=EventPriority.LOWEST, receiveCanceled=true)
	public static void onEvent(PopulateChunkEvent.Post event)
	{
		Logger logger = LogManager.getLogger(Reference.MOD_ID);
		logger.info("<< JKS SKYGEN >> REWRITING BLOCKS TO AIR");
	    
		if (!event.getWorld().isRemote)
		{
		    Chunk chunk = event.getWorld().getChunkFromChunkCoords(event.getChunkX(), event.getChunkZ());
	
		    for (ExtendedBlockStorage storage : chunk.getBlockStorageArray()) 
		    {
		        if (storage != null) 
		        {
		            for (int x = 0; x < 16; ++x) 
		            {
		                for (int y = 0; y < 16; ++y) 
		                {
		                    for (int z = 0; z < 16; ++z) 
		                    {
		                    	//logger.info("<< JKS SKYGEN >> REWRITING BLOCK AT X:{}, Y: {}, Z: {}", x, y, z);
		                    	storage.set(x, y, z, Blocks.AIR.getDefaultState());
		                    }
		                }
		            }
		        }
		    }  
		    chunk.setModified(true); // this is important as it marks it to be saved
		}
	}
	
	@SubscribeEvent
	public static void onDecorateBiome(DecorateBiomeEvent.Decorate event)
	{
		Logger logger = LogManager.getLogger(Reference.MOD_ID);
		logger.info("<< JKS >> onDecorateBiome: {}", event.getType().name());
		if (!event.getWorld().isRemote)
		{
			event.setResult(Result.DENY);
		}
	}
	
	@SubscribeEvent
	public static void onReplaceBiomeBlocks(ReplaceBiomeBlocks event)
	{
		Logger logger = LogManager.getLogger(Reference.MOD_ID);
		logger.info("<< JKS >> onReplaceBiomeBlocks");
		if (!event.getWorld().isRemote)
		{
			event.setResult(Result.DENY);
		}
	}
	
	@SubscribeEvent
	public static void onInitMapGen(InitMapGenEvent event)
	{
		Logger logger = LogManager.getLogger(Reference.MOD_ID);
		logger.info("<< JKS >> onInitMapGen: {}", event.getType().name());
		if (!permittedMapGenEvents.contains(event.getType())) {
			event.setResult(Result.DENY);
		}
		else {
			logger.info("<< ! JKS ! >> Permitted init event {}", event.getType().name());
		}
	}
}

This logic voids most of the world, but despite the onInitMapGen event, I still gee some structures generating, most notably mineshafts and ocean monuments, and I think at one point I might have seen a floating village garden, though I could be recalling an old test. I also see stray water and lava pillars. These seem logically inconsistent with the above behavior.

On a separate note, do I need to check isRemote on the onInitMapGen, or is it implicitly not remote? Unsure how to grab the world from the event. Also, is there a way to change some of this logic to only take effect when in the overworld? That onInitMapGen seems like it might make a check like that tricky.

All the best and thanks for taking the time to take a look at this. Let me know if more is needed.
jks

  • Curle locked this topic
Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • C:\Users\bruiser\curseforge\minecraft\Instances\Fazbear Remnants\essential\loader\stage1\launchwrapper\stage2.forge_1.12.2.jar: The process cannot access the file because it is being used by another process. Restart your system and test it again If there is no change, delete the mentioned essential folder or remove the mod essential
    • Does it work with newer versions? For 1.16.5 also make a test with Embeddium + Oculus as Optifine replacement
    • Looking for the best Temu coupon code $100 off? You’re in the right place! We’ve got the ultimate deal that helps you save big on your favorite items. Our exclusive ACS670886 Temu coupon code is perfect for shoppers in the USA, Canada, and Europe. Whether you're a new or existing customer, this code ensures you get maximum benefits. By using the Temu coupon $100 off, you can unlock exciting savings on Temu’s vast collection. Don’t miss this chance to claim your Temu 100 off coupon code today! What Is The Coupon Code For Temu $100 Off? Both new and existing customers can enjoy incredible benefits with our Temu coupon $100 off on the Temu app and website. This $100 off Temu coupon ensures huge savings for everyone! ACS670886 – Get a flat $100 off on selected purchases. ACS670886 – Unlock a $100 coupon pack for multiple uses. ACS670886 – Enjoy a $100 flat discount if you're a new customer. ACS670886 – Existing customers can claim an extra $100 promo code. ACS670886 – This $100 coupon is valid for shoppers in the USA and Canada. Temu Coupon Code $100 Off For New Users In 2025 New users can maximize their savings by applying our Temu coupon $100 off on the Temu app. This Temu coupon code $100 off unlocks amazing deals for first-time shoppers. ACS670886 – Get a flat $100 discount for new users. ACS670886 – Receive a $100 coupon bundle as a welcome offer. ACS670886 – Unlock up to $100 in coupons for multiple uses. ACS670886 – Enjoy free shipping to 68 countries. ACS670886 – Get an extra 30% off on any purchase as a first-time user. How To Redeem The Temu Coupon $100 Off For New Customers? Using the Temu $100 coupon is easy! Follow these steps to redeem your Temu $100 off coupon code for new users: Sign up on the Temu app or website. Browse and add your favorite items to the cart. Enter ACS670886 at checkout. See the $100 discount applied instantly. Complete your purchase and enjoy your savings! Temu Coupon $100 Off For Existing Customers Existing customers can also benefit from our exclusive Temu $100 coupon codes for existing users. Use this Temu coupon $100 off for existing customers free shipping deal and save more! ACS670886 – Get an extra $100 discount for existing users. ACS670886 – Enjoy a $100 coupon bundle for multiple purchases. ACS670886 – Receive a free gift with express shipping across the USA/Canada. ACS670886 – Grab an extra 30% off on top of existing discounts. ACS670886 – Avail free shipping to 68 countries. How To Use The Temu Coupon Code $100 Off For Existing Customers? Redeeming your Temu coupon code $100 off as an existing user is simple. Just follow these steps: Log in to your Temu account. Select your desired products and add them to your cart. Apply ACS670886 at checkout. Your Temu coupon $100 off code will be applied automatically. Confirm your order and enjoy massive savings! Latest Temu Coupon $100 Off First Order First-time buyers get the best deals with our Temu coupon code $100 off first order. This Temu coupon code first order ensures maximum savings. ACS670886 – Flat $100 discount for the first order. ACS670886 – Special $100 Temu coupon code for new customers. ACS670886 – Get up to $100 in coupons for multiple uses. ACS670886 – Free shipping to 68 countries. ACS670886 – Extra 30% off on any first-time purchase. How To Find The Temu Coupon Code $100 Off? Finding a Temu coupon $100 off is easy! Check out the Temu coupon $100 off Reddit section or follow these tips: Subscribe to the Temu newsletter for exclusive deals. Follow Temu’s official social media pages for the latest updates. Visit trusted coupon sites for verified and working codes. Is Temu $100 Off Coupon Legit? Yes, our Temu $100 Off Coupon Legit and verified! Wondering if the Temu 100 off coupon legit? Here’s why: The ACS670886 code is officially tested and confirmed. Valid for all customers in the USA, Canada, and Europe. No expiration date—use it anytime! How Does Temu $100 Off Coupon Work? The Temu coupon code $100 off first-time user works instantly upon applying at checkout. Simply enter the Temu coupon codes 100 off, and the discount is automatically deducted. How To Earn Temu $100 Coupons As A New Customer? To earn a Temu coupon code $100 off, sign up on Temu, make your first purchase, and refer friends. This 100 off Temu coupon code can be unlocked through special promotions. What Are The Advantages Of Using The Temu Coupon $100 Off? $100 discount on the first order $100 coupon bundle for multiple uses 70% discount on popular items Extra 30% off for existing customers Up to 90% off on selected products Free gifts for new users Free delivery to 68 countries Temu $100 Discount Code And Free Gift For New And Existing Customers Enjoy the Temu $100 off coupon code and get amazing benefits! Our $100 off Temu coupon code ensures huge savings. ACS670886 – $100 discount for the first order. ACS670886 – Extra 30% off on any item. ACS670886 – Free gift for new Temu users. ACS670886 – Up to 70% discount on all Temu items. ACS670886 – Free shipping in 68 countries including the USA and UK. Final Note: Use The Latest Temu Coupon Code $100 Off Using the Temu coupon code $100 off is the smartest way to save on Temu! Don’t wait—grab your discount now. Our Temu coupon $100 off is available for all customers, ensuring maximum savings. Get yours today! FAQs Of Temu $100 Off Coupon Q: How can I get the Temu $100 off coupon? A: Use code ACS670886 at checkout to claim your $100 discount. Q: Is the Temu $100 coupon valid for existing customers? A: Yes! Existing users can also apply ACS670886 and enjoy savings. Q: Does the Temu $100 off coupon have an expiration date? A: No, ACS670886 is valid indefinitely. Q: Can I use the Temu coupon on multiple orders? A: Yes! ACS670886 allows multiple redemptions. Q: Is the Temu $100 coupon applicable worldwide? A: Yes, it’s valid in the USA, Canada, Europe, and 68 other countries.
    • I tried both Vanilla and Optfine like you said, and both gave the same result. So I believe the issue is most likely with Minecraft in general and not Forge
    • https://pastebin.com/xWy0mWXA Like I said Modded Java Edition 1.12.2 using Forge Version 14.23.5.2859 Oh yeah and Exit Code: 1  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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