Advertisement
Benjamin_Loison

ClientProxy

Oct 13th, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.46 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.EntityMobBenjaminLoison;
  15. import fr.altiscraft.altiscraft.common.GuiCarte;
  16. import fr.altiscraft.altiscraft.common.GuiCustomMainMenu;
  17. import fr.altiscraft.altiscraft.common.GuiEchapMenu;
  18. import fr.altiscraft.altiscraft.common.GuiInv;
  19. import fr.altiscraft.altiscraft.common.GuiMort;
  20. import fr.altiscraft.altiscraft.common.RenderMobBenjaminLoison;
  21. import fr.altiscraft.altiscraft.common.TileEntityATM;
  22. import fr.altiscraft.altiscraft.common.TileEntityBarriereFerme;
  23. import fr.altiscraft.altiscraft.common.TileEntityBarriereOuverte;
  24. import fr.altiscraft.altiscraft.common.TileEntityBasket;
  25. import fr.altiscraft.altiscraft.common.TileEntityChemine;
  26. import fr.altiscraft.altiscraft.common.TileEntityChemineVide;
  27. import fr.altiscraft.altiscraft.common.TileEntityCoco;
  28. import fr.altiscraft.altiscraft.common.TileEntityDrapeau;
  29. import fr.altiscraft.altiscraft.common.TileEntityLampadaire;
  30. import fr.altiscraft.altiscraft.common.TileEntityPanneauInterdit;
  31. import fr.altiscraft.altiscraft.common.TileEntityPanneauSTOP;
  32. import fr.altiscraft.altiscraft.common.TileEntityPieton;
  33. import fr.altiscraft.altiscraft.common.TileEntityPoubelle;
  34. import fr.altiscraft.altiscraft.common.TileEntityVATM;
  35. import fr.altiscraft.altiscraft.common.TileEntityVLampadaire;
  36. import fr.altiscraft.altiscraft.common.TileEntityVentilateur;
  37. import fr.altiscraft.altiscraft.common.TileEntityVolet;
  38. import net.minecraft.client.Minecraft;
  39. import net.minecraft.client.audio.PositionedSoundRecord;
  40. import net.minecraft.client.gui.GuiGameOver;
  41. import net.minecraft.client.gui.GuiIngameMenu;
  42. import net.minecraft.client.gui.GuiMainMenu;
  43. import net.minecraft.client.gui.GuiScreen;
  44. import net.minecraft.client.gui.GuiScreenServerList;
  45. import net.minecraft.client.gui.inventory.GuiInventory;
  46. import net.minecraft.client.model.ModelBiped;
  47. import net.minecraft.client.settings.GameSettings;
  48. import net.minecraft.client.settings.KeyBinding;
  49. import net.minecraft.inventory.Container;
  50. import net.minecraft.util.ResourceLocation;
  51. import net.minecraftforge.client.event.GuiScreenEvent;
  52. import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
  53.  
  54. public class ClientProxy extends CommonProxy {
  55.     public GuiMainMenu ph;
  56.     public Minecraft mc;
  57.     public GameSettings gameSettings;
  58.     public static int tesrRenderId;
  59.     public static boolean GPS = false;
  60.     public Container thePlayer;
  61.  
  62.     public static void setGPS(boolean gPS) {
  63.         GPS = gPS;
  64.     }
  65.     public static boolean isGPS() {
  66.         return GPS;
  67.     }
  68.     public void registerRender() {
  69.         FMLCommonHandler.instance().bus().register(this);
  70.         System.out.println("Méthode côté client");
  71.         RenderingRegistry.registerEntityRenderingHandler(EntityMobBenjaminLoison.class,
  72.                 new RenderMobBenjaminLoison(new ModelBiped()));
  73.        
  74.         ClientRegistry.registerKeyBinding(keyBindInv);
  75.         ClientRegistry.registerKeyBinding(keyBindCarte);
  76.         ClientRegistry.registerKeyBinding(keyBindGPS);
  77.  
  78.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityATM.class, new TileEntityATMSpecialRenderer());
  79.        
  80.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVentilateur.class, new TileEntityVentilateurSpecialRenderer());
  81.  
  82.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVATM.class, new TileEntityVATMSpecialRenderer());
  83.  
  84.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCoco.class, new TileEntityCocoSpecialRenderer());
  85.  
  86.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLampadaire.class, new TileEntityLampadaireSpecialRenderer());
  87.  
  88.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVLampadaire.class, new TileEntityVLampadaireSpecialRenderer());
  89.        
  90.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPoubelle.class, new TileEntityPoubelleSpecialRenderer());
  91.        
  92.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBarriereFerme.class, new TileEntityBarriereFermeSpecialRenderer());
  93.        
  94.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBarriereOuverte.class, new TileEntityBarriereOuverteSpecialRenderer());
  95.        
  96.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPanneauSTOP.class, new TileEntityPanneauSTOPSpecialRenderer());
  97.        
  98.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPanneauInterdit.class, new TileEntityPanneauInterditSpecialRenderer());
  99.  
  100.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBasket.class, new TileEntityBasketSpecialRenderer());
  101.  
  102.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPieton.class, new TileEntityPietonSpecialRenderer());
  103.  
  104.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDrapeau.class, new TileEntityDrapeauSpecialRenderer());
  105.            
  106.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVolet.class, new TileEntityVoletSpecialRenderer());
  107.        
  108.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChemine.class, new TileEntityChemineSpecialRenderer());
  109.    
  110.         ClientRegistry.bindTileEntitySpecialRenderer(TileEntityChemineVide.class, new TileEntityChemineVideSpecialRenderer());
  111.  
  112.         tesrRenderId = RenderingRegistry.getNextAvailableRenderId();
  113.         RenderingRegistry.registerBlockHandler(new TESRInventoryRenderer());
  114.     }
  115.  
  116.     private static KeyBinding keyBindInv = new KeyBinding("Inventaire d'AltisCraft", 21, "key.categories.inventory");
  117.     private static KeyBinding keyBindCarte = new KeyBinding("Carte", 50, "key.categories.inventory");
  118.     private static KeyBinding keyBindGPS = new KeyBinding("GPS", Keyboard.KEY_G, "key.categories.inventory");
  119.  
  120. //  @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());}}
  121.  
  122.     @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());}}
  123.     @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());}}
  124.    
  125. //  @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());}}
  126.    
  127.     @SubscribeEvent
  128.     public void onInv(InputEvent.KeyInputEvent event) {
  129.         if (keyBindInv.isPressed()) {
  130.             keyInvTyped();
  131.         }
  132.     }
  133.    
  134.     @SubscribeEvent
  135.     public void initGuiScreenServerListEvent(InitGuiEvent.Post event) {
  136.         if(event.gui instanceof GuiScreenServerList)
  137.         {
  138.             event.setCanceled(true);
  139.         }
  140.     }
  141.    
  142.     /*@SubscribeEvent
  143.     public void onGuiOpen(GuiOpenEvent event) {
  144.         if (event.gui instanceof GuiMainMenu) event.gui = new GuiCustomMainMenu();
  145.         if (event.gui instanceof GuiIngameMenu) event.gui = new GuiEchapMenu();
  146.         if (event.gui instanceof GuiGameOver) event.gui = new G();
  147.     }*/
  148.  
  149.     @SubscribeEvent
  150.     public void onCarte(InputEvent.KeyInputEvent event) {
  151.         if (keyBindCarte.isPressed()) {
  152.             keyCarteTyped();
  153.         }
  154.     }
  155.    
  156.     @SubscribeEvent
  157.     public void onGPS(InputEvent.KeyInputEvent event) {
  158.         if (keyBindGPS.isPressed()) {
  159.             keyGPSTyped();
  160.         }
  161.     }
  162.    
  163.     private void keyInvTyped() {
  164. //      Minecraft.getMinecraft().thePlayer.sendChatMessage("/inventaire");
  165. //      Minecraft.getMinecraft().displayGuiScreen(new GuiPlayerList(PacketPlayerList.playerList));
  166.         Minecraft.getMinecraft().displayGuiScreen(new GuiInv());
  167.         Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
  168.     }
  169.    
  170.     private void keyGPSTyped() {
  171.         if(this.isGPS())
  172.         {
  173.             this.setGPS(false);
  174.         }
  175.         else
  176.         {
  177.             this.setGPS(true);
  178.         }
  179.         //Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
  180.     }
  181.  
  182.     private void keyCarteTyped() {
  183.         Minecraft.getMinecraft().displayGuiScreen(new GuiCarte());
  184.         Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
  185. //      Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("altiscraft", "secrets"), 1.0F));
  186.     }
  187.  
  188.     //public static ResourceLocation getLocationSkin(String Skin) {
  189.     //  return new ResourceLocation("skins/" + StringUtils.stripControlCodes(Skin));
  190.     //}
  191.    
  192.     public void GuiScreenEvent(GuiScreenEvent event){
  193.         if(event.gui instanceof GuiInventory){
  194.             event.setCanceled(true);
  195.         }
  196.     }
  197.    
  198. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement