Advertisement
Benjamin_Loison

ClientProxy

Oct 13th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.27 KB | None | 0 0
  1. package fr.altiscraft.altiscraft.proxy;
  2.  
  3.  
  4. import org.lwjgl.input.Keyboard;
  5.  
  6. import cpw.mods.fml.client.FMLClientHandler;
  7. import cpw.mods.fml.client.registry.ClientRegistry;
  8. import cpw.mods.fml.client.registry.RenderingRegistry;
  9. import cpw.mods.fml.common.FMLCommonHandler;
  10. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  11. import cpw.mods.fml.common.gameevent.InputEvent;
  12. import cpw.mods.fml.common.gameevent.TickEvent;
  13. import cpw.mods.fml.relauncher.SideOnly;
  14. import fr.altiscraft.altiscraft.common.GuiCarte;
  15. import fr.altiscraft.altiscraft.common.GuiCustomMainMenu;
  16. import fr.altiscraft.altiscraft.common.GuiEchapMenu;
  17. import fr.altiscraft.altiscraft.common.GuiInv;
  18. import fr.altiscraft.altiscraft.common.GuiMort;
  19. import fr.altiscraft.altiscraft.common.TileEntityATM;
  20. import fr.altiscraft.altiscraft.common.TileEntityBarriereFerme;
  21. import fr.altiscraft.altiscraft.common.TileEntityBarriereOuverte;
  22. import fr.altiscraft.altiscraft.common.TileEntityBasket;
  23. import fr.altiscraft.altiscraft.common.TileEntityChemine;
  24. import fr.altiscraft.altiscraft.common.TileEntityChemineVide;
  25. import fr.altiscraft.altiscraft.common.TileEntityCoco;
  26. import fr.altiscraft.altiscraft.common.TileEntityDrapeau;
  27. import fr.altiscraft.altiscraft.common.TileEntityLampadaire;
  28. import fr.altiscraft.altiscraft.common.TileEntityPanneauInterdit;
  29. import fr.altiscraft.altiscraft.common.TileEntityPanneauSTOP;
  30. import fr.altiscraft.altiscraft.common.TileEntityPieton;
  31. import fr.altiscraft.altiscraft.common.TileEntityPoubelle;
  32. import fr.altiscraft.altiscraft.common.TileEntityVATM;
  33. import fr.altiscraft.altiscraft.common.TileEntityVLampadaire;
  34. import fr.altiscraft.altiscraft.common.TileEntityVentilateur;
  35. import fr.altiscraft.altiscraft.common.TileEntityVolet;
  36. import net.minecraft.client.Minecraft;
  37. import net.minecraft.client.audio.PositionedSoundRecord;
  38. import net.minecraft.client.gui.GuiGameOver;
  39. import net.minecraft.client.gui.GuiIngameMenu;
  40. import net.minecraft.client.gui.GuiMainMenu;
  41. import net.minecraft.client.gui.GuiScreen;
  42. import net.minecraft.client.gui.GuiScreenServerList;
  43. import net.minecraft.client.gui.inventory.GuiInventory;
  44. import net.minecraft.client.settings.GameSettings;
  45. import net.minecraft.client.settings.KeyBinding;
  46. import net.minecraft.inventory.Container;
  47. import net.minecraft.util.ResourceLocation;
  48. import net.minecraftforge.client.event.GuiScreenEvent;
  49. import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
  50.  
  51. public class ClientProxy extends CommonProxy {
  52.     public GuiMainMenu ph;
  53.     public Minecraft mc;
  54.     public GameSettings gameSettings;
  55.     public static int tesrRenderId;
  56.     public static boolean GPS = false;
  57.     public Container thePlayer;
  58.  
  59.     public static void setGPS(boolean gPS) {
  60.         GPS = gPS;
  61.     }
  62.     public static boolean isGPS() {
  63.         return GPS;
  64.     }
  65.     public void registerRender() {
  66.         FMLCommonHandler.instance().bus().register(this);
  67.         System.out.println("Méthode côté client");
  68.        
  69.         ClientRegistry.registerKeyBinding(keyBindInv);
  70.         ClientRegistry.registerKeyBinding(keyBindCarte);
  71.         ClientRegistry.registerKeyBinding(keyBindGPS);
  72.  
  73.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityATM.class, new TileEntityATMSpecialRenderer());
  74.        
  75.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVentilateur.class, new TileEntityVentilateurSpecialRenderer());
  76.  
  77.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVATM.class, new TileEntityVATMSpecialRenderer());
  78.  
  79.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCoco.class, new TileEntityCocoSpecialRenderer());
  80.  
  81.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLampadaire.class, new TileEntityLampadaireSpecialRenderer());
  82.  
  83.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVLampadaire.class, new TileEntityVLampadaireSpecialRenderer());
  84.        
  85.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPoubelle.class, new TileEntityPoubelleSpecialRenderer());
  86.        
  87.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBarriereFerme.class, new TileEntityBarriereFermeSpecialRenderer());
  88.        
  89.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBarriereOuverte.class, new TileEntityBarriereOuverteSpecialRenderer());
  90.        
  91.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPanneauSTOP.class, new TileEntityPanneauSTOPSpecialRenderer());
  92.        
  93.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPanneauInterdit.class, new TileEntityPanneauInterditSpecialRenderer());
  94.  
  95.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBasket.class, new TileEntityBasketSpecialRenderer());
  96.  
  97.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPieton.class, new TileEntityPietonSpecialRenderer());
  98.  
  99.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDrapeau.class, new TileEntityDrapeauSpecialRenderer());
  100.            
  101.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVolet.class, new TileEntityVoletSpecialRenderer());
  102.        
  103.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChemine.class, new TileEntityChemineSpecialRenderer());
  104.    
  105.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChemineVide.class, new TileEntityChemineVideSpecialRenderer());
  106.  
  107.         tesrRenderId = RenderingRegistry.getNextAvailableRenderId();
  108.         RenderingRegistry.registerBlockHandler(new TESRInventoryRenderer());
  109.     }
  110.  
  111.     private static KeyBinding keyBindInv = new KeyBinding("Inventaire d'AltisCraft", 21, "key.categories.inventory");
  112.     private static KeyBinding keyBindCarte = new KeyBinding("Carte", 50, "key.categories.inventory");
  113.     private static KeyBinding keyBindGPS = new KeyBinding("GPS", Keyboard.KEY_G, "key.categories.inventory");
  114.  
  115.     @SubscribeEvent @SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) public void onTickGuiMainMenu(TickEvent.ClientTickEvent event) {Minecraft mc = FMLClientHandler.instance().getClient();GuiScreen currentScreen = mc.currentScreen;if ((mc.currentScreen != null) && (mc.currentScreen.getClass().equals(GuiMainMenu.class))){mc.displayGuiScreen(new GuiCustomMainMenu());}}
  116.  
  117.     @SubscribeEvent @SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) public void onTickGuiF3(TickEvent.ClientTickEvent event) {Minecraft mc = FMLClientHandler.instance().getClient();GuiScreen currentScreen = mc.currentScreen;if ((mc.currentScreen != null) && (mc.currentScreen.getClass().equals(GuiIngameMenu.class))){mc.displayGuiScreen(new GuiEchapMenu());}}
  118.     @SubscribeEvent @SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) public void onTickGuiEchap(TickEvent.ClientTickEvent event) {Minecraft mc = FMLClientHandler.instance().getClient();GuiScreen currentScreen = mc.currentScreen;if ((mc.currentScreen != null) && (mc.currentScreen.getClass().equals(GuiGameOver.class))){mc.displayGuiScreen(new GuiMort());}}
  119.    
  120.     @SubscribeEvent @SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) public void onTickInv(TickEvent.ClientTickEvent event) {Minecraft mc = FMLClientHandler.instance().getClient();GuiScreen currentScreen = mc.currentScreen;if ((mc.currentScreen != null) && (mc.currentScreen.getClass().equals(GuiInventory.class))) {Minecraft.getMinecraft().displayGuiScreen(new GuiInv());}}
  121.    
  122.     @SubscribeEvent
  123.     public void onInv(InputEvent.KeyInputEvent event) {
  124.         if (keyBindInv.isPressed()) {
  125.             keyInvTyped();
  126.         }
  127.     }
  128.    
  129.     @SubscribeEvent
  130.     public void initGuiScreenServerListEvent(InitGuiEvent.Post event) {
  131.         if(event.gui instanceof GuiScreenServerList)
  132.         {
  133.             event.setCanceled(true);
  134.         }
  135.     }
  136.  
  137.     @SubscribeEvent
  138.     public void onCarte(InputEvent.KeyInputEvent event) {
  139.         if (keyBindCarte.isPressed()) {
  140.             keyCarteTyped();
  141.         }
  142.     }
  143.    
  144.     @SubscribeEvent
  145.     public void onGPS(InputEvent.KeyInputEvent event) {
  146.         if (keyBindGPS.isPressed()) {
  147.             keyGPSTyped();
  148.         }
  149.     }
  150.    
  151.     private void keyInvTyped() {
  152.         Minecraft.getMinecraft().displayGuiScreen(new GuiInv());
  153.         Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
  154.     }
  155.    
  156.     private void keyGPSTyped() {
  157.         if(this.isGPS())
  158.         {
  159.             this.setGPS(false);
  160.         }
  161.         else
  162.         {
  163.             this.setGPS(true);
  164.         }
  165.     }
  166.  
  167.     private void keyCarteTyped() {
  168.         Minecraft.getMinecraft().displayGuiScreen(new GuiCarte());
  169.         Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
  170.     }
  171.    
  172.     public void GuiScreenEvent(GuiScreenEvent event){
  173.         if(event.gui instanceof GuiInventory){
  174.             event.setCanceled(true);
  175.         }
  176.     }
  177.    
  178. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement