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

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

  • Author

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());

3db82551f3db69e41365c3aa65119750.png

Edited by DoctorLOGiQ
Forgot to include attachment, derp

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.