Jump to content

ChunkDataEvent.Load never called


klokklok

Recommended Posts

Hello,

 

I'm new to modding in minecraft and I was testing around with some events.

 

I was wondering why ChunkDataEvent.Load never calls when loading into a map/server.

 

@SubscribeEvent public void LoadChunk(ChunkDataEvent.Load event){

System.out.println("Chunk loaded x:" + event.getChunk().xPosition + " z:" + event.getChunk().zPosition);

}

 

Did I miss something? The console returns no errors and also the default Init event seems to work fine.

 

Thanks for reading/helping!

Link to comment
Share on other sites

What do you exactly mean?

 

This is the full code I came up with so far:

 

@EventHandler

public void preInit(FMLPreInitializationEvent event) {

 

FMLCommonHandler.instance().bus().register(new Events());

 

System.out.println("Event Handler Initialized");

 

}

 

Events class looks like this:

 

public class Events {

@SubscribeEvent public void LoadChunk(ChunkDataEvent.Load event){

System.out.println("Chunk loaded x:" + event.getChunk().xPosition + " z:" + event.getChunk().zPosition);

}

}

Link to comment
Share on other sites

MinecraftForge.EVENT_BUS.register(new ForgeEvents());

 

This event belongs to Forge events. To know that look at package. There are 2 main buses - FML and Forge, and few side ones - for world-gens mainly.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

I figured out why it didn't seem to work on multiplayer servers. I was checking for stone blocks in the chunk and logging that to the console. It worked fine on singleplayer but for some reason on multiplayer the chunk.getBlock() only returns air blocks and finds nothing else.

 

This is what I have tried:

 

    @SubscribeEvent public void LoadChunk(ChunkEvent.Load event){

    for(int x = event.getChunk().xPosition*16; x<(event.getChunk().xPosition*16)+15; x++){

    for(int y = 0; y < 256; y++){

            for(int z = event.getChunk().zPosition*16; z<(event.getChunk().zPosition*16)+15; z++){

            if(event.getChunk().getBlock(x,y,z) != Block.getBlockById(0)){

            System.out.println("Block : " + x + "," + y + "," + z);

            }

            }

    }

    }

    }

 

This code spams my console in multiplayer. If I change getBlockById to 1 it finds nothing in multiplayer and still works in singleplayer.

 

Why does this happen?

Link to comment
Share on other sites

What do you exactly mean with the constant of the block class? If I try:

 

System.out.println(event.getChunk().getBlock(x,y,z).toString());

 

This still ends up spamming only air blocks like this:

 

net.minecraft.block.BlockAir@503ecb24

 

If I'm right thats the constant of the block or isn't it?

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.