Jump to content

[1.7.10] Looking for some Tutorial on how to "Override" Vanilla World Gen


American2050

Recommended Posts

To completely disable a specific type of structure generation:

 

Create a class that extends the appropriate

MapGen

class (e.g.

MapGenStrongholds

) and overrides

canSpawnStructureAtCoords

to return

false

. Subscribe to

InitMapGenEvent

, check for the appropriate

EventType

and assign a new instance of your class to the

newGen

field. This replaces the default generator with one that does nothing.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

To completely disable a specific type of structure generation:

 

Create a class that extends the appropriate

MapGen

class (e.g.

MapGenStrongholds

) and overrides

canSpawnStructureAtCoords

to return

false

. Subscribe to

InitMapGenEvent

, check for the appropriate

EventType

and assign a new instance of your class to the

newGen

field. This replaces the default generator with one that does nothing.

 

Thanks Choonster, yes I finally found something, and I kinda made what you saying, what I'm not sure about is how to make the Event thing. I'm gonna do some tests and see how it goes, but I already made a custom ChunkProvider and also made my own MapGenStronghold and StructureStrongholdPieces

 

I'll play around with my EventHandler and see what to do there ;)

Link to comment
Share on other sites

Are you creating your own dimension or modifying the Overworld? If it's your own dimension, just don't generate the structures in the first place.

 

coolAlias has a tutorial on event handling here. Jabelar has a tutorial here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

At this point, I would call me happy :P just by removing the End Portal Frames on the Strongholds Portal Rooms.

 

Reading around I found this post http://www.minecraftforge.net/forum/index.php/topic,21625.0.html Where I implement that and register it on the PopulateChunkEvent.Pre

 

@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
public void onEvent(PopulateChunkEvent.Pre event)
{     
    Chunk chunk = event.world.getChunkFromChunkCoords(event.chunkX, event.chunkZ);
    Block fromBlock = Blocks.end_portal_frame; // change this to suit your need
    Block toBlock = Blocks.air; // change this to suit your need

    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)
                    {
                        if (storage.getBlockByExtId(x, y, z) == fromBlock)
                        {
                            storage.func_150818_a(x, y, z, toBlock);
                        }
                    }
                }
            }
        }
    }

    chunk.isModified = true; // this is important as it marks it to be saved
}

 

Problem is that it doesn't work correctly, it does replace the End Portal Frames with air, but not all of them I did several tests and it replaced 9 in one seed leaving a row of 3 and in another test with different seed it replaced only 7.

 

I think the example they provide here was to replace "Ores" and maybe to replace End Portal Frames I have to run this in another event?

 

Back to your question. Yes I was to modify Overworld.

 

I have this Event registered on main mod class

 

    @EventHandler
    public void init(FMLInitializationEvent event)
    {
    	//EVENTS
    	MinecraftForge.EVENT_BUS.register(new WGMEventHandler());
    }

 

WGMEventHandler (I think my error is here on that if statement)

    @SubscribeEvent
    public void initMapGenEvent(InitMapGenEvent event)
    {
    	if(event.type == EventType.STRONGHOLD )
    	{
    		event.newGen = new CustomMapGenStronghold();
    	}
    	
    }

 

And on CustomMapGenStronghold

 

public class CustomMapGenStronghold extends MapGenStronghold
{
@Override
    public boolean canSpawnStructureAtCoords(int p_75047_1_, int p_75047_2_)
    {
    	
    	return false;
    	
    }

}

 

Thanks for the links, gonna take a lok at those ;)

Link to comment
Share on other sites

At this point, I would call me happy :P just by removing the End Portal Frames on the Strongholds Portal Rooms.

 

Reading around I found this post http://www.minecraftforge.net/forum/index.php/topic,21625.0.html Where I implement that and register it on the PopulateChunkEvent.Pre

 

@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
public void onEvent(PopulateChunkEvent.Pre event)
{     
    Chunk chunk = event.world.getChunkFromChunkCoords(event.chunkX, event.chunkZ);
    Block fromBlock = Blocks.end_portal_frame; // change this to suit your need
    Block toBlock = Blocks.air; // change this to suit your need

    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)
                    {
                        if (storage.getBlockByExtId(x, y, z) == fromBlock)
                        {
                            storage.func_150818_a(x, y, z, toBlock);
                        }
                    }
                }
            }
        }
    }

    chunk.isModified = true; // this is important as it marks it to be saved
}

 

Problem is that it doesn't work correctly, it does replace the End Portal Frames with air, but not all of them I did several tests and it replaced 9 in one seed leaving a row of 3 and in another test with different seed it replaced only 7.

 

I think the example they provide here was to replace "Ores" and maybe to replace End Portal Frames I have to run this in another event?

 

Does anyone know if the problem of this code replacing only the End Frame Portals "randomly" I mean, not all of them, is related to the Event I'm attaching this into, or is there any other problem here?

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