• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    Résolu RenderGameOverlayEvent

    Anciennes versions
    1.6.4
    2
    7
    2199
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • T
      totos51 dernière édition par

      Bonjour à tous, j’aimerai remplacer la barre devie par un simple rectangle rouge dont la taille varie selon une valeur, cependant quand cette valeur varie, la taille elle, ne varie pas, voici le code, ai je simplement mal compris le fonctionnement?:

      ​@ForgeSubscribe
      
      public void RenderBloodBar(RenderGameOverlayEvent event)
      {
      ExtendsPropertiesPlayerBlood properties = (ExtendsPropertiesPlayerBlood) this.mc.thePlayer.getExtendedProperties(ExtendsPropertiesPlayerBlood.EXT_PRO_PLAYER_BLOOD);
      if (event.type == ElementType.FOOD && !event.isCancelable())
      {
      ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);
      int k1 = scaledresolution.getScaledWidth() / 2 - 91;
      int i2 = scaledresolution.getScaledHeight() - 39;
      int blood = properties.getBlood();
      this.drawRect(k1, i2, k1 + ((blood/1200)*81), i2 + 9, Color.RED.getRGB());
      }
      }
      

      Merci de votre aide,
      Cordialement
      Grég’ :3

      1 réponse Dernière réponse Répondre Citer 0
      • Gugu
        Gugu dernière édition par

        Perso j’ai ajouté un GUI custom dans mon mod, c’est plus simple, même si ça affiche un nombre.

        
        [size=x-small @SideOnly(Side.CLIENT)
        ]
        @SubscribeEvent
        
        public void renderGameOverlay(RenderGameOverlayEvent event) {
        
        if (Minecraft.getMinecraft().thePlayer == null
        
        || Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() == null)
        
        return;
        
        if (Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem()
        
        .getItem() instanceof ItemRcWeap) {
        
        ItemRcWeap item = (ItemRcWeap) Minecraft.getMinecraft().thePlayer
        
        .getCurrentEquippedItem().getItem();
        
        if (item.hasCrosshair || item.hideCrosshair)
        
        {
        
        if (event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS)
        
        {
        
        event.setCanceled(true);
        
        Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.icons);
        
        }
        
        }
        
        }
        [size=x-small }]
        

        https://github.com/Gugu42/RatchetAndClankMod/blob/master/java/com/gugu42/rcmod/gui/GuiBolt.java

        Avec ça tu devrais trouver comment cacher les parties de l’overlay ( dans mon cas le crosshair ) et comment utiliser une variable d’ExtProp

        "If you have a comprehensive explanation for everything then it decreases uncertainty and anxiety and reduces your cognitive load. And if you can use that simplifying algorithm to put yourself on the side of moral virtue then you’re constantly a good person with a minimum of effort."
        ― Jordan B. Peterson

        1 réponse Dernière réponse Répondre Citer 0
        • T
          totos51 dernière édition par

          bah c’est un GUI aussi moi enfinje pense que le code complet sera plus parlant:

          ​public class RenderGuiEvent extends Gui
          
          {
          private Minecraft mc;
          
          public RenderGuiEvent(Minecraft mc)
          {
          super();
          this.mc = mc;
          }
          
          @ForgeSubscribe(priority = EventPriority.NORMAL)
          public void onRenderHealthBar(RenderGameOverlayEvent event)
          {
          if (event.type == ElementType.HEALTH)
          {
          event.setCanceled(true);
          }    
          }
          
          @ForgeSubscribe
          public void RenderBloodBar(RenderGameOverlayEvent event)
          {
          ExtendsPropertiesPlayerBlood properties = (ExtendsPropertiesPlayerBlood) this.mc.thePlayer.getExtendedProperties(ExtendsPropertiesPlayerBlood.EXT_PRO_PLAYER_BLOOD);
          if (event.type == ElementType.FOOD && !event.isCancelable())
          {
          ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);
          int k1 = scaledresolution.getScaledWidth() / 2 - 91;
          int i2 = scaledresolution.getScaledHeight() - 39;
          int blood = properties.getBlood();
          this.drawRect(k1, i2, k1 + ((blood/1200)*81), i2 + 9, Color.RED.getRGB());
          }
          }
          }
          
          
          1 réponse Dernière réponse Répondre Citer 0
          • Gugu
            Gugu dernière édition par

            Tes props sont bien sync ?

            Essaie d’afficher un string pour voir si la valeur est changé du côté du GUI

            "If you have a comprehensive explanation for everything then it decreases uncertainty and anxiety and reduces your cognitive load. And if you can use that simplifying algorithm to put yourself on the side of moral virtue then you’re constantly a good person with a minimum of effort."
            ― Jordan B. Peterson

            1 réponse Dernière réponse Répondre Citer 0
            • T
              totos51 dernière édition par

              non elle change pas du côté du GUI mais change du coté de la prop vuq ue si la prop tombe à zéro je meurs en jeu et je fais expres de la faire descendre.

              J’ajoute le code de la prop:

              ​public class ExtendsPropertiesPlayerBlood implements IExtendedEntityProperties 
              
              {
              public final static String EXT_PRO_PLAYER_BLOOD = "ExtPropPlayerBlood";
              
              public final EntityPlayer player;
              public int blood;
              
              public ExtendsPropertiesPlayerBlood(EntityPlayer player)
              {
              this.player = player;
              this.blood = 1200;
              }
              
              public static final void register(EntityPlayer player)
              {
              player.registerExtendedProperties(ExtendsPropertiesPlayerBlood.EXT_PRO_PLAYER_BLOOD,  new ExtendsPropertiesPlayerBlood(player));
              }
              
              public static final ExtendsPropertiesPlayerBlood get(EntityPlayer player)
              {
              return (ExtendsPropertiesPlayerBlood) player.getExtendedProperties(EXT_PRO_PLAYER_BLOOD);
              }
              
              public final void sync()
              {
              ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
              DataOutputStream outputStream = new DataOutputStream(bos);
              
              try {
              outputStream.writeInt(this.blood);
              } catch (Exception ex) {
              ex.printStackTrace();
              }
              
              Packet250CustomPayload packet = new Packet250CustomPayload("Survald|Blood",
              bos.toByteArray());
              
              if (!player.worldObj.isRemote) {
              EntityPlayerMP player1 = (EntityPlayerMP) player;
              PacketDispatcher.sendPacketToPlayer(packet, (Player) player1);
              }
              }
              
              private static String getSaveKey(EntityPlayer player) 
              {
              return player.getDisplayName() + ":" + EXT_PRO_PLAYER_BLOOD;
              }
              
              public static void saveProxyData(EntityPlayer player) 
              {
              ExtendsPropertiesPlayerBlood playerData = ExtendsPropertiesPlayerBlood.get(player);
              NBTTagCompound savedData = new NBTTagCompound();
              
              playerData.saveNBTData(savedData);
              CommonProxy.storeEntityData(getSaveKey(player), savedData);
              }
              
              public static void loadProxyData(EntityPlayer player) 
              {
              ExtendsPropertiesPlayerBlood playerData = ExtendsPropertiesPlayerBlood.get(player);
              NBTTagCompound savedData = CommonProxy.getEntityData(getSaveKey(player));
              
              if (savedData != null) {
              playerData.loadNBTData(savedData);
              }
              playerData.sync();
              }
              
              @Override
              public void saveNBTData(NBTTagCompound compound) 
              {
              NBTTagCompound properties = new NBTTagCompound();
              properties.setInteger("Blood", this.blood);
              compound.setTag(EXT_PRO_PLAYER_BLOOD, properties);
              }
              
              @Override
              public void loadNBTData(NBTTagCompound compound) 
              {
              NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PRO_PLAYER_BLOOD);
              this.blood = properties.getInteger("Blood");
              }
              
              @Override
              public void init(Entity entity, World world) {
              // TODO Auto-generated method stub
              
              }
              
              public void remove(int blToDecr)
              {
              this.blood = this.blood - blToDecr;
              if (this.blood <= 0)
              {
              player.setHealth(0);
              }
              }
              
              public void add(int blToIncr)
              {
              this.blood = this.blood + blToIncr;
              if (this.blood > 1200)
              {
              this.blood = 1200;
              }
              }
              
              public int getBlood()
              {
              return this.blood;
              }
              
              
              1 réponse Dernière réponse Répondre Citer 0
              • Gugu
                Gugu dernière édition par

                Tu dois avoir du mal a synchroniser client & serveur, j’avais eu ça quand je faisait mon GUI aussi, mais je ne me souviens plus du fix.

                "If you have a comprehensive explanation for everything then it decreases uncertainty and anxiety and reduces your cognitive load. And if you can use that simplifying algorithm to put yourself on the side of moral virtue then you’re constantly a good person with a minimum of effort."
                ― Jordan B. Peterson

                1 réponse Dernière réponse Répondre Citer 0
                • T
                  totos51 dernière édition par

                  ah 😕 bah je me suis basé sur ton commit en fait x)

                  Edit: Je viens de regarder a nouveau ce même commit, ce serai pas avec le packethandler?

                  Edit 2: SOlved! donc j’avais pas le packet handler dans la main de 1, premier problème, et il me fallait des sync(); dans add et remove. ce qui me semble logique après coup… mais bon au moins j’ai trouvé, merci quand même à toi gugu 🙂

                  1 réponse Dernière réponse Répondre Citer 0
                  • 1 / 1
                  • Premier message
                    Dernier message
                  Design by Woryk
                  Contact / Mentions Légales

                  MINECRAFT FORGE FRANCE © 2018

                  Powered by NodeBB