• Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Solved RE pioche qui mine 5 par 5

    1.11.x
    1.11.x
    7
    43
    4768
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      Fury last edited by

      Bonjour je voudrait faire une pioche qui mine 5 par 5 j’ai vue le codes sur le forum mais pour la 1.7.10 via le forum.
      Mais pouvez vous m’aider s.v.p car je sais pas comment faire en 1.11.2.
      Voici ma classe actuel de ma pioche.

      
      public class Testpickaxe extends ItemPickaxe {
      public Testpickaxe(ToolMaterial diamond) {
      
         super(diamond);
         setRegistryName("Testpickaxe");
      setUnlocalizedName("Testpickaxe");
      setCreativeTab(Furymods.Pvp);
       }
      
      public static ToolMaterial toolMaterial = EnumHelper
             .addToolMaterial( "Testpickaxe", 4, 2048, 30.0f, 4.0f,64);
      
      public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase living)
      {
          if(living instanceof EntityPlayer)
          {
              for(int x1 = -2; x1 < 3; x1++)
              {
                  for(int y1 = -2; y1 < 3; y1++)
                  {
                      for(int z1 = -2; z1 < 3; z1++)
                      {
        if(world.getBlock(Event.block.posX + x1, y + y1, z + z1).getBlockHardness(world, x + x1, y + y1, z + z1) >= 0) {
                              world.getBlock(x + x1, y + y1, z + z1).harvestBlock(world, (EntityPlayer)living, x + x1, y + y1, z + z1, world.getBlockMetadata(x + x1, y + y1, z + z1));
                              world.setBlockToAir(x + x1, y + y1, z + z1);
        }
                      }
                  }
              }
          }
          return super.onBlockDestroyed(stack, world, block, x, y, z, living);
      }
      }
      ``` merci de vôtre aide
      1 Reply Last reply Reply Quote 0
      • Alexandre1156
        Alexandre1156 last edited by

        Toutes les méthodes qui utilisaient en argument trois int pour les coordonnés x, y et z ce sont vu remplacer par l’objet BlockPos (ex : setBlockToAir[size=small) ]:

        
        BlockPos pos = new BlockPos(x, y, z);
        
        

        Ensuite, pour récupérer un block, tu es obligé de passer par son BlockStates :

        
        world.getBlockState(PositionDeTonBlock).getBlock()…
        
        

        Enfin, la méthode **harvestBlock **et **onBlockDestroyed **ont des arguments différents par rapport à la 1.7. 
        Pour harvestBlock, récupère le block et met un point, tape “harvestBlock”, sélectionne la méthode, appuis sur entrée et rentre les bons arguments.
        Pour onBlockDestroyed, tape le début de “onBlockDestroyed” dans ta class puis fait Ctrl + Espace et override la méthode. Pour savoir si c’est la bonne méthode, ajoute l’annotation @override au dessus. Si Eclipse te dis rien, c’est bon. Sinon, c’est que c’est pas la bonne.

        1 Reply Last reply Reply Quote 0
        • F
          Fury last edited by

          tu veux dire comme ça

          public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase living)
          {
          if(living instanceof EntityPlayer)
          {
          for(int x1 = -2; x1 < 3; x1++)
          {
          for(int y1 = -2; y1 < 3; y1++)
          {
          for(int z1 = -2; z1 < 3; z1++)
          {
          BlockPos pos = new BlockPos(x, y, z);
          if(world.getBlockStatek(x + x1, y + y1, z + z1).getBlockHardness(world, x + x1, y + y1, z + z1) >= 0) {
          world.setBlockState(x + x1, y + y1, z + z1).harvestBlock(world, (EntityPlayer)living, x + x1, y + y1, z + z1, world.getBlockMetadata(x + x1, y + y1, z + z1));
          world.setBlockToAir(x + x1, y + y1, z + z1);
          }
          }
          }
          }
          }
          return super.onBlockDestroyed(stack, world, block, x, y, z, living);
          }
          
          ```.désoler ci je peux par être idiot mais je sais vraiment pas comment faire.ds
          1 Reply Last reply Reply Quote 0
          • robin4002
            robin4002 Moddeurs confirmés Rédacteurs Administrateurs last edited by

            BlockPos pos = new BlockPos(x + x1, y + y1, z + z1);
            Et ensuite partout où tu as x + x1, y + y1, z + z1 remplaces par pos.

            1 Reply Last reply Reply Quote 0
            • F
              Fury last edited by

              tu veux dire comme cela

              public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase living)
              {
              if(living instanceof EntityPlayer)
              {
              for(int x1 = -2; x1 < 3; x1++)
              {
              for(int y1 = -2; y1 < 3; y1++)
              {
              for(int z1 = -2; z1 < 3; z1++)
              {
              BlockPos pos = new BlockPos(x + x1, y + y1, z + z1);
              if(world.getBlock(pos.getX() + pos.getY()+ pos.getZ()).getBlockHardness(world, pos.getX() + pos.getY()+ pos.getZ()) >= 0) {
              world.getBlock(pos.getX() + pos.getY()+ pos.getZ()).harvestBlock(world, (EntityPlayer)living,pos.getX() + pos.getY()+ pos.getZ(), world.getBlockMetadata(pos.getX() + pos.getY()+ pos.getZ()));
              world.setBlockToAir(pos.getX() + pos.getY()+ pos.getZ());
              }
              }
              }
              }
              }
              return super.onBlockDestroyed(stack, world, block, x, y, z, living);
              }
              }
              
              1 Reply Last reply Reply Quote 0
              • robin4002
                robin4002 Moddeurs confirmés Rédacteurs Administrateurs last edited by

                Non …
                world.getBlockState(pos).getBlock()

                1 Reply Last reply Reply Quote 0
                • F
                  Fury last edited by

                  comme ca sais mieux.

                  public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase living)
                  {
                  if(living instanceof EntityPlayer)
                  {
                  for(int x1 = -2; x1 < 3; x1++)
                  {
                  for(int y1 = -2; y1 < 3; y1++)
                  {
                  for(int z1 = -2; z1 < 3; z1++)
                  {
                  BlockPos pos = new BlockPos(x + x1, y + y1, z + z1);
                  if(world.getBlockState(pos).getBlock().setHardness(world, x + x1, y + y1, z + z1) >= 0) {
                  world.getBlockState(pos).getBlock().harvestBlock(world, (EntityPlayer)living, x + x1, y + y1, z + z1, world.getBlockState(pos).getBlockMetadata(x + x1, y + y1, z + z1));
                  world.setBlockToAir(pos);
                  }
                  }
                  }
                  }
                  }
                  return super.onBlockDestroyed(stack, world, block, x, y, z, living);
                  }
                  }
                  
                  1 Reply Last reply Reply Quote 0
                  • robin4002
                    robin4002 Moddeurs confirmés Rédacteurs Administrateurs last edited by

                    Il y a du progrès oui, maintenant il faut encore remplacer le x + x1, y + y1, z + z1 par pos sur cette ligne :
                    world.getBlockState(pos).getBlock().harvestBlock(world, (EntityPlayer)living, x + x1, y + y1, z + z1, world.getBlockState(pos).getBlockMetadata(x + x1, y + y1, z + z1));
                    (les deux fois)

                    et adapter les arguments de la fonction onBlockDestroyed (regardes dans la classe Block.java quels sont les bons arguments).

                    1 Reply Last reply Reply Quote 0
                    • F
                      Fury last edited by

                      je sais pas ci j’ai bien trouver les arguments de la fonction onBlockDEstroyed
                      voie la mon codes

                      ublic boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase living)
                      {
                      if(living instanceof EntityPlayer)
                      {
                      for(int x1 = -2; x1 < 3; x1++)
                      {
                      for(int y1 = -2; y1 < 3; y1++)
                      {
                      for(int z1 = -2; z1 < 3; z1++)
                      {
                      BlockPos pos = new BlockPos(x + x1, y + y1, z + z1);
                      if(world.getBlockState(pos).getBlock().getBlockHardness(world, pos.getX() + pos.getY() + pos.getZ()) >= 0) {
                      world.getBlockState(pos).getBlock().harvestBlock(world, (EntityPlayer)living, pos.getX() + pos.getY() + pos.getZ(), world.getBlockState(pos).getBlockMetadata(pos.getX() + pos.getY() + pos.getZ()));
                      world.setBlockToAir(pos);
                      }
                      }
                      }
                      }
                      }
                      return super.onBlockDestroyed(stack, world, stack, pos, living);
                      }
                      }
                      
                      1 Reply Last reply Reply Quote 0
                      • Deleted
                        Deleted last edited by

                        Ajoute un @Override au dessus de la fonction, et tu t’en rendras vite compte.

                        1 Reply Last reply Reply Quote 0
                        • F
                          Fury last edited by

                          les bons arguments sais qu’il a manquer IBlockState block et ,BlockPos pos
                          il me rest que 2 erreur a corriger maintenant.

                          public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block,BlockPos pos, int x, int y, int z, EntityLivingBase living)
                          {
                          if(living instanceof EntityPlayer)
                          {
                          for(int x1 = -2; x1 < 3; x1++)
                          {
                          for(int y1 = -2; y1 < 3; y1++)
                          {
                          for(int z1 = -2; z1 < 3; z1++)
                          {
                          BlockPos pos1 = new BlockPos(x + x1, y + y1, z + z1);
                          if(world.getBlockState(pos1).getBlock().getBlockHardness(world, pos1.getX() + pos1.getY() + pos1.getZ()) >= 0) { (erreur) et ce lui dan bas
                          world.getBlockState(pos1).getBlock().harvestBlock(world, (EntityPlayer)living, pos1.getX() + pos1.getY() + pos1.getZ(), world.getBlockState(pos1).getBlockMetadata(pos1.getX() + pos1.getY() + pos1.getZ()));
                          world.setBlockToAir(pos1);
                          }
                          }
                          }
                          }
                          }
                          
                          return super.onBlockDestroyed(stack, world, block,pos, living);
                          }
                          }
                          
                          1 Reply Last reply Reply Quote 0
                          • PoulpoGaz
                            PoulpoGaz last edited by

                            Bonjour j’aimerai faire la même chose et j’ai un code qui n’a aucune erreur (enfin presque):

                            
                            package com.test.mod.items;
                            
                            import net.minecraft.block.state.IBlockState;
                            import net.minecraft.entity.EntityLivingBase;
                            import net.minecraft.entity.player.EntityPlayer;
                            import net.minecraft.item.ItemPickaxe;
                            import net.minecraft.item.ItemStack;
                            import net.minecraft.tileentity.TileEntity;
                            import net.minecraft.util.math.BlockPos;
                            import net.minecraft.world.World;
                            
                            public class Tool_with_effect extends ItemPickaxe {
                               public Tool_with_effect(ToolMaterial material) {
                                   super(material);
                                   onBlockDestroyed();     /*<–--------  L'erreur est ici*/
                               }
                            
                               public void onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, int x, int y, int z, EntityLivingBase living)
                               {
                                   if(living instanceof EntityPlayer)
                                   {
                                       for(int x1 = -2; x1 < 3; x1++)
                                       {
                                           for(int y1 = -2; y1 < 3; y1++)
                                           {
                                               for(int z1 = -2; z1 < 3; z1++)
                                               {
                                                   BlockPos pos1 = new BlockPos(x + x1, y + y1, z + z1);
                            
                                                   if(world.getBlockState(pos1).getBlock().getBlockHardness(block ,world, pos) >= 0) {
                            
                                                       world.getBlockState(pos1).getBlock().harvestBlock(world, (EntityPlayer)living, pos, world.getBlockState(pos1), TileEntity.create(world, getNBTShareTag(stack) ), stack );
                                                       world.setBlockToAir(pos1);
                            
                                                   }
                                               }
                                           }
                                       }
                                   }
                            
                                   return super.onBlockDestroyed(stack, world, block ,pos, living);
                               }
                            }
                            
                            

                            Vous allez me dire mais il faut mettre les arguments de la méthode, mais je ne sais pas quoi mettre.
                            En tout cas pour le reste Idea ne me met aucune erreur. Il y a aussi le getBlockHarness (ligne 33) qui est barré

                            Mais il se peut que dans la méthode onBlockDestroyed il y ai des trucs qui fond que ça ne mine pas en 5x5.
                            Bref, merci de votre aide.

                            Mes mods:
                            :::
                            World of Pillar
                            :::

                            [url=https://www.youtube.co…

                            1 Reply Last reply Reply Quote 0
                            • Deleted
                              Deleted last edited by

                              Salut, ça n’a aucun sens d’appeler onBlockDestroyed dans le constructeur de ton item.
                              Si j’interprète le code ici, je dirais que tu cherches à détruire un block d’un certain monde, lors de l’initialisation du jeu, tu sais cette phase où t’as le logo de Mojang et la progress bar de forge. Or je ne pense pas que c’est ce que tu recherches, hum hum ?!

                              1 Reply Last reply Reply Quote 0
                              • PoulpoGaz
                                PoulpoGaz last edited by

                                Ah non ce n’est pas ce que je recherche, mais en faite j’ai mis les trucs un peu au hasard pour avoir un truc sans erreur.
                                J’ai mis onBlockDestroyed dans le constructeur car idea me dit que la méthode ne sera jamais utilisé

                                Mes mods:
                                :::
                                World of Pillar
                                :::

                                [url=https://www.youtube.co…

                                1 Reply Last reply Reply Quote 0
                                • Deleted
                                  Deleted last edited by

                                  Justement quand on modde, on ne fait pas les choses au-hasard.
                                  La méthode onBlockDestroyed est déjà appelé de base par Minecraft, donc nullement besoin de la réappeler autre part dans ta classe.

                                  1 Reply Last reply Reply Quote 0
                                  • PoulpoGaz
                                    PoulpoGaz last edited by

                                    @‘Plaigon’:

                                    Justement quand on modde, on ne fait pas les choses au-hasard.
                                    La méthode onBlockDestroyed est déjà appelé de base par Minecraft, donc nullement besoin de la réappeler autre part dans ta classe.

                                    De toute façon ce que tu me dis ça ne m’aide pas. Et on ne dis pas on modde mais soit on code ou on programme.
                                    EDIT: J’ai fait des test. La méthode n’est jamais appelé.

                                    Mes mods:
                                    :::
                                    World of Pillar
                                    :::

                                    [url=https://www.youtube.co…

                                    1 Reply Last reply Reply Quote 0
                                    • Superloup10
                                      Superloup10 Modérateurs last edited by

                                      Bonjour, il y a plusieurs problèmes :

                                      1. La méthode que tu utilises n’existe pas.
                                      2. Jamais _ dans le nom d’une classe
                                      3. La méthode onBlockDestroyed est appelé de base par Minecraft.
                                      4. On dit que l’on modifie un programme, on ne code pas un programme déjà existant.
                                      5. Plaigon sait beaucoup plus de choses que toi. Merci de ne pas le reprendre sur des termes que tu ne comprends pas.

                                      Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

                                      Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

                                      1 Reply Last reply Reply Quote 1
                                      • robin4002
                                        robin4002 Moddeurs confirmés Rédacteurs Administrateurs last edited by

                                        Ouvres la classe Block.java puis cherches “onBlockDestroyed” tu devrais trouver la bonne fonction et les bons arguments.
                                        En 1.10.2 c’est visiblement comme ça :

                                        public void onBlockDestroyedByPlayer(World worldIn, BlockPos pos, IBlockState state)
                                        

                                        à toi de regarder comme c’est en 1.11.2 et d’adapter ton code.

                                        1 Reply Last reply Reply Quote 0
                                        • F
                                          Fury last edited by

                                          moi  j’ai changer mon codes par ce ci mais mon problème vien que il mine 1 et non par 5

                                          
                                          public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block,BlockPos pos, int x, int y, int z, EntityLivingBase living)
                                          {
                                              if(living instanceof EntityPlayer)
                                              {
                                                  for(int x1 = -2; x1 < 3; x1++)
                                                  {
                                                      for(int y1 = -2; y1 < 3; y1++)
                                                      {
                                                          for(int z1 = -2; z1 < 3; z1++)
                                                          {
                                                          BlockPos pos1 = new BlockPos(x + x1, y + y1, z + z1);
                                          
                                            if(world.getBlockState(pos1).getBlock().getBlockHardness(block ,world, pos1) >= 0) {
                                          
                                            world.getBlockState(pos1).getBlock().harvestBlock(world, (EntityPlayer)living, pos, world.getBlockState(pos1), TileEntity.create(world, getNBTShareTag(stack) ), stack );
                                            world.setBlockToAir(pos1);
                                            }
                                                          }
                                                      }
                                                  }
                                              }
                                          
                                              return super.onBlockDestroyed(stack, world, block,pos, living);
                                          }
                                          }
                                          
                                          1 Reply Last reply Reply Quote 0
                                          • PoulpoGaz
                                            PoulpoGaz last edited by robin4002

                                            Bon ok, je me suis un peu emporté, désolé.
                                            Mais la méthode onBlockDestroyedByPlayer et la méthode onBlockDestroyed ne sont pas appelé quand je casse un block:
                                            0_1537628533351_Capture.PNG
                                            0_1537628537364_Capture2.PNG
                                            Je ne comprend donc pas. Aussi dans Idea, quand une méthode est en gris c’est quelle n’est jamais appelé

                                            Pour réponder à Superloup10,
                                            1)Pourquoi ma méthode n’existe pas?
                                            2)J’ai modifié en ToolWithEffect
                                            3)Avec moi ça marche pas
                                            4)Bref, on s’en fiche
                                            5)Ok il sait plus de chose que moi mais moi je parle Français pas Anglais donc je dit code/programme, et puis le “Merci de ne pas le reprendre sur des termes que tu ne comprends pas”. Je comprend de quoi je parle quand même.

                                            Mes mods:
                                            :::
                                            World of Pillar
                                            :::

                                            [url=https://www.youtube.co…

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 1 / 3
                                            • First post
                                              Last post
                                            Design by Woryk
                                            Contact / Mentions Légales

                                            MINECRAFT FORGE FRANCE © 2018

                                            Powered by NodeBB