Jump to content

[1.16.4] How to use TickEvent.ClientTickEvent ?


Recommended Posts

Posted

For some reason, the console doesnt print anything

@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
    System.out.println("Hello");
}
Posted
37 minutes ago, Klarks said:

For some reason, the console doesnt print anything


@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
    System.out.println("Hello");
}

 

Posted (edited)
MinecraftForge.EVENT_BUS.register(PlayerCapa.class);
public class PlayerCapa {
  

    @SubscribeEvent (priority = EventPriority.LOWEST)
    public static void onClientTick(TickEvent.ClientTickEvent event) {
    
    }

}
Edited by Klarks
Posted (edited)

I use that way now

//edited
@Mod.EventBusSubscriber(modid = Main.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class ClientEventBusSubscriber {
    public static final KeyBinding TEST = new KeyBinding("key.structure.desc", GLFW.GLFW_KEY_R, "key.magicbeans.category");
    private static Field KEYBIND_ARRAY = null;

 
    
    @SubscribeEvent (priority = EventPriority.LOWEST)
    public static void onClientTick(TickEvent.ClientTickEvent event) throws Exception {
        if(KEYBIND_ARRAY == null){
            KEYBIND_ARRAY = KeyBinding.class.getDeclaredField("KEYBIND_ARRAY");
            KEYBIND_ARRAY.setAccessible(true);
        }
        if(event.phase.equals(TickEvent.Phase.END)){
            Map<String, KeyBinding> binds = (Map<String, KeyBinding>) KEYBIND_ARRAY.get(null);
            for (String bind : binds.keySet()) {
                if(binds.get(bind).isKeyDown() && (binds.get(bind) == TEST)){
                    System.out.println("R");
                    break;
                }
            }
        }
    }




}
Edited by Klarks

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.