Posted September 7, 201510 yr Does anyone know of some Tutorial on how to Override Vanilla World Generation, like to disable stuff, like for example Mineshaft or Strongholds and things like that? Thanks a lot.
September 8, 201510 yr 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.
September 8, 201510 yr Author 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
September 8, 201510 yr 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.
September 8, 201510 yr Author At this point, I would call me happy 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
September 14, 201510 yr Author At this point, I would call me happy 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?
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.