DoctorLOGiQ Posted June 16, 2018 Share Posted June 16, 2018 Hey guys. So I have a query, which doesn't come without much code-digging prior to asking. I'm looking for the best way to have my mod detect when an end gateway is spawned. I have tried listening for the event net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.world, this.rand, x, z, false); which is called right after (new WorldGenEndGateway()).generate(this.world, this.rand, blockpos1); in Vanilla's ChunkGeneratorEnd script... but my mod isn't detecting this event. I am using @SubscribeEvent public static void onChunkPopulate(PopulateChunkEvent.Post event) to listen for the event, and I have tried annotating the class with @Mod.EventBusSubscriber and registering it with MinecraftForge.EVENT_BUS.register(...) but to no avail. Am I doing something wrong? How can I detect when the gateways are spawned, preferably with access to the generation code? Many thanks. - Logiq Quote Link to comment Share on other sites More sharing options...
DoctorLOGiQ Posted June 17, 2018 Author Share Posted June 17, 2018 (edited) Sure. This is the function. Upon testing, nothing happens, the System.out.println() doesn't even print. I have tested this by killing the Dragon. Each time a new end gateway is spawned, but nothing shows up in the console (and yes, I know Systmem.out.println() isn't the proper way to log, it's only temporary, and works with IDEA). Function: @SubscribeEvent public static void onChunkPopulate(PopulateChunkEvent.Post event) { System.out.println("End chunk population event"); if (!event.getWorld().isRemote && event.getGen() instanceof ChunkGeneratorEnd) { World world = event.getWorld(); ChunkGeneratorEnd generator = (ChunkGeneratorEnd) event.getGen(); int chunkX = event.getChunkX(), chunkZ = event.getChunkZ(); for (int x = 0; x < 16; x++) { for (int y = 8; y < 128; y++) { for (int z = 0; z < 16; z++) { if (world.getChunkFromChunkCoords(chunkX, chunkZ).getBlockState(new BlockPos(x, y, z)).getBlock() == Blocks.END_GATEWAY) { System.out.println("Located gateway! Chunk X: " + chunkX + ", Chunk Z: " + chunkZ + ", Block X: " + x + ", Block Y: " + y + ", Block Z: " + z); } } } } } } Registration (during FMLInitializationEvent? MinecraftForge.EVENT_BUS.register(new VppChunkGeneratorEnd()); Edited June 17, 2018 by DoctorLOGiQ Forgot to include attachment, derp Quote Link to comment Share on other sites More sharing options...
jabelar Posted June 17, 2018 Share Posted June 17, 2018 You shouldn't register the class to the event bus if you're already using the annotation and static method. Alternatively you should not make method static. I think your event handler registration isn't right. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
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.