Ajouter des touches personalisées
-
@robin4002 Classd’event le gui ??
-
Non. C’est une autre classe que tu dois créé si tu ne l’as pas déjà.
-
@robin4002 créer une classe qu ise nomme comment est je doit mettre quoi dedans désolé si je suis chiant a poser beaucoup de question
-
Tu dois y mettre la fonction de l’event.
Et le nom c’est comme tu veux. -
@robin4002 la fonction d’event c’est MinecraftForge.EVENT_BUS.register(new TaClasseDevent()); ??
-
ET C4EST POSSIBLE DE CR2ER UNE SORTE DE CREATIVE TAB SANS SLOT DANS UN GUI CUSTOM ??
-
Les questions que tu poses démontre un manque des bases.
J’ai vraiment pas le temps ni l’envie de réexpliquer des éléments déjà disponible dans des tutoriels :
https://www.minecraftforgefrance.fr/topic/636/utiliser-les-événements -
@robin4002 c’est bon mais quand j’appuie sur ma touche sa me met
java.lang.ClassCastException: java.lang.Class cannot be cast to net.minecraft.client.gui.GuiScreen at fr.astro.athenamod.proxy.ClientProxy.keyPressed(ClientProxy.java:38) ~[ClientProxy.class:?] at fr.astro.athenamod.proxy.ClientProxy.onEvent(ClientProxy.java:32) ~[ClientProxy.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_ClientProxy_onEvent_KeyInputEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?] at net.minecraftforge.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:565) [FMLCommonHandler.class:?] at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2144) [Minecraft.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1935) [Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1188) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:442) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_281] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_281] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_281] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_281] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_281] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_281] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_281] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_281] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:25) [start/:?] [00:10:43] [Client thread/ERROR] [FML]: Index: 1 Listeners: [00:10:43] [Client thread/ERROR] [FML]: 0: NORMAL [00:10:43] [Client thread/ERROR] [FML]: 1: ASM: fr.astro.athenamod.proxy.ClientProxy@eb3b4d7 onEvent(Lnet/minecraftforge/fml/common/gameevent/InputEvent$KeyInputEvent;)V [00:10:47] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server [00:10:47] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players [00:10:47] [Server thread/INFO] [minecraft/MinecraftServer]: Saving worlds [00:10:47] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test'/overworld [00:10:49] [Server thread/INFO] [FML]: Unloading dimension 0 [00:10:49] [Server thread/INFO] [FML]: Applying holder lookups [00:10:49] [Server thread/INFO] [FML]: Holder lookups applied [00:10:52] [Client thread/FATAL] [minecraft/Minecraft]: Unreported exception thrown! java.lang.ClassCastException: java.lang.Class cannot be cast to net.minecraft.client.gui.GuiScreen at fr.astro.athenamod.proxy.ClientProxy.keyPressed(ClientProxy.java:38) ~[ClientProxy.class:?] at fr.astro.athenamod.proxy.ClientProxy.onEvent(ClientProxy.java:32) ~[ClientProxy.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_ClientProxy_onEvent_KeyInputEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) ~[EventBus.class:?] at net.minecraftforge.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:565) ~[FMLCommonHandler.class:?] at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2144) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1935) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1188) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:442) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_281] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_281] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_281] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_281] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_281] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_281] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_281] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_281] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:25) [start/:?] [00:10:52] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ---- // There are four lights! Time: 2/3/21 12:10 AM Description: Unexpected error java.lang.ClassCastException: java.lang.Class cannot be cast to net.minecraft.client.gui.GuiScreen at fr.astro.athenamod.proxy.ClientProxy.keyPressed(ClientProxy.java:38) at fr.astro.athenamod.proxy.ClientProxy.onEvent(ClientProxy.java:32) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_ClientProxy_onEvent_KeyInputEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) at net.minecraftforge.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:565) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2144) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1935) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1188) at net.minecraft.client.Minecraft.run(Minecraft.java:442) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:25) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at fr.astro.athenamod.proxy.ClientProxy.keyPressed(ClientProxy.java:38) at fr.astro.athenamod.proxy.ClientProxy.onEvent(ClientProxy.java:32) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_ClientProxy_onEvent_KeyInputEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) at net.minecraftforge.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:565) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2144) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player33'/425, l='MpServer', x=184.50, y=66.00, z=257.50]] Chunk stats: MultiplayerChunkCache: 529, 529 Level seed: 0 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: Level spawn location: World: (180,64,256), Chunk: (at 4,4,0 in 11,16; contains blocks 176,0,256 to 191,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Level time: 237 game time, 237 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 88 total; [EntitySquid['Squid'/256, l='MpServer', x=194.98, y=61.86, z=211.70], EntitySheep['Sheep'/128, l='MpServer', x=109.50, y=70.00, z=216.45], EntityBat['Bat'/257, l='MpServer', x=205.75, y=34.03, z=253.51], EntitySheep['Sheep'/129, l='MpServer', x=111.50, y=70.00, z=219.50], EntityBat['Bat'/258, l='MpServer', x=203.15, y=35.29, z=255.22], EntitySheep['Sheep'/130, l='MpServer', x=111.46, y=67.00, z=225.54], EntitySheep['Sheep'/259, l='MpServer', x=195.50, y=69.00, z=297.53], EntitySheep['Sheep'/260, l='MpServer', x=195.55, y=69.00, z=296.48], EntitySheep['Sheep'/132, l='MpServer', x=109.50, y=74.00, z=333.50], EntitySheep['Sheep'/261, l='MpServer', x=195.50, y=69.00, z=302.50], EntitySheep['Sheep'/262, l='MpServer', x=197.46, y=68.00, z=301.43], EntityZombie['Zombie'/269, l='MpServer', x=223.40, y=31.00, z=232.50], EntityZombie['Zombie'/270, l='MpServer', x=209.50, y=34.00, z=252.50], EntityWitch['Witch'/271, l='MpServer', x=209.50, y=18.00, z=259.50], EntityPig['Pig'/274, l='MpServer', x=229.50, y=78.00, z=197.50], EntityPig['Pig'/275, l='MpServer', x=229.50, y=78.00, z=197.50], EntitySheep['Sheep'/147, l='MpServer', x=113.47, y=71.00, z=213.37], EntityPig['Pig'/276, l='MpServer', x=231.50, y=78.00, z=193.50], EntityPig['Pig'/277, l='MpServer', x=224.23, y=75.00, z=190.72], EntityCreeper['Creeper'/278, l='MpServer', x=226.50, y=31.00, z=234.50], EntitySquid['Squid'/150, l='MpServer', x=121.60, y=59.00, z=298.16], EntityZombie['Zombie'/279, l='MpServer', x=225.50, y=31.00, z=235.87], EntityMinecartChest['Minecart with Chest'/151, l='MpServer', x=118.50, y=15.06, z=318.50], EntitySpider['Spider'/280, l='MpServer', x=224.50, y=31.00, z=232.61], EntityCreeper['Creeper'/152, l='MpServer', x=115.50, y=15.00, z=318.50], EntitySkeleton['Skeleton'/281, l='MpServer', x=227.50, y=30.00, z=245.50], EntitySheep['Sheep'/155, l='MpServer', x=112.50, y=76.00, z=335.50], EntitySheep['Sheep'/156, l='MpServer', x=112.50, y=76.00, z=334.50], EntitySheep['Sheep'/157, l='MpServer', x=113.50, y=76.00, z=336.50], EntityBat['Bat'/289, l='MpServer', x=244.53, y=30.32, z=181.35], EntityBat['Bat'/290, l='MpServer', x=255.68, y=34.08, z=191.37], EntitySkeleton['Skeleton'/163, l='MpServer', x=133.46, y=40.00, z=298.52], EntityBat['Bat'/291, l='MpServer', x=251.75, y=32.06, z=188.25], EntitySpider['Spider'/164, l='MpServer', x=135.66, y=40.00, z=299.29], EntityZombie['Zombie'/165, l='MpServer', x=137.52, y=40.00, z=294.85], EntitySkeleton['Skeleton'/166, l='MpServer', x=142.50, y=30.00, z=309.50], EntityPlayerSP['Player33'/425, l='MpServer', x=184.50, y=66.00, z=257.50], EntityZombie['Zombie'/172, l='MpServer', x=148.50, y=26.00, z=218.50], EntitySheep['Sheep'/173, l='MpServer', x=154.50, y=66.00, z=255.50], EntitySheep['Sheep'/174, l='MpServer', x=157.35, y=66.00, z=253.91], EntitySheep['Sheep'/175, l='MpServer', x=153.50, y=67.00, z=258.50], EntityZombie['Zombie'/176, l='MpServer', x=144.50, y=8.61, z=298.08], EntityBat['Bat'/177, l='MpServer', x=161.31, y=48.00, z=286.20], EntityCreeper['Creeper'/178, l='MpServer', x=149.51, y=30.00, z=311.91], EntityBat['Bat'/306, l='MpServer', x=256.34, y=31.10, z=185.33], EntitySkeleton['Skeleton'/179, l='MpServer', x=146.50, y=30.00, z=312.50], EntitySkeleton['Skeleton'/180, l='MpServer', x=144.50, y=30.00, z=312.50], EntityCreeper['Creeper'/181, l='MpServer', x=148.50, y=43.00, z=317.50], EntityZombie['Zombie'/182, l='MpServer', x=149.50, y=20.00, z=328.50], EntityCreeper['Creeper'/183, l='MpServer', x=148.10, y=20.00, z=331.50], EntityCreeper['Creeper'/184, l='MpServer', x=149.50, y=20.00, z=330.50], EntityZombie['Zombie'/312, l='MpServer', x=264.51, y=24.00, z=206.30], EntityCreeper['Creeper'/185, l='MpServer', x=150.48, y=20.00, z=328.83], EntityCreeper['Creeper'/313, l='MpServer', x=263.50, y=24.00, z=206.50], EntitySkeleton['Skeleton'/186, l='MpServer', x=146.50, y=44.00, z=324.50], EntityCreeper['Creeper'/314, l='MpServer', x=264.46, y=24.00, z=206.87], EntityPig['Pig'/315, l='MpServer', x=256.50, y=74.00, z=240.50], EntityPig['Pig'/316, l='MpServer', x=258.50, y=72.00, z=240.50], EntityPig['Pig'/317, l='MpServer', x=257.50, y=73.00, z=240.50], EntityPig['Pig'/318, l='MpServer', x=259.50, y=71.00, z=242.50], EntityCreeper['Creeper'/200, l='MpServer', x=174.80, y=29.00, z=233.59], EntityCreeper['Creeper'/201, l='MpServer', x=170.30, y=30.00, z=232.30], EntityZombie['Zombie'/202, l='MpServer', x=168.50, y=30.00, z=238.55], EntityZombie['Zombie'/203, l='MpServer', x=171.52, y=30.00, z=241.24], EntitySkeleton['Skeleton'/204, l='MpServer', x=173.50, y=20.00, z=241.50], EntitySkeleton['Skeleton'/205, l='MpServer', x=173.50, y=20.00, z=240.50], EntityZombie['Zombie'/206, l='MpServer', x=168.50, y=30.00, z=240.50], EntitySheep['Sheep'/207, l='MpServer', x=161.97, y=65.00, z=261.43], EntityBat['Bat'/208, l='MpServer', x=162.44, y=47.10, z=290.96], EntitySheep['Sheep'/209, l='MpServer', x=167.71, y=64.00, z=335.48], EntityCreeper['Creeper'/229, l='MpServer', x=188.50, y=15.00, z=213.50], EntityCreeper['Creeper'/230, l='MpServer', x=179.50, y=17.00, z=215.78], EntityCreeper['Creeper'/231, l='MpServer', x=179.50, y=17.00, z=218.50], EntityZombie['Zombie'/232, l='MpServer', x=177.20, y=17.00, z=216.41], EntityZombie['Zombie'/233, l='MpServer', x=177.28, y=17.00, z=218.17], EntityBat['Bat'/234, l='MpServer', x=200.47, y=23.38, z=222.25], EntityBat['Bat'/235, l='MpServer', x=187.53, y=18.07, z=227.59], EntityWitch['Witch'/236, l='MpServer', x=186.50, y=20.00, z=230.50], EntitySkeleton['Skeleton'/237, l='MpServer', x=185.52, y=26.00, z=223.72], EntityCreeper['Creeper'/238, l='MpServer', x=183.50, y=22.00, z=236.78], EntityBat['Bat'/239, l='MpServer', x=190.59, y=13.51, z=310.97], EntitySkeleton['Skeleton'/240, l='MpServer', x=179.52, y=34.00, z=314.13], EntityCreeper['Creeper'/241, l='MpServer', x=184.50, y=14.00, z=330.50], EntityBat['Bat'/251, l='MpServer', x=188.25, y=25.10, z=225.51], EntityBat['Bat'/252, l='MpServer', x=196.44, y=14.06, z=214.92], EntitySquid['Squid'/253, l='MpServer', x=203.91, y=62.66, z=216.55], EntitySquid['Squid'/254, l='MpServer', x=195.84, y=62.44, z=212.79], EntitySquid['Squid'/255, l='MpServer', x=191.34, y=61.67, z=212.32]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:461) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2889) at net.minecraft.client.Minecraft.run(Minecraft.java:471) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:25)
-
Le problème se trouve dans ton client proxy, envoies le code.
-
import org.lwjgl.input.Keyboard; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; import net.minecraftforge.fml.common.network.internal.FMLMessage.OpenGui; public class ClientProxy extends CommonProxy { private static KeyBinding keyBindTest; private static final Object OpenGui = fr.astro.athenamod.f4.gui.GuiMain.class; private static KeyBinding keyBinding; public ClientProxy() { FMLCommonHandler.instance().bus().register(this); keyBinding = new KeyBinding(".Gui", Keyboard.KEY_F4, "key.categories.gameplay"); ClientRegistry.registerKeyBinding(keyBinding); } @SubscribeEvent public void onEvent(KeyInputEvent event) { if(keyBinding.isPressed()) { keyPressed(); } } private void keyPressed() { Minecraft.getMinecraft().displayGuiScreen(new OpenGui(GuiScreen)); } @Override public void preInit() { super.preInit(); } @Override public void Init() { super.Init(); } @Override public void postInit() { super.postInit(); } }
-
Supprimes complètement la ligne 16.
SiGuiMain
est le gui que tu veux ouvrir, il faut à la ligne 37 mettreMinecraft.getMinecraft().displayGuiScreen(new GuiMain());
-
-
-