#Classe principale(Classe principale)
Dans la déclaration
public static Main INSTANCE;
Dans le onInit
KeyBindingRegistry.registerKeyBinding(new TutoKeyBind());
#Crée ta classe qui gère les touches (Crée ta classe qui gère les touches )
| public class TutoKeyBind extends KeyHandler |
| { |
| public static KeyBinding tutoKey = new KeyBinding("key.button.tutoKey", Keyboard.KEY_P); |
| |
| public FicheKeyBind() |
| { |
| |
| super(new KeyBinding[] {tutoKey}, new boolean[] {false}); |
| } |
| |
| @Override |
| public String getLabel() |
| { |
| return "Key Tutorial"; |
| } |
| |
| @Override |
| public void keyDown(EnumSet <ticktype>types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { |
| } |
| |
| @Override |
| public void keyUp(EnumSet <ticktype>types, KeyBinding kb, boolean tickEnd) |
| { |
| |
| EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; |
| Minecraft mc = Minecraft.getMinecraft(); |
| |
| if(kb.keyCode == tutoKey.keyCode && mc.currentScreen == null) |
| { |
| player.openGui(Main.INSTANCE,TutorielGuiHandler.tutoGuiHandler,player.worldObj,(int) player.posX,(int) player.posY,(int) player.posZ); |
| } |
| |
| } |
| |
| @Override |
| public EnumSet <ticktype>ticks() |
| { |
| return EnumSet.allOf(TickType.class); |
| } |
| } |
#Ton GuiHandler(Ton GuiHandler)
Attention un seul HuiGandler par mod.
| public class TutorielGuiHandler implements IGuiHandler{ |
| public static final int tutoGuiHandler = 1; |
| |
| private EntityLiving entityL; |
| @Override |
| public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { |
| switch(ID){ |
| case 1: return new ContainerTuto(); |
| default : return null; |
| } |
| |
| } |
| |
| @Override |
| public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { |
| switch(ID){ |
| case 1: return new GuiTuto(); |
| default : return null; |
| } |
| } |
| |
| } |
| ```</ticktype></ticktype></ticktype> |