diff --git a/src/main/java/kasuga/lib/core/KasugaLibStacks.java b/src/main/java/kasuga/lib/core/KasugaLibStacks.java index 867502cf..11a8d317 100644 --- a/src/main/java/kasuga/lib/core/KasugaLibStacks.java +++ b/src/main/java/kasuga/lib/core/KasugaLibStacks.java @@ -61,7 +61,7 @@ public KasugaLibStacks(IEventBus bus) { MinecraftForge.EVENT_BUS.addListener(PacketEvent::onServerPayloadHandleEvent); bus.addListener(BothSetupEvent::onFMLCommonSetup); bus.addListener(EntityAttributeEvent::entityAttributeCreation); - bus.addListener(KeyBindingReg::register); + bus.addListener(BothSetupEvent::RegisterKeyEvent); if(Envs.isClient()) { MinecraftForge.EVENT_BUS.addListener(PacketEvent::onClientPayloadHandleEvent); diff --git a/src/main/java/kasuga/lib/core/events/both/BothSetupEvent.java b/src/main/java/kasuga/lib/core/events/both/BothSetupEvent.java index 8e6cfe1d..b4a64618 100644 --- a/src/main/java/kasuga/lib/core/events/both/BothSetupEvent.java +++ b/src/main/java/kasuga/lib/core/events/both/BothSetupEvent.java @@ -1,10 +1,23 @@ package kasuga.lib.core.events.both; import kasuga.lib.KasugaLib; +import net.minecraftforge.client.event.RegisterKeyMappingsEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; public class BothSetupEvent { public static void onFMLCommonSetup(FMLCommonSetupEvent event){ } + + @SubscribeEvent + public static void RegisterKeyEvent(RegisterKeyMappingsEvent event) { + KasugaLib.STACKS.getRegistries().forEach( + (name, registry) -> { + registry.key().forEach( + ((s, keyBindingReg) -> event.register(keyBindingReg.getMapping())) + ); + } + ); + } } diff --git a/src/main/java/kasuga/lib/registrations/client/KeyBindingReg.java b/src/main/java/kasuga/lib/registrations/client/KeyBindingReg.java index 3545999c..380124cc 100644 --- a/src/main/java/kasuga/lib/registrations/client/KeyBindingReg.java +++ b/src/main/java/kasuga/lib/registrations/client/KeyBindingReg.java @@ -25,7 +25,6 @@ public class KeyBindingReg extends Reg { public final String translationKey; public final String category; - private int keyCode = -1; private KeyMapping mapping; private Environment env = Environment.ALL; @@ -33,7 +32,6 @@ public class KeyBindingReg extends Reg { private Consumer serverHandler; private KeyModifier modifier = KeyModifier.NONE; private InputConstants.Type type = InputConstants.Type.KEYSYM; - private static final ChannelReg keyChannel; private static final LinkedList registered; @@ -123,7 +121,6 @@ public KeyBindingReg submit(SimpleRegistry registry) { this.mapping = new KeyMapping(registrationKey, env.context, modifier, type, keyCode, category); registry.key().put(this.toString(), this); registered.add(this); - ClientRegistry.registerKeyBinding(this.mapping); return this; } @@ -142,11 +139,6 @@ public static void onClientTick(){ }); } - @Inner - public static void register(RegisterKeyMappingsEvent event) { - reference.forEach(reg -> event.register(reg.mapping)); - } - @Override public String getIdentifier() { return "key_binding";