MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Table de craft buguée

    Planifier Épinglé Verrouillé Déplacé Résolu 1.8.x
    1.8
    19 Messages 6 Publieurs 3.1k Vues 1 Watching
    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.
    • SCAREXS Hors-ligne
      SCAREX
      dernière édition par

      Le String inutile sert à réobfusqué/déobfusqué les classes. Donc pas besoin dans tes propres classes.

      Le problème vient du fait que le clear de la table de craft se fait lorsqu’on enlève un Item du slot de résultat, Minecraft utilise un slot custom mais toi tu as ajouté des slots normaux.

      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
      • EryahE Hors-ligne
        Eryah
        dernière édition par

        Ah, et comment faire, j’aurais besoin d’éclairement,car moi et les GUI’s, sa fait 2, voir 3 peut-etre 😕
        Faut que je fasse ma propre classe de slot ?
        (Je fais tenter cela, car il y a bien Slot, et SlotCrafting  )

        Edit: Non, c’est pas ça. Bon j’ai juste fait un copier coller de la classe vanilla…
        Il faut peut-etre rajouter un truc mais je sais pas ce que c’est

        ​package net.minecraft.inventory;
        
        import net.minecraft.entity.player.EntityPlayer;
        import net.minecraft.init.Blocks;
        import net.minecraft.init.Items;
        import net.minecraft.item.Item;
        import net.minecraft.item.ItemHoe;
        import net.minecraft.item.ItemPickaxe;
        import net.minecraft.item.ItemStack;
        import net.minecraft.item.ItemSword;
        import net.minecraft.item.crafting.CraftingManager;
        import net.minecraft.stats.AchievementList;
        
        public class SlotCrafting extends Slot
        {
            /** The craft matrix inventory linked to this result slot. */
            private final InventoryCrafting craftMatrix;
            /** The player that is using the GUI where this slot resides. */
            private final EntityPlayer thePlayer;
            /** The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. */
            private int amountCrafted;
            private static final String __OBFID = "CL_00001761";
        
            public SlotCrafting(EntityPlayer player, InventoryCrafting craftingInventory, IInventory p_i45790_3_, int slotIndex, int xPosition, int yPosition)
            {
                super(p_i45790_3_, slotIndex, xPosition, yPosition);
                this.thePlayer = player;
                this.craftMatrix = craftingInventory;
            }
        
            /**
             * Check if the stack is a valid item for this slot. Always true beside for the armor slots.
             */
            public boolean isItemValid(ItemStack stack)
            {
                return false;
            }
        
            /**
             * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
             * stack.
             */
            public ItemStack decrStackSize(int amount)
            {
                if (this.getHasStack())
                {
                    this.amountCrafted += Math.min(amount, this.getStack().stackSize);
                }
        
                return super.decrStackSize(amount);
            }
        
            /**
             * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
             * internal count then calls onCrafting(item).
             */
            protected void onCrafting(ItemStack stack, int amount)
            {
                this.amountCrafted += amount;
                this.onCrafting(stack);
            }
        
            /**
             * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
             */
            protected void onCrafting(ItemStack stack)
            {
                if (this.amountCrafted > 0)
                {
                    stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted);
                }
        
                this.amountCrafted = 0;
        
                if (stack.getItem() == Item.getItemFromBlock(Blocks.crafting_table))
                {
                    this.thePlayer.triggerAchievement(AchievementList.buildWorkBench);
                }
        
                if (stack.getItem() instanceof ItemPickaxe)
                {
                    this.thePlayer.triggerAchievement(AchievementList.buildPickaxe);
                }
        
                if (stack.getItem() == Item.getItemFromBlock(Blocks.furnace))
                {
                    this.thePlayer.triggerAchievement(AchievementList.buildFurnace);
                }
        
                if (stack.getItem() instanceof ItemHoe)
                {
                    this.thePlayer.triggerAchievement(AchievementList.buildHoe);
                }
        
                if (stack.getItem() == Items.bread)
                {
                    this.thePlayer.triggerAchievement(AchievementList.makeBread);
                }
        
                if (stack.getItem() == Items.cake)
                {
                    this.thePlayer.triggerAchievement(AchievementList.bakeCake);
                }
        
                if (stack.getItem() instanceof ItemPickaxe && ((ItemPickaxe)stack.getItem()).getToolMaterial() != Item.ToolMaterial.WOOD)
                {
                    this.thePlayer.triggerAchievement(AchievementList.buildBetterPickaxe);
                }
        
                if (stack.getItem() instanceof ItemSword)
                {
                    this.thePlayer.triggerAchievement(AchievementList.buildSword);
                }
        
                if (stack.getItem() == Item.getItemFromBlock(Blocks.enchanting_table))
                {
                    this.thePlayer.triggerAchievement(AchievementList.enchantments);
                }
        
                if (stack.getItem() == Item.getItemFromBlock(Blocks.bookshelf))
                {
                    this.thePlayer.triggerAchievement(AchievementList.bookcase);
                }
        
                if (stack.getItem() == Items.golden_apple && stack.getMetadata() == 1)
                {
                    this.thePlayer.triggerAchievement(AchievementList.overpowered);
                }
            }
        
            public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack)
            {
                net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix);
                this.onCrafting(stack);
                net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn);
                ItemStack[] aitemstack = CraftingManager.getInstance().func_180303_b(this.craftMatrix, playerIn.worldObj);
                net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);
        
                for (int i = 0; i < aitemstack.length; ++i)
                {
                    ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);
                    ItemStack itemstack2 = aitemstack*;
        
                    if (itemstack1 != null)
                    {
                        this.craftMatrix.decrStackSize(i, 1);
                    }
        
                    if (itemstack2 != null)
                    {
                        if (this.craftMatrix.getStackInSlot(i) == null)
                        {
                            this.craftMatrix.setInventorySlotContents(i, itemstack2);
                        }
                        else if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2))
                        {
                            this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false);
                        }
                    }
                }
            }
        }
        

        EDIT² j’ai trouvé l’erreur mais je ne peut  pas al corriger maintenat

        Membre fantôme
        Je développe maintenant un jeu sur UnrealEngine4


        Contact :…

        1 réponse Dernière réponse Répondre Citer 0
        • EryahE Hors-ligne
          Eryah
          dernière édition par

          C’était ça, maintenant, trouvez l’erreur 😛
          ( Elle est plûtot simple a trouver, je l’ai vu en quelques secondes )
          Le premier qui trouve aura le droit à un COOKIE

          Membre fantôme
          Je développe maintenant un jeu sur UnrealEngine4


          Contact :…

          1 réponse Dernière réponse Répondre Citer 0
          • DiabolicaTrixD Hors-ligne
            DiabolicaTrix Correcteurs Moddeurs confirmés
            dernière édition par

            Enleve ça: private static final String __OBFID = “CL_00001761”; c’est pour l’obfuscation, tu n’en as pas besoin 😉

            1 réponse Dernière réponse Répondre Citer 0
            • EryahE Hors-ligne
              Eryah
              dernière édition par

              J’en ai pas besoin mais il ne gêne as, j’ai carrèment la flemme de l’enlever pour être franc 😛

              Membre fantôme
              Je développe maintenant un jeu sur UnrealEngine4


              Contact :…

              1 réponse Dernière réponse Répondre Citer 0
              • DiabolicaTrixD Hors-ligne
                DiabolicaTrix Correcteurs Moddeurs confirmés
                dernière édition par

                Haha, d’accord 😛

                1 réponse Dernière réponse Répondre Citer 0
                • EryahE Hors-ligne
                  Eryah
                  dernière édition par

                  Ah, je viens de me rendre compte que c’est pas ma classe … Fuck, désolé ^^’
                  Voici ma classe

                  package eryah.usefulthings.container;
                  
                  import net.minecraft.entity.player.EntityPlayer;
                  import net.minecraft.inventory.IInventory;
                  import net.minecraft.inventory.InventoryCrafting;
                  import net.minecraft.inventory.Slot;
                  import net.minecraft.item.ItemStack;
                  import eryah.usefulthings.recipes.WeaponTableRecipes;
                  
                  public class SlotWeaponResult extends Slot
                  {
                  /** The craft matrix inventory linked to this result slot. */
                  private final InventoryCrafting craftMatrix;
                  /** The player that is using the GUI where this slot resides. */
                  private final EntityPlayer thePlayer;
                  /** The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. */
                  private int amountCrafted;
                  
                  public SlotWeaponResult(EntityPlayer player, InventoryCrafting craftingInventory, IInventory p_i45790_3_, int slotIndex, int xPosition, int yPosition)
                  {
                  super(p_i45790_3_, slotIndex, xPosition, yPosition);
                  this.thePlayer = player;
                  this.craftMatrix = craftingInventory;
                  }
                  
                  /**
                  * Check if the stack is a valid item for this slot. Always true beside for the armor slots.
                  */
                  public boolean isItemValid(ItemStack stack)
                  {
                  return false;
                  }
                  
                  /**
                  * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
                  * stack.
                  */
                  public ItemStack decrStackSize(int amount)
                  {
                  if (this.getHasStack())
                  {
                  this.amountCrafted += Math.min(amount, this.getStack().stackSize);
                  }
                  
                  return super.decrStackSize(amount);
                  }
                  
                  /**
                  * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
                  * internal count then calls onCrafting(item).
                  */
                  protected void onCrafting(ItemStack stack, int amount)
                  {
                  this.amountCrafted += amount;
                  this.onCrafting(stack);
                  }
                  
                  /**
                  * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
                  */
                  protected void onCrafting(ItemStack stack)
                  {
                  if (this.amountCrafted > 0)
                  {
                  stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted);
                  }
                  
                  this.amountCrafted = 0;
                  
                  }
                  
                  public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack)
                  {
                  net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix);
                  this.onCrafting(stack);
                  net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn);
                  ItemStack[] aitemstack = WeaponTableRecipes.getInstance().func_180303_b(this.craftMatrix, playerIn.worldObj);
                  net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);
                  
                  for (int i = 0; i < aitemstack.length; ++i)
                  {
                  ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);
                  ItemStack itemstack2 = aitemstack*;
                  
                  if (itemstack1 != null)
                  {
                  this.craftMatrix.decrStackSize(i, 1);
                  }
                  
                  if (itemstack2 != null)
                  {
                  if (this.craftMatrix.getStackInSlot(i) == null)
                  {
                  this.craftMatrix.setInventorySlotContents(i, itemstack2);
                  }
                  else if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2))
                  {
                  this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false);
                  }
                  }
                  }
                  }
                  }
                  

                  Membre fantôme
                  Je développe maintenant un jeu sur UnrealEngine4


                  Contact :…

                  1 réponse Dernière réponse Répondre Citer 0
                  • AlgorythmisA Hors-ligne
                    Algorythmis
                    dernière édition par

                    protected void onCrafting(ItemStack stack, int amount) {
                       this.amountCrafted += amount;
                       this.onCrafting(stack);
                    }
                    

                    Tu augmentes le nombre d’items dans la case résultat sans vider la matrice de craft?

                    **EDIT : **Je suis con, amountCrafted c’est même pas le nombre d’items en résultat… si?
                    EDIT 2 :…Eryah il est con aussi, il nous donne la classe corrigée, comment il veut qu’on trouve l’erreur facepalm

                    Mes mods :

                    • Cookie Ore (1.7.10)

                    Mod en cours : **E…

                    1 réponse Dernière réponse Répondre Citer 0
                    • EryahE Hors-ligne
                      Eryah
                      dernière édition par

                      Ca pourrait être ça, mais non

                      Membre fantôme
                      Je développe maintenant un jeu sur UnrealEngine4


                      Contact :…

                      1 réponse Dernière réponse Répondre Citer 0
                      • EryahE Hors-ligne
                        Eryah
                        dernière édition par

                        J’ai mis la classe corrigée –’

                        package eryah.usefulthings.container;
                        
                        import net.minecraft.entity.player.EntityPlayer;
                        import net.minecraft.inventory.IInventory;
                        import net.minecraft.inventory.InventoryCrafting;
                        import net.minecraft.inventory.Slot;
                        import net.minecraft.item.ItemStack;
                        import eryah.usefulthings.recipes.WeaponTableRecipes;
                        
                        public class SlotWeaponResult extends Slot
                        {
                           /** The craft matrix inventory linked to this result slot. */
                           private final InventoryCrafting craftMatrix;
                           /** The player that is using the GUI where this slot resides. */
                           private final EntityPlayer thePlayer;
                           /** The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. */
                           private int amountCrafted;
                        
                           public SlotWeaponResult(EntityPlayer player, InventoryCrafting craftingInventory, IInventory p_i45790_3_, int slotIndex, int xPosition, int yPosition)
                           {
                               super(p_i45790_3_, slotIndex, xPosition, yPosition);
                               this.thePlayer = player;
                               this.craftMatrix = craftingInventory;
                           }
                        
                           /**
                            * Check if the stack is a valid item for this slot. Always true beside for the armor slots.
                            */
                           public boolean isItemValid(ItemStack stack)
                           {
                               return false;
                           }
                        
                           /**
                            * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
                            * stack.
                            */
                           public ItemStack decrStackSize(int amount)
                           {
                               if (this.getHasStack())
                               {
                                   this.amountCrafted += Math.min(amount, this.getStack().stackSize);
                               }
                        
                               return super.decrStackSize(amount);
                           }
                        
                           /**
                            * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
                            * internal count then calls onCrafting(item).
                            */
                           protected void onCrafting(ItemStack stack, int amount)
                           {
                               this.amountCrafted += amount;
                               this.onCrafting(stack);
                           }
                        
                           /**
                            * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
                            */
                           protected void onCrafting(ItemStack stack)
                           {
                               if (this.amountCrafted > 0)
                               {
                                   stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted);
                               }
                        
                               this.amountCrafted = 0;
                        
                           }
                        
                           public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack)
                           {
                               net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix);
                               this.onCrafting(stack);
                               net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn);
                               ItemStack[] aitemstack = CraftingManager.getInstance().func_180303_b(this.craftMatrix, playerIn.worldObj);
                               net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);
                        
                               for (int i = 0; i < aitemstack.length; ++i)
                               {
                                   ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);
                                   ItemStack itemstack2 = aitemstack*;
                        
                                   if (itemstack1 != null)
                                   {
                                       this.craftMatrix.decrStackSize(i, 1);
                                   }
                        
                                   if (itemstack2 != null)
                                   {
                                       if (this.craftMatrix.getStackInSlot(i) == null)
                                       {
                                           this.craftMatrix.setInventorySlotContents(i, itemstack2);
                                       }
                                       else if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2))
                                       {
                                           this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false);
                                       }
                                   }
                               }
                           }
                        }
                        

                        Membre fantôme
                        Je développe maintenant un jeu sur UnrealEngine4


                        Contact :…

                        1 réponse Dernière réponse Répondre Citer 0
                        • AlgorythmisA Hors-ligne
                          Algorythmis
                          dernière édition par

                          Code erroné :

                          ItemStack[] aitemstack = CraftingManager.getInstance().func_180303_b(this.craftMatrix, playerIn.worldObj);
                          

                          Code corrigé :

                          ItemStack[] aitemstack = WeaponTableRecipes.getInstance().func_180303_b(this.craftMatrix, playerIn.worldObj);
                          

                          :::
                          Trouvé avec ceci x)
                          :::

                          Mes mods :

                          • Cookie Ore (1.7.10)

                          Mod en cours : **E…

                          1 réponse Dernière réponse Répondre Citer 0
                          • DiabolicaTrixD Hors-ligne
                            DiabolicaTrix Correcteurs Moddeurs confirmés
                            dernière édition par

                            Je l’ai dit avant 😛

                            1 réponse Dernière réponse Répondre Citer 0
                            • AlgorythmisA Hors-ligne
                              Algorythmis
                              dernière édition par

                              Mais pas sur ce topic 😛

                              Mes mods :

                              • Cookie Ore (1.7.10)

                              Mod en cours : **E…

                              1 réponse Dernière réponse Répondre Citer 0
                              • w67clementW Hors-ligne
                                w67clement
                                dernière édition par

                                Arghhh je venais de voir le même truc x( mais Sasukz, tu fus plus rapide…

                                1 réponse Dernière réponse Répondre Citer 0
                                • EryahE Hors-ligne
                                  Eryah
                                  dernière édition par

                                  Vous avez gagnés un cookie 🙂
                                  GG a vous deux

                                  Membre fantôme
                                  Je développe maintenant un jeu sur UnrealEngine4


                                  Contact :…

                                  1 réponse Dernière réponse Répondre Citer 0
                                  • DiabolicaTrixD Hors-ligne
                                    DiabolicaTrix Correcteurs Moddeurs confirmés
                                    dernière édition par

                                    C’était easy avec Winmerge 😛

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

                                    MINECRAFT FORGE FRANCE © 2024

                                    Powered by NodeBB