Jump to content

Recommended Posts

Posted

In this same vein, seeing some sample/tutorial code specifically pertaining to 1.7.2 would be awesome for us noobs. Although I am slowly patching things together. :P

Posted

You can just type Event. and wait for your IDE to autofill with Events, they are all pretty self explanatory. You can also download the Javadoc. The ones below are taken directly from the Javadocs.

 

InputEvent.KeyInputEvent

InputEvent.MouseInputEvent

 

PlayerEvent.ItemCraftedEvent

PlayerEvent.ItemPickupEvent

PlayerEvent.ItemSmeltedEvent

PlayerEvent.PlayerChangedDimensionEvent

PlayerEvent.PlayerLoggedInEvent

PlayerEvent.PlayerLoggedOutEvent

PlayerEvent.PlayerRespawnEvent

 

TickEvent.ClientTickEvent

TickEvent.PlayerTickEvent

TickEvent.RenderTickEvent

TickEvent.ServerTickEvent

TickEvent.WorldTickEvent

 

As for some sample code...

 

@EventHandler
    public void preInit(FMLPreInitializationEvent event) {
        FMLCommonHandler.instance().bus().register(new ExampleEvent());
    }

 

public class TestEvent {
    @SubscribeEvent
    public void onItemPickup(PlayerEvent.ItemPickupEvent event) {
        System.out.println("You just picked up: " + event.pickedUp.toString());
    }
}

Posted

You can just type Event. and wait for your IDE to autofill with Events, they are all pretty self explanatory. You can also download the Javadoc. The ones below are taken directly from the Javadocs.

 

InputEvent.KeyInputEvent

InputEvent.MouseInputEvent

 

PlayerEvent.ItemCraftedEvent

PlayerEvent.ItemPickupEvent

PlayerEvent.ItemSmeltedEvent

PlayerEvent.PlayerChangedDimensionEvent

PlayerEvent.PlayerLoggedInEvent

PlayerEvent.PlayerLoggedOutEvent

PlayerEvent.PlayerRespawnEvent

 

TickEvent.ClientTickEvent

TickEvent.PlayerTickEvent

TickEvent.RenderTickEvent

TickEvent.ServerTickEvent

TickEvent.WorldTickEvent

 

As for some sample code...

 

@EventHandler
    public void preInit(FMLPreInitializationEvent event) {
        FMLCommonHandler.instance().bus().register(new ExampleEvent());
    }

 

public class TestEvent {
    @SubscribeEvent
    public void onItemPickup(PlayerEvent.ItemPickupEvent event) {
        System.out.println("You just picked up: " + event.pickedUp.toString());
    }
}

 

i thought there was more events then that :(

 

Posted

It should be noted that events derived from net.minecraftforge must be registered using:

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

 

Whereas events derived from cpw.mods.fml.common.gameevent must be registered using:

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

  • 4 weeks later...
Posted

I noticed that the PlayerEvent.PlayerLoggedOutEvent is not called when you quit the game, i tested it in both single and multiplayer.

But PlayerEvent.PlayerRespawnEvent works actually

 

Is there another event to use when you logout and quit the game to save config and such...

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.