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

    Résolu Rendu familier dans inventaire

    1.7.x
    1.7.10
    5
    25
    5763
    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.
    • D
      Degraduck dernière édition par

      Donc voilà j’ai un inventaire custom, j’ai créé un familier et j’aimerai qu’il soit rendu dans mon inventaire sauf que je n’y arrive pas.
      Mes classes:

      public class MinefusContainerPlayer extends Container {
      
      private final EntityPlayer thePlayer;
      
         public MinefusContainerPlayer(EntityPlayer player, InventoryPlayer inventoryPlayer, MinefusInventoryPlayer inventoryMinefus)
         {
         this.thePlayer = player;
         this.bindMinefusInventory(inventoryMinefus);
         this.bindPlayerInventory(inventoryPlayer);
         this.bindArmorInventory(inventoryPlayer);
         }
      
         private void bindPlayerInventory(InventoryPlayer inventoryPlayer)
         {
         int i;
         for(i = 0; i < 9; i++)
         {
         this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 161 + 33));
         }
      
         //Barres Inventaires
                 int j;
         for (i = 0; i < 3; ++i)
                 {
                     for (j = 0; j < 9; ++j)
                     {
                         this.addSlotToContainer(new Slot(inventoryPlayer, j + (i + 1) * 9, 8 + j * 18, 136 + i * 18));
                     }
                 }
         }
      
         private void bindMinefusInventory(MinefusInventoryPlayer inventoryMinefus){
      
         //1ere Barre Slots
         this.addSlotToContainer(new Slot(inventoryMinefus, 0, 0, 119));
         this.addSlotToContainer(new Slot(inventoryMinefus, 1, 8, 119));
         this.addSlotToContainer(new Slot(inventoryMinefus, 2, 26, 119));
         this.addSlotToContainer(new Slot(inventoryMinefus, 3, 44, 119));
         this.addSlotToContainer(new Slot(inventoryMinefus, 4, 62, 119));
         this.addSlotToContainer(new Slot(inventoryMinefus, 5, 80, 119));
         this.addSlotToContainer(new Slot(inventoryMinefus, 6, 98, 119));
         this.addSlotToContainer(new Slot(inventoryMinefus, 7, 116, 119));
         this.addSlotToContainer(new Slot(inventoryMinefus, 8, 134, 119));
         this.addSlotToContainer(new Slot(inventoryMinefus, 9, 152, 119));
      
         //Minefus Slots
         this.addSlotToContainer(new SlotMinefus(inventoryMinefus, 10, 8, 8));
         this.addSlotToContainer(new SlotMinefus(inventoryMinefus, 11, 8, 26));
         this.addSlotToContainer(new SlotMinefus(inventoryMinefus, 12, 8, 44));
         this.addSlotToContainer(new SlotMinefus(inventoryMinefus, 13, 8, 62));
         this.addSlotToContainer(new SlotMinefus(inventoryMinefus, 14, 8, 80));
         this.addSlotToContainer(new SlotMinefus(inventoryMinefus, 15, 8, 98));
      
         //ArmorSlots
         this.addSlotToContainer(new SlotAnneau(inventoryMinefus, 16, 28, 43));
         this.addSlotToContainer(new SlotAnneau(inventoryMinefus, 17, 118, 43));
         this.addSlotToContainer(new SlotMinefus(inventoryMinefus, 18, 28, 25));
         this.addSlotToContainer(new SlotAmulette(inventoryMinefus, 19, 28, 7));                
         this.addSlotToContainer(new SlotFamilier(inventoryMinefus, 20, 118, 79));
      
         }
      
         private void bindArmorInventory(InventoryPlayer inventoryPlayer){
         this.addSlotToContainer(new SlotArmor(thePlayer, inventoryPlayer, inventoryPlayer.getSizeInventory() - 1, 118, 7, 0)); //coiffe
         this.addSlotToContainer(new SlotArmor(thePlayer, inventoryPlayer, inventoryPlayer.getSizeInventory() - 2, 118, 25, 1)); //cape
         this.addSlotToContainer(new SlotArmor(thePlayer, inventoryPlayer, inventoryPlayer.getSizeInventory() - 3, 28, 61, 2)); // ceinture
         this.addSlotToContainer(new SlotArmor(thePlayer, inventoryPlayer, inventoryPlayer.getSizeInventory() - 4, 28, 79, 3)); //botte
      
         }
      
         /**
         * This should always return true, since custom inventory can be accessed from anywhere
         */
         @Override
         public boolean canInteractWith(EntityPlayer player)
         {
         return true;
         }
      
         /**
         * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
         * Basically the same as every other container I make, since I define the same constant indices for all of them
         */
         @Override
         public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
         {
         ItemStack itemstack = null;
         Slot slot = (Slot)this.inventorySlots.get(slotId);
      
         if(slot != null && slot.getHasStack())
         {
         ItemStack itemstack1 = slot.getStack();
         itemstack = itemstack1.copy();
      
         if(slotId < 0){
          if(!this.mergeItemStack(itemstack1, 0, this.inventorySlots.size(), true))
          {
          return null;
          }
         }
         else if(!this.mergeItemStack(itemstack1, 0, 0, false))
         {
          return null;
         }
         else if(slotId == 9 && slotId != 0)
         {
          if(!this.mergeItemStack(itemstack1, 0, 9, true)){
          return null;
             }
      
         }
         if(itemstack1.stackSize == 0)
         {
          slot.putStack((ItemStack)null);
         }
         else
         {
          slot.onSlotChanged();
         }
         }
         return itemstack;
         }
      
      }
      
      public class PetBilby extends Item {
      
      public boolean getIsRepairable(ItemStack input, ItemStack repair)
      {
      return false;
      }
      
      @Override
      public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
      {
      
      if(slot == 20)
      {
      return ModStuff.MODID+ ":textures/models/armor/pet_bilby.png";
      }
      
      return ModStuff.MODID+ ":textures/models/armor/stuff_empty.png";
      
      }
      
      @Override
      @SideOnly(Side.CLIENT)
      public ModelBiped getArmorModel(EntityLivingBase entityliving, ItemStack stack, int armor)
      {
      
      if(stack.getItem() == ModStuff.PetBilby)
      {
      return new ModelPetBilby(armor);
      }
      return null;
      }
      
      public void onArmorTick(World world, EntityPlayer player, ItemStack stack)
      {
      //
      }
      
      public void addInformation(ItemStack stack, EntityPlayer player, List par3List, boolean par4)
      {
      
      par3List.add("Bilby, ou Bilbiblabalou de son vrai nom,");
      par3List.add("est une petite gelee en quete d'aventure.");
      
      super.addInformation(stack, player, par3List, par4);
      }
      ]
      
      public class GUIMinefusInventoryPlayer extends GuiContainer {
      
      /** x size of the inventory window in pixels. Defined as float, passed as int */
      private float xSize_lo;
      
      /** y size of the inventory window in pixels. Defined as float, passed as int. */
      private float ySize_lo;
      
      /** Normally I use '(ModInfo.MOD_ID, "textures/…")', but it can be done this way as well */
      private static final ResourceLocation iconLocation = new ResourceLocation(ModStuff.MODID +":textures/gui/minefus_inventory.png");
      
      /** Could use IInventory type to be more generic, but this way will save an import... */
      private final MinefusInventoryPlayer inventory;
      
      public GUIMinefusInventoryPlayer(EntityPlayer player, InventoryPlayer inventoryPlayer, MinefusInventoryPlayer inventoryCustom)
      {
      super(new MinefusContainerPlayer(player, inventoryPlayer, inventoryCustom));
      this.inventory = inventoryCustom;
      this.ySize = this.ySize+52;
      // if you need the player for something later on, store it in a local variable here as well
      }
      
      /**
      * Draws the screen and all the components in it.
      */
      public void drawScreen(int par1, int par2, float par3)
      {
      super.drawScreen(par1, par2, par3);
      this.xSize_lo = (float)par1;
      this.ySize_lo = (float)par2;
      }
      
      /**
      * Draw the foreground layer for the GuiContainer (everything in front of the items)
      */
      protected void drawGuiContainerForegroundLayer(int par1, int par2)
      {
      // This method will simply draw inventory names on the screen - you could do without it entirely
      // if that's not important to you, since we are overriding the default inventory rather than
      // creating a specific type of inventory
      
      String s = this.inventory.hasCustomInventoryName() ? this.inventory.getInventoryName() : I18n.format(this.inventory.getInventoryName());
      this.fontRendererObj.drawString(s, 122 - this.fontRendererObj.getStringWidth(s), 105, 4210752);
      }
      /**
      * Draw the background layer for the GuiContainer (everything behind the items)
      */
      protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
      {
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      this.mc.getTextureManager().bindTexture(iconLocation);
      int k = (this.width - this.xSize) / 2;
      int l = (this.height - this.ySize) / 2;
      this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
      int i1;
      drawPlayerModel(k + 80, l + 90, 40, (float)(k + 51) - this.xSize_lo, (float)(l + 75 - 50) - this.ySize_lo, this.mc.thePlayer);
      }
      
      /**
      * This renders the player model in standard inventory position;
      * copied straight from vanilla code but with renamed method parameters
      */
      public static void drawPlayerModel(int x, int y, int scale, float yaw, float pitch, EntityLivingBase entity) {
      
      ExtendedPlayer ext = ExtendedPlayer.get((EntityPlayer)entity);
       ItemStack pet = ext.inventory.getStackInSlot(20);
      
      GL11.glEnable(GL11.GL_COLOR_MATERIAL);
      GL11.glPushMatrix();
      GL11.glTranslatef(x, y, 50.0F);
      
      if(pet != null && pet.getItem() == ModStuff.PetBilby)
      {
      GL11.glScalef(-scale*0.8F, scale*0.8F, scale*0.8F);
      }
      else if(pet != null && pet.getItem() == ModStuff.PetCroum)
      {
      GL11.glScalef(-scale*0.8F, scale*0.8F, scale*0.8F);
      }
      else
      {
      GL11.glScalef(-scale, scale, scale);
      }
      
      GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
      float f2 = entity.renderYawOffset;
      float f3 = entity.rotationYaw;
      float f4 = entity.rotationPitch;
      float f5 = entity.prevRotationYawHead;
      float f6 = entity.rotationYawHead;
      
      GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F);
      RenderHelper.enableStandardItemLighting();
      GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
      GL11.glRotatef(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F);
      entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F;
      entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F;
      entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F;
      entity.rotationYawHead = entity.rotationYaw;
      entity.prevRotationYawHead = entity.rotationYaw;
      GL11.glTranslatef(0.0F, entity.yOffset, 0.0F);
      RenderManager.instance.playerViewY = 180.0F;
      RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
      entity.renderYawOffset = f2;
      entity.rotationYaw = f3;
      entity.rotationPitch = f4;
      entity.prevRotationYawHead = f5;
      entity.rotationYawHead = f6;
      GL11.glPopMatrix();
      RenderHelper.disableStandardItemLighting();
      GL11.glDisable(GL12.GL_RESCALE_NORMAL);
      OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
      GL11.glDisable(GL11.GL_TEXTURE_2D);
      OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
      
      }
      
      }
      
      1 réponse Dernière réponse Répondre Citer 0
      • Gugu
        Gugu dernière édition par

        Tu veux le render comment ? Sous forme d’item, ou de créature ? Car la, tu semble pas appeler de méthode pour render ton familier

        "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
        • D
          Degraduck dernière édition par

          En familier en faite je voudrais rendre mon modèle et ma texture

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

            Up, j’arrive toujours pas?

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

              Vous allez peut être me prendre pour un inculte, mais c’est quoi un familier ?

              Site web contenant mes scripts : http://SCAREXgaming.github.io

              Pas de demandes de support par MP ni par skype SVP.
              Je n'accepte sur skype que l…

              1 réponse Dernière réponse Répondre Citer 0
              • robin4002
                robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par

                http://fr.wiktionary.org/wiki/familier

                Qui est considéré comme appartenant à la famille.

                • Aucun animal familier n’est autorisé dans l’avion.

                = animal de compagnie.
                Je ne savais pas non plus avant que Kévin me le dise, dans certaines régions c’est très utilisé, dans d’autres non. (En tout cas en Alsace ce n’est pas utilisé)

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

                  Mets un System.out.println(“quelque chose”) ou utilise un logger dans ta fonction drawPlayerModel pour voir si elle est bien appelée (attention aux spams)

                  Site web contenant mes scripts : http://SCAREXgaming.github.io

                  Pas de demandes de support par MP ni par skype SVP.
                  Je n'accepte sur skype que l…

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

                    Oui oui elle est bien appelé, car quand je méttais mon familier dans le slot 3, donc celui des bottes cela fonctionnai à merveille, sauf que j’ai créé un invertaire custom avec un slot réservé aux familiers, du coup je ne vois pas comment faire, par quoi remplacer le 3 j’ai essayé avec 20 vu que c’est l’ ID de mon slot sauf que cela ne fonctionne pas car cest un slot custom voilà où est mon soucis.

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

                      @Override
                      public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
                      {
                      if(slot == 20)
                      {
                      return ModStuff.MODID+ ":textures/models/armor/pet_bilby.png";
                      }
                      return ModStuff.MODID+ ":textures/models/armor/stuff_empty.png";
                      }
                      

                      La tu check si c’est le slot 20 de l’inventaire de base, tu dois aller chercher ton inventaire custom:

                      @Override
                      
                      public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
                      {
                      
                      ExtendedPlayer ext = ExtendedPlayer.get((EntityPlayer)entity);
                      if(ext.inventory.getStackInSlot(20) != null && ext.inventory.getStackInSlot(20) == ModDofus.petBilby)
                      {
                      return ModStuff.MODID+ ":textures/models/armor/pet_bilby.png";
                      }
                      return ModStuff.MODID+ ":textures/models/armor/stuff_empty.png";
                      }
                      

                      Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

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

                        D’accord et bien je verrais ce soir car la je suis en cours.

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

                          Toujours pas trouvé.

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

                            Dans le drawPlayerModel, regarde si ton item est null.

                            Site web contenant mes scripts : http://SCAREXgaming.github.io

                            Pas de demandes de support par MP ni par skype SVP.
                            Je n'accepte sur skype que l…

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

                              Il n’est pas null.

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

                                Regarde dans les rotations/translations voir si ton model n’est pas rendu en dehors de l’écran

                                Site web contenant mes scripts : http://SCAREXgaming.github.io

                                Pas de demandes de support par MP ni par skype SVP.
                                Je n'accepte sur skype que l…

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

                                  Non il n’est pas rendu du tout ^^

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

                                    Pourtant tu dis que ta méthode est appelée et que ton Item n’est pas null, donc il est forcément rendu.

                                    Site web contenant mes scripts : http://SCAREXgaming.github.io

                                    Pas de demandes de support par MP ni par skype SVP.
                                    Je n'accepte sur skype que l…

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

                                      Si tu veux essayé je peux te poster mes src

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

                                        Je veux bien essayer de débuguer

                                        Site web contenant mes scripts : http://SCAREXgaming.github.io

                                        Pas de demandes de support par MP ni par skype SVP.
                                        Je n'accepte sur skype que l…

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

                                          Je t’envois le lien en privé.

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

                                            Ton code fait exactement ce qui lui ai demandé, c’est-à-dire faire le rendu du joueur et si le joueur possède dans son inventaire l’une de tes entités, le joueur est rendu plus petit, je ne comprends pas l’utilité mais ton code fonctionne.

                                            Site web contenant mes scripts : http://SCAREXgaming.github.io

                                            Pas de demandes de support par MP ni par skype SVP.
                                            Je n'accepte sur skype que l…

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

                                            MINECRAFT FORGE FRANCE © 2018

                                            Powered by NodeBB