Jump to content

Recommended Posts

Posted

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!

Posted

This should be in modder support.

 

Did you register your event class?

Are other events also not called?

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

Posted

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

}

}

Posted

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.

Posted

Allright I got it working now on singleplayer with MinecraftForge.EVENT_BUS.register(new Events()); But for some reason none of these events call on multiplayer servers? Do I need another event for this? I'm working with world generating.

Posted

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?

Posted

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?

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.