Navigation

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

    Hammer 3x3 HELP

    Sans suite
    1.7.10
    9
    15
    3394
    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.
    • AzTick_
      AzTick_ last edited by

      Bonjour,
      J’ai trouver la méthode pour miner en 5x5 mais je n’arrive pas a la mettre en 3x3

          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(x + x1, y + y1, z + z1).getBlockHardness(world, z1, z1, z1) >= 0.0F)
                              {
      
                              }
                              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);
          }
      

      Cordialament, FanatikForce

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

        Salut,
        Il suffit de remplacer les -2 en -1 et les 3 en 2 dans les trois boucle for.

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

          @‘robin4002’:

          Salut,
          Il suffit de remplacer les -2 en -1 et les 3 en 2 dans les trois boucle for.

          Mais sa marche sur les murs ?

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

            Pourquoi pas ?

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

              Faudrait vraiment un tutoriel la dessus xD C’est de plus en plus demander

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

                @‘moscaphone421’:

                Faudrait vraiment un tutoriel la dessus xD C’est de plus en plus demander

                Comment je fais pour creuser que de 1 de profondeur car la sa mine de 2 de profondeur ?

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

                  @‘robin4002’:

                  Salut,
                  Il suffit de remplacer les -2 en -1 et les 3 en 2 dans les trois boucle for.

                  Comment je fais pour creuser que de 1 de profondeur car la sa mine de 2 de profondeur ?

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

                    Tu veux du 3x3x3 ou du 3x3x1 ?
                    Car si c’est du 3x3x1, il faut adapter en fonction du côté que le joueur touche.

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

                      @‘robin4002’:

                      Tu veux du 3x3x3 ou du 3x3x1 ?
                      Car si c’est du 3x3x1, il faut adapter en fonction du côté que le joueur touche.

                      J’aimerai du 3x3x1

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

                        package fr.minecraftforgefrance.test;
                        
                        import net.minecraft.block.Block;
                        import net.minecraft.entity.EntityLivingBase;
                        import net.minecraft.entity.player.EntityPlayer;
                        import net.minecraft.item.ItemPickaxe;
                        import net.minecraft.item.ItemStack;
                        import net.minecraft.util.MathHelper;
                        import net.minecraft.world.World;
                        
                        public class ItemTestPickaxe extends ItemPickaxe
                        {
                        protected ItemTestPickaxe(ToolMaterial material)
                        {
                        super(material);
                        }
                        
                        public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase living)
                        {
                        if(living instanceof EntityPlayer && !world.isRemote)
                        {
                        switch(determineOrientation(world, x, y, z, living))
                        {
                        case 0:
                        for(int x1 = -1; x1 < 2; x1++)
                        {
                        for(int z1 = -1; z1 < 2; z1++)
                        {
                        if(world.getBlock(x + x1, y, z + z1).getBlockHardness(world, x1, y, z1) >= 0.0F)
                        {
                        world.getBlock(x + x1, y, z + z1).harvestBlock(world, (EntityPlayer)living, x + x1, y, z + z1, world.getBlockMetadata(x + x1, y, z + z1));
                        world.setBlockToAir(x + x1, y, z + z1);
                        }
                        }
                        }
                        break;
                        case 1:
                        for(int y1 = -1; y1 < 2; y1++)
                        {
                        for(int z1 = -1; z1 < 2; z1++)
                        {
                        if(world.getBlock(x, y + y1, z + z1).getBlockHardness(world, x, y1, z1) >= 0.0F)
                        {
                        world.getBlock(x, y + y1, z + z1).harvestBlock(world, (EntityPlayer)living, x, y + y1, z + z1, world.getBlockMetadata(x, y + y1, z + z1));
                        world.setBlockToAir(x, y + y1, z + z1);
                        }
                        }
                        }
                        break;
                        case 2:
                        for(int x1 = -1; x1 < 2; x1++)
                        {
                        for(int y1 = -1; y1 < 2; y1++)
                        {
                        if(world.getBlock(x + x1, y + y1, z).getBlockHardness(world, x1, y1, z) >= 0.0F)
                        {
                        world.getBlock(x + x1, y + y1, z).harvestBlock(world, (EntityPlayer)living, x + x1, y + y1, z, world.getBlockMetadata(x + x1, y + y1, z));
                        world.setBlockToAir(x + x1, y + y1, z);
                        }
                        }
                        }
                        break;
                        }
                        }
                        return super.onBlockDestroyed(stack, world, block, x, y, z, living);
                        }
                        
                        public int determineOrientation(World world, int x, int y, int z, EntityLivingBase living)
                        {
                        if(MathHelper.abs((float)living.posX - x) < 2.0F && MathHelper.abs((float)living.posZ - z) < 2.0F)
                        {
                        double d0 = living.posY + 1.82D - (double)living.yOffset;
                        
                        if(d0 - y > 2.0D || y - d0 > 0.0D)
                        {
                        return 0;
                        }
                        }
                        float rotation = MathHelper.abs(living.rotationYaw);
                        return (rotation > 45F && rotation < 135F) || (rotation > 225F && rotation < 315F) ? 1 : 2;
                        }
                        }
                        
                        1 Reply Last reply Reply Quote 0
                        • vSKAH
                          vSKAH last edited by

                          J’ai une question car moi j’avais créer un topic qui résumer tous sa mais(Surtout pas envie de detterer) en compliqué mais je pense qu’il va être suprit car avec ce code on peux miner dans les claims faction

                          1 Reply Last reply Reply Quote 0
                          • BrokenSwing
                            BrokenSwing Moddeurs confirmés Rédacteurs last edited by

                            Avec un truc de ce type il ne devrait pas pouvoir miner dans les claims :

                            
                            public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) {
                            if(entity instanceof EntityPlayer) {
                            
                            EntityPlayer player = (EntityPlayer)entity;
                            
                            Vec3 lookVec = player.getLookVec();
                            double xLook = Math.abs(lookVec.xCoord);
                            double yLook = Math.abs(lookVec.yCoord);
                            double zLook = Math.abs(lookVec.zCoord);
                            
                            //Ici accorder un peu moins d'importance à yLook peut-être, à voir …
                            //L'idéal serait de savoir sur quelle face le joueur casse le bloc
                            double max = Math.max(xLook, Math.max(yLook, zLook));
                            
                            //Ici si vous avez une meilleur façon de ne faire tourner que sur deux boucle
                            //en fonction de la direction, je suis preneur
                            
                            int addX = 1;
                            int addY = 1;
                            int addZ = 1;
                            
                            if(max == xLook) {
                            y -= 2;
                            z -= 2;
                            addX = 5;
                            } else if(max == yLook) {
                            x -= 2;
                            z -= 2;
                            addY = 5;
                            } else if(max == zLook) {
                            x -= 2;
                            y -= 2;
                            addZ = 5;
                            }
                            
                            for(int xOffset = 0; xOffset < 5; xOffset += addX) {
                            for(int yOffset = 0; yOffset < 5; yOffset += addY) {
                            for(int zOffset = 0; zOffset < 5; zOffset += addZ) {
                            
                            Block currentBlock = world.getBlock(x + xOffset, y + yOffset, z + zOffset);
                            int blockMetadata = world.getBlockMetadata(x + xOffset, y + yOffset, z + zOffset);
                            
                            BreakEvent event = new BreakEvent(x + xOffset, y + yOffset, x + zOffset, world, currentBlock, blockMetadata, (EntityPlayer)player);
                            event.setCanceled(!player.capabilities.isCreativeMode);
                            
                            if(currentBlock.getBlockHardness(world, x + xOffset, y + yOffset, z + zOffset) >= 0) {
                            event.setCanceled(false);
                            }
                            
                            MinecraftForge.EVENT_BUS.post(event);
                            
                            if(!event.isCanceled()) {
                            currentBlock.harvestBlock(world, (EntityPlayer)player, x + xOffset, y + yOffset, z + zOffset, blockMetadata);
                            world.setBlockToAir(x + xOffset, y + yOffset, z + zOffset);
                            
                            boolean hasSilk = EnchantmentHelper.getSilkTouchModifier(player);
                            boolean canSilk = currentBlock.canSilkHarvest(world, (EntityPlayer)player, x + xOffset, y + yOffset, z + zOffset, blockMetadata);
                            if(ForgeHooks.canHarvestBlock(currentBlock, (EntityPlayer)player, blockMetadata) && (!hasSilk || hasSilk && !canSilk)) {
                            
                            //Ici on spawn de l'exp à chaque bloc, peut-être faire un total de l'expérience
                            //et n'en faire spawn qu'un à la fin ?
                            int exp = currentBlock.getExpDrop(world, blockMetadata, EnchantmentHelper.getFortuneModifier(player));
                            currentBlock.dropXpOnBlockBreak(world, x + xOffset, y + yOffset, z + zOffset, exp);
                            }
                            }
                            }
                            }
                            }
                            return true;
                            }
                            return false;
                            }
                            
                            
                            1 Reply Last reply Reply Quote 0
                            • Tituya
                              Tituya last edited by

                              Fait un peu attention au déterrage de sujet, le dernier message vien de 7 mois !

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

                                Non desoler 😄 ce n’est pas grave mais fait attention, parfois c’est sanctionné, je dit ca pour toi

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

                                  Eh bien tu modifies les boucles, jusqu’où elles vont. Là il s’agit de pures connaissances en Java, et d’un peu de logique 😃

                                  1 Reply Last reply Reply Quote 0
                                  • 1 / 1
                                  • First post
                                    Last post
                                  Design by Woryk
                                  Contact / Mentions Légales / Faire un don

                                  MINECRAFT FORGE FRANCE © 2018

                                  Powered by NodeBB