MFF

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

    Gen chest + random loot

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    21 Messages 3 Publieurs 4.0k 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.
    • AymericRedA Hors-ligne
      AymericRed
      dernière édition par

      Juste après avoir placé le coffre, tu récupères le tileentity et tu l’appelles

      Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

      AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

      Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
      Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

      1 réponse Dernière réponse Répondre Citer 0
      • SpyManS Hors-ligne
        SpyMan
        dernière édition par robin4002

        Ok mais là je met quoi ?
        je ne peut pas mettre d’itemstack

        /* –--------------------------- Chest Loot ----------------------------- */
        
           //* Chest Gen *//
            *world*.setBlock(x+1, y+1, z+7, Blocks.chest);
            *world*.setBlockMetadataWithNotify(x+1, y+1, z+7, 5, 5);
            //* Chest Gen Loot *//
            ItemStack[] chestLootList = new ItemStack[]
           {
                   new ItemStack(MechanicalCraft.ironGear,1 ,0),
                    new ItemStack(MechanicalCraft.hammer,1 ,0),
                    new ItemStack(MechanicalCraft.wrench,1 ,0),
                    new ItemStack(MechanicalCraft.pliers,1 ,0),
                    new ItemStack(MechanicalCraft.copperIngot,1 ,0),
                    new ItemStack(MechanicalCraft.bronzePickaxe,1 ,0),
                    new ItemStack(MechanicalCraft.ironPlate, 1, 0)
           };
        
           Random rand = new Random();
            WeightedRandomChestContent.generateChestContents(rand, /* ICI je ne sais quoi mettre */, (IInventory)world.getTileEntity(x+1,y+1, z+7), 3);
        
        1 réponse Dernière réponse Répondre Citer 0
        • robin4002R Hors-ligne
          robin4002 Moddeurs confirmés Rédacteurs Administrateurs
          dernière édition par robin4002

          La signature de la fonction c’est ça :
             public static void generateChestContents(Random random, List<WeightedRandomChestContent> listIn, IInventory inv, int max)

          Donc il faut une liste de WeightedRandomChestContent.

          List<WeightedRandomChestContent>chestLootList = Lists.newArrayList<WeightedRandomChestContent>();
          chestLootList.add(new WeightedRandomChestContent(MechanicalCraft.ironGear, 0, chanceMini, chanceMaxi); // le 0 c'est le metadata, la quantité est toujours 1, pour avoir plus il faut ajouter avec  la chance
          chestLootList.add(new WeightedRandomChestContent(MechanicalCraft.hammer, 0, chanceMini, chanceMaxi);
          etc …
          WeightedRandomChestContent.generateChestContents(world.rand, chestLootList, ((IInventory)world.getTileEntity(x+1, y+1, z+7)), 3);
          
          1 réponse Dernière réponse Répondre Citer 0
          • SpyManS Hors-ligne
            SpyMan
            dernière édition par

            J’ai une erreur “Method call expected”
            a cette ligne
            chestLootList.add(WeightedRandomChestContent(MechanicalCraft.ironGear, 0, 30, 80);

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

              Oups, j’ai oublié le new devant WeightedRandomChestContent

              1 réponse Dernière réponse Répondre Citer 0
              • SpyManS Hors-ligne
                SpyMan
                dernière édition par robin4002

                chestLootList.add(new WeightedRandomChestContent(new ItemStack(MechanicalCraft.ironGear), 0, 30, 80);
                

                Comme cela ?

                WeightedRandomChestContent.generateChestContents(world.rand, chestLootList, (Inventory)world.getTileEntity(x + 1, y + 1, z + 7), 3);
                

                Il n’aime pas non plus le “chestLootList” dans l’appel de la fonction

                EDIT: j’ai trouvé Chest loot list doit etre un tableau et pas une list 🙂

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

                  Mon crash quand je fait spawn le structure

                  Structure

                  [font=Courier New/* –--------------------------- Chest Loot ----------------------------- */
                  ]
                  %(#ff9205)[//* Chest Gen *//
                  ]*world*.setBlock(*x*+1, *y*+1, *z*+7, Blocks.chest)%(#aaa9a7)[;
                  ]*world*.setBlockMetadataWithNotify(*x*+1, *y*+1, *z*+7, 5, 5)%(#aaa9a7)[;
                  ]%(#ff9205)[//* Chest Gen Loot *//
                  ]WeightedRandomChestContent[] chestLootList = new WeightedRandomChestContent[]
                  {
                     new WeightedRandomChestContent(new ItemStack(MechanicalCraft.ironGear, 1, 0), 30, 80, 0)%(#aaa9a7)[,
                  ]    new WeightedRandomChestContent(new ItemStack(MechanicalCraft.hammer, 1, 0), 30, 80, 0)%(#aaa9a7)[,
                  ]    new WeightedRandomChestContent(new ItemStack(MechanicalCraft.wrench, 1, 0), 30, 80, 0)%(#aaa9a7)[,
                  ]    new WeightedRandomChestContent(new ItemStack(MechanicalCraft.pliers, 1, 0), 30, 80, 0)%(#aaa9a7)[,
                  ]    new WeightedRandomChestContent(new ItemStack(MechanicalCraft.ironPlate, 1, 0), 30, 80, 0)%(#aaa9a7)[,
                  ]    new WeightedRandomChestContent(new ItemStack(MechanicalCraft.bronzePickaxe, 1, 0), 30, 80, 0)
                  }%(#aaa9a7)[;
                  ]%(#345f99).generateChestContents(*world*.rand, chestLootList, ((IInventory)*world*.getTileEntity(*x*+1, *y*+1, *z*+7)), 3);
                  

                  Crash log

                  [12:23:22] [Client thread/FATAL]: Unreported exception thrown!
                  java.lang.IllegalArgumentException
                  at net.minecraft.util.WeightedRandom.getRandomItem(WeightedRandom.java:100) ~[WeightedRandom.class:?]
                  at net.minecraft.util.WeightedRandom.getRandomItem(WeightedRandom.java:137) ~[WeightedRandom.class:?]
                  at net.minecraft.util.WeightedRandomChestContent.generateChestContents(WeightedRandomChestContent.java:43) ~[WeightedRandomChestContent.class:?]
                  at com.google.SpyMan.Mechanicalcraft.common.world.FactoryGen.spawn(FactoryGen.java:1720) ~[FactoryGen.class:?]
                  at com.google.SpyMan.Mechanicalcraft.common.itemsTools.StructSpawnItem.onItemRightClick(StructSpawnItem.java:28) ~[StructSpawnItem.class:?]
                  at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) ~[ItemStack.class:?]
                  at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:430) ~[PlayerControllerMP.class:?]
                  at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1557) ~[Minecraft.class:?]
                  at net.minecraft.client.Minecraft.runTick(Minecraft.java:2044) ~[Minecraft.class:?]
                  at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) ~[Minecraft.class:?]
                  at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?]
                  at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_66]
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_66]
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_66]
                  at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_66]
                  at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
                  at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
                  at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
                  at GradleStart.main(Unknown Source) [start/:?]
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_66]
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_66]
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_66]
                  at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_66]
                  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:?]
                  [12:23:22] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ----
                  // But it works on my machine.
                  
                  Time: 19/03/16 12:23
                  Description: Unexpected error
                  
                  java.lang.IllegalArgumentException
                  at net.minecraft.util.WeightedRandom.getRandomItem(WeightedRandom.java:100)
                  at net.minecraft.util.WeightedRandom.getRandomItem(WeightedRandom.java:137)
                  at net.minecraft.util.WeightedRandomChestContent.generateChestContents(WeightedRandomChestContent.java:43)
                  at com.google.SpyMan.Mechanicalcraft.common.world.FactoryGen.spawn(FactoryGen.java:1720)
                  at com.google.SpyMan.Mechanicalcraft.common.itemsTools.StructSpawnItem.onItemRightClick(StructSpawnItem.java:28)
                  at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164)
                  at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:430)
                  at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1557)
                  at net.minecraft.client.Minecraft.runTick(Minecraft.java:2044)
                  at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039)
                  at net.minecraft.client.Minecraft.run(Minecraft.java:962)
                  at net.minecraft.client.main.Main.main(Main.java:164)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                  at java.lang.reflect.Method.invoke(Method.java:497)
                  at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
                  at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
                  at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
                  at GradleStart.main(Unknown Source)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                  at java.lang.reflect.Method.invoke(Method.java:497)
                  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
                  
                  
                  1 réponse Dernière réponse Répondre Citer 0
                  • AymericRedA Hors-ligne
                    AymericRed
                    dernière édition par

                    T’es sur qu’il a accepté en tableau ? Bon après je suis en 1.8
                    Et le seul IllegalArgumentExcpetion qui peut arriver c’est si la liste est trop petite

                    Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                    AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                    Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                    Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

                      Je ne sais point, mais je sais que si je lui donne un list il veut pas

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

                        Le dernier argument de WeightedRandomChestContent ne peut pas être nul ou inférieur à 0.
                        Il représente le poids, plus ce nombre sera élevé plus la probabilité sera élevé. (le code que je t’avais donné avant était du code 1.8.9 et non 1.7.10 d’où le problème).

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

                          Dans mon cas il est a 3 mais le jeu crash tout de même

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

                            Je parle du constructeur de WeightedRandomChestContent, pas de la fonction generateChestContents.
                            Tu as bien mit 0 dans ce dernier :
                            @‘SpyMan’:

                            WeightedRandomChestContent[] chestLootList = new WeightedRandomChestContent[]
                            {
                            new WeightedRandomChestContent(new ItemStack(MechanicalCraft.ironGear, 1, 0), 30, 80, 0), // 0
                            new WeightedRandomChestContent(new ItemStack(MechanicalCraft.hammer, 1, 0), 30, 80, 0), // 0 aussi
                            new WeightedRandomChestContent(new ItemStack(MechanicalCraft.wrench, 1, 0), 30, 80, 0), // encore 0
                            new WeightedRandomChestContent(new ItemStack(MechanicalCraft.pliers, 1, 0), 30, 80, 0), // etc …
                            new WeightedRandomChestContent(new ItemStack(MechanicalCraft.ironPlate, 1, 0), 30, 80, 0),
                            new WeightedRandomChestContent(new ItemStack(MechanicalCraft.bronzePickaxe, 1, 0), 30, 80, 0)
                            };
                            
                            1 réponse Dernière réponse Répondre Citer 0
                            • SpyManS Hors-ligne
                              SpyMan
                              dernière édition par

                              Oui pourtant

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

                                Justement, il faut pas que ce soit 0

                                Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                                AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                                Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                                Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

                                1 réponse Dernière réponse Répondre Citer 0
                                • SpyManS Hors-ligne
                                  SpyMan
                                  dernière édition par robin4002

                                  Le jeu ne crash plus mais la gen dans les coffre est tout de même bizarre

                                  /* –--------------------------- Chest Loot ----------------------------- */
                                  //* Chest Gen *//
                                  world.setBlock(x+1, y+1, z+7, Blocks.chest);
                                  world.setBlockMetadataWithNotify(x+1, y+1, z+7, 5, 5);
                                  
                                  //* Chest Gen Loot *//
                                      WeightedRandomChestContent[] chestLootList = new WeightedRandomChestContent[]
                                     {
                                         new WeightedRandomChestContent(new ItemStack(MechanicalCraft.ironGear, 1, 0), 10, 80, 1),
                                          new WeightedRandomChestContent(new ItemStack(MechanicalCraft.hammer, 1, 0), 10, 50, 1)
                                          new WeightedRandomChestContent(new ItemStack(MechanicalCraft.wrench, 1, 0), 10, 50, 1),
                                          new WeightedRandomChestContent(new ItemStack(MechanicalCraft.pliers, 1, 0), 10, 50, 1),
                                          new WeightedRandomChestContent(new ItemStack(MechanicalCraft.ironPlate, 1, 0), 10, 80, 1),
                                          new WeightedRandomChestContent(new ItemStack(MechanicalCraft.bronzePickaxe, 1, 0), 10, 50, 1)
                                     };
                                  ]    WeightedRandomChestContent.generateChestContents(world.rand, chestLootList, ((IInventory)world.getTileEntity(x+1, y+1, z+7)), 6);
                                  }
                                  
                                  1 réponse Dernière réponse Répondre Citer 0
                                  • AymericRedA Hors-ligne
                                    AymericRed
                                    dernière édition par

                                    Met des nombres min et Max d’item moins élevés

                                    Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                                    AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                                    Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                                    Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

                                      Avec 10 en minimum et 50 voire 80 en max le résultat n’a rien d’étonnant x)

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

                                        OK merci, j’avais pas saisi que c’etait un nombre min et max d’items

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

                                        MINECRAFT FORGE FRANCE © 2024

                                        Powered by NodeBB