MFF

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

    Création tnt

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    47 Messages 8 Publieurs 8.6k 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.
    • S Hors-ligne
      Sebenf0rce
      dernière édition par

      @‘AymericRed’:

      Empėcher les lags ? Même les explosions Vanilla laguent mais tu peux essayer de faire spawn moins de particules ou encore ne pas faire spawn les EntityItem des blocks…

      Envoyé de mon RAINBOW LITE 4G en utilisant Tapatalk

      Le problème c’est que là j’ai augmenté la puissance à 2000F pour pouvoir casser la tnt mais du coup ça fait limite crashé le jeu. Je ne trouve pas où réduire le rayon de la tnt.

      Sinon pour register l’entité ce n’est pas comme ça ? :
               EntityRegistry.registerModEntity(TntZenodium.class, “tntZenodium”, 30, Main.MODID, 1, 1, true);

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

        Salut Sebenf0rce,
        Pour palier à ton problème, tu peux peut-être essayer de redéfinir la méthode doExplosionA() ?
        C’est la méthode qui permet de détruire les blocks adjacent à ta TNT. Dans cette méthode tu as un test à un moment :

        
        Block block = this.worldObj.getBlock(j1, k1, l1);
        if (block.getMaterial() != Material.air) {
        float f3 = this.exploder != null ? this.exploder.func_145772_a(this, this.worldObj, j1, k1, l1, block) : block.getExplosionResistance(this.exploder, worldObj, j1, k1, l1, explosionX, explosionY, explosionZ);
        f1 -= (f3 + 0.3F) * f2;
        }
        

        Si je ne dis pas de bétises, il me semble que tu récupères la résistance des blocks adjacent à ta TNT.
        Modifie le pour que si le block  détecté est un block d’obsidienne alors la résistance f3 retranchée à f1 soit petite (genre tu mets un f3 = à la resistance de la dirt par exemple).
        Et tu gardes une valeur d’explosion relativement faible ce qui va réduire tes lags et ton rayon d’action.
        PS : Je suis pas chez moi pour l’instant, je ne peux pas tester ce que j’avance mais je le fais dès que j’arrive 😉
        Bon courage et en espérant avoir aidé !

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

          Salut,
          J’ai essayé de faire ce que tu m’as dit mais le jeu crash, voila mon nouveau code :

          if (block.getMaterial() != Material.air)
                                     {
                                      if(block.getMaterial() == Blocks.obsidian.getMaterial()) {
                                       float f3 =  2.0f;
                                       f1 -= (f3 + 0.3F) * f2;
                                      }
                                      else {
                                         float f3 = this.exploder != null ? this.exploder.func_145772_a(this, this.worldObj, j1, k1, l1, block) : block.getExplosionResistance(this.exploder, worldObj, j1, k1, l1, explosionX, explosionY, explosionZ);
                                         f1 -= (f3 + 0.3F) * f2;
                                     }
                                     }
          

          Suis-je partis sur une mauvaise base ?

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

            Attention, si tu regardes le block d’obsidienne, il étend la classe BlockStone qui a pour material stone, du coup ta TNT risque de ravager à la fois l’obsidienne mais aussi tout les blocks de stone, cobble etc…
            J’ai essayé en modifiant la méthode comme ça et ça a marché :

            
            if (block.getMaterial() != Material.air)
            {
                  float f3 = this.exploder != null ?
                        this.exploder.func_145772_a(this, this.worldObj, j1, k1, l1, block) :
                        block.getExplosionResistance(this.exploder, worldObj, j1, k1, l1, explosionX, explosionY, explosionZ);
            
                 if(block == Blocks.obsidian)
                         f3 = 1.0F;
            
                  f1 -= (f3 + 0.3F) * f2;
            }
            
            

            Si ça plante encore, envoie le rapport d’erreur s’il te plait : )

            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

              C’est en effet ici que la résistance du bloc est prit en compte :

              for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F)
              {
              int j1 = MathHelper.floor_double(d5);
              int k1 = MathHelper.floor_double(d6);
              int l1 = MathHelper.floor_double(d7);
              Block block = this.worldObj.getBlock(j1, k1, l1);
              
              if (block.getMaterial() != Material.air)
              {
              float f3 = this.exploder != null ? this.exploder.func_145772_a(this, this.worldObj, j1, k1, l1, block) : block.getExplosionResistance(this.exploder, worldObj, j1, k1, l1, explosionX, explosionY, explosionZ);
              f1 -= (f3 + 0.3F) * f2;
              }
              
              if (f1 > 0.0F && (this.exploder == null || this.exploder.func_145774_a(this, this.worldObj, j1, k1, l1, block, f1)))
              {
              hashset.add(new ChunkPosition(j1, k1, l1));
              }
              
              d5 += d0 * (double)f2;
              d6 += d1 * (double)f2;
              d7 += d2 * (double)f2;
              }
              

              Dans la deuxième condition il suffit d’enlever f1 > 0.0F et ça devrait être bon.

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

                J’ai un crash qui survient lors de la création de mon explosionCustom :
                http://pastebin.com/bF4Ev0UM

                Et je n’ai n’arrive pas à avoir la texture de la tnt lorsqu’elle est actionné pourtant je pense bien avoir register ce qu’il fallait.
                Voici mon code :
                Main :

                tntZenodium = new TntZenodium().setHardness(0.0F).setBlockName("tnt").setBlockTextureName(Main.MODID + "tnt");
                        GameRegistry.registerBlock(tntZenodium, "tntZenodium");
                        EntityRegistry.registerModEntity(EntityTNTCustom.class, "EntityTNTCustom", 30, Main.MODID, 80, 3, true);
                

                Classe de la tnt :

                package com.sebenforce;
                
                import cpw.mods.fml.relauncher.Side;
                import cpw.mods.fml.relauncher.SideOnly;
                
                import java.util.Random;
                
                import net.minecraft.block.Block;
                import net.minecraft.block.material.Material;
                import net.minecraft.client.renderer.texture.IIconRegister;
                import net.minecraft.creativetab.CreativeTabs;
                import net.minecraft.entity.Entity;
                import net.minecraft.entity.EntityLivingBase;
                import net.minecraft.entity.player.EntityPlayer;
                import net.minecraft.entity.projectile.EntityArrow;
                import net.minecraft.init.Items;
                import net.minecraft.util.IIcon;
                import net.minecraft.world.Explosion;
                import net.minecraft.world.World;
                
                public class TntZenodium extends Block
                {
                   @SideOnly(Side.CLIENT)
                   private IIcon field_150116_a;
                   @SideOnly(Side.CLIENT)
                   private IIcon field_150115_b;
                
                   public TntZenodium()
                   {
                       super(Material.tnt);
                       this.setCreativeTab(CreativeTabs.tabRedstone);
                   }
                
                   @SideOnly(Side.CLIENT)
                   public IIcon getIcon(int p_149691_1_, int p_149691_2_)
                   {
                       return p_149691_1_ == 0 ? this.field_150115_b : (p_149691_1_ == 1 ? this.field_150116_a : this.blockIcon);
                   }
                
                   /**
                    * Called whenever the block is added into the world. Args: world, x, y, z
                    */
                   public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_)
                   {
                       super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_);
                
                       if (p_149726_1_.isBlockIndirectlyGettingPowered(p_149726_2_, p_149726_3_, p_149726_4_))
                       {
                           this.onBlockDestroyedByPlayer(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_, 1);
                           p_149726_1_.setBlockToAir(p_149726_2_, p_149726_3_, p_149726_4_);
                       }
                   }
                
                   /**
                    * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
                    * their own) Args: x, y, z, neighbor Block
                    */
                   public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
                   {
                       if (p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_))
                       {
                           this.onBlockDestroyedByPlayer(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, 1);
                           p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_);
                       }
                   }
                
                   /**
                    * Returns the quantity of items to drop on block destruction.
                    */
                   public int quantityDropped(Random p_149745_1_)
                   {
                       return 1;
                   }
                
                   /**
                    * Called upon the block being destroyed by an explosion
                    */
                   public void onBlockDestroyedByExplosion(World p_149723_1_, int p_149723_2_, int p_149723_3_, int p_149723_4_, Explosion p_149723_5_)
                   {
                       if (!p_149723_1_.isRemote)
                       {
                        EntityTNTCustom entitytntprimed = new EntityTNTCustom(p_149723_1_, (double)((float)p_149723_2_ + 0.5F), (double)((float)p_149723_3_ + 0.5F), (double)((float)p_149723_4_ + 0.5F), p_149723_5_.getExplosivePlacedBy());
                           entitytntprimed.fuse = p_149723_1_.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8;
                           p_149723_1_.spawnEntityInWorld(entitytntprimed);
                       }
                   }
                
                   /**
                    * Called right before the block is destroyed by a player.  Args: world, x, y, z, metaData
                    */
                   public void onBlockDestroyedByPlayer(World p_149664_1_, int p_149664_2_, int p_149664_3_, int p_149664_4_, int p_149664_5_)
                   {
                       this.func_150114_a(p_149664_1_, p_149664_2_, p_149664_3_, p_149664_4_, p_149664_5_, (EntityLivingBase)null);
                   }
                
                   public void func_150114_a(World p_150114_1_, int p_150114_2_, int p_150114_3_, int p_150114_4_, int p_150114_5_, EntityLivingBase p_150114_6_)
                   {
                       if (!p_150114_1_.isRemote)
                       {
                           if ((p_150114_5_ & 1) == 1)
                           {
                            EntityTNTCustom entitytntprimed = new EntityTNTCustom(p_150114_1_, (double)((float)p_150114_2_ + 0.5F), (double)((float)p_150114_3_ + 0.5F), (double)((float)p_150114_4_ + 0.5F), p_150114_6_);
                               p_150114_1_.spawnEntityInWorld(entitytntprimed);
                               p_150114_1_.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
                           }
                       }
                   }
                
                   /**
                    * Called upon block activation (right click on the block.)
                    */
                   public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
                   {
                       if (p_149727_5_.getCurrentEquippedItem() != null && p_149727_5_.getCurrentEquippedItem().getItem() == Items.flint_and_steel)
                       {
                           this.func_150114_a(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, 1, p_149727_5_);
                           p_149727_1_.setBlockToAir(p_149727_2_, p_149727_3_, p_149727_4_);
                           p_149727_5_.getCurrentEquippedItem().damageItem(1, p_149727_5_);
                           return true;
                       }
                       else
                       {
                           return super.onBlockActivated(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, p_149727_5_, p_149727_6_, p_149727_7_, p_149727_8_, p_149727_9_);
                       }
                   }
                
                   /**
                    * Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
                    */
                   public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_)
                   {
                       if (p_149670_5_ instanceof EntityArrow && !p_149670_1_.isRemote)
                       {
                           EntityArrow entityarrow = (EntityArrow)p_149670_5_;
                
                           if (entityarrow.isBurning())
                           {
                               this.func_150114_a(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_, 1, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase)entityarrow.shootingEntity : null);
                               p_149670_1_.setBlockToAir(p_149670_2_, p_149670_3_, p_149670_4_);
                           }
                       }
                   }
                
                   /**
                    * Return whether this block can drop from an explosion.
                    */
                   public boolean canDropFromExplosion(Explosion p_149659_1_)
                   {
                       return false;
                   }
                
                   @SideOnly(Side.CLIENT)
                   public void registerBlockIcons(IIconRegister p_149651_1_)
                   {
                       this.blockIcon = p_149651_1_.registerIcon(Main.MODID + ":tnt_side");
                       this.field_150116_a = p_149651_1_.registerIcon(Main.MODID + ":tnt_top");
                       this.field_150115_b = p_149651_1_.registerIcon(Main.MODID + ":tnt_bottom");
                   }
                }
                

                La classe de l’entité :

                package com.sebenforce;
                
                import cpw.mods.fml.relauncher.Side;
                import cpw.mods.fml.relauncher.SideOnly;
                import net.minecraft.entity.Entity;
                import net.minecraft.entity.EntityLivingBase;
                import net.minecraft.nbt.NBTTagCompound;
                import net.minecraft.world.Explosion;
                import net.minecraft.world.World;
                
                public class EntityTNTCustom extends Entity
                {
                   /** How long the fuse is */
                   public int fuse;
                   private EntityLivingBase tntPlacedBy;
                   private static final String __OBFID = "CL_00001681";
                
                   public EntityTNTCustom(World p_i1729_1_)
                   {
                       super(p_i1729_1_);
                       this.preventEntitySpawning = true;
                       this.setSize(0.98F, 0.98F);
                       this.yOffset = this.height / 2.0F;
                   }
                
                   public EntityTNTCustom(World p_i1730_1_, double p_i1730_2_, double p_i1730_4_, double p_i1730_6_, EntityLivingBase p_i1730_8_)
                   {
                       this(p_i1730_1_);
                       this.setPosition(p_i1730_2_, p_i1730_4_, p_i1730_6_);
                       float f = (float)(Math.random() * Math.PI * 2.0D);
                       this.motionX = (double)(-((float)Math.sin((double)f)) * 0.02F);
                       this.motionY = 0.20000000298023224D;
                       this.motionZ = (double)(-((float)Math.cos((double)f)) * 0.02F);
                       this.fuse = 80;
                       this.prevPosX = p_i1730_2_;
                       this.prevPosY = p_i1730_4_;
                       this.prevPosZ = p_i1730_6_;
                       this.tntPlacedBy = p_i1730_8_;
                   }
                
                   protected void entityInit() {}
                
                   /**
                    * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
                    * prevent them from trampling crops
                    */
                   protected boolean canTriggerWalking()
                   {
                       return false;
                   }
                
                   /**
                    * Returns true if other Entities should be prevented from moving through this Entity.
                    */
                   public boolean canBeCollidedWith()
                   {
                       return !this.isDead;
                   }
                
                   /**
                    * Called to update the entity's position/logic.
                    */
                   public void onUpdate()
                   {
                       this.prevPosX = this.posX;
                       this.prevPosY = this.posY;
                       this.prevPosZ = this.posZ;
                       this.motionY -= 0.03999999910593033D;
                       this.moveEntity(this.motionX, this.motionY, this.motionZ);
                       this.motionX *= 0.9800000190734863D;
                       this.motionY *= 0.9800000190734863D;
                       this.motionZ *= 0.9800000190734863D;
                
                       if (this.onGround)
                       {
                           this.motionX *= 0.699999988079071D;
                           this.motionZ *= 0.699999988079071D;
                           this.motionY *= -0.5D;
                       }
                
                       if (this.fuse– <= 0)
                       {
                           this.setDead();
                
                           if (!this.worldObj.isRemote)
                           {
                               this.explode();
                           }
                       }
                       else
                       {
                           this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
                       }
                   }
                
                   private void explode()
                   {
                       float f = 4.0F;
                      createExplosion(this, this.posX, this.posY, this.posZ, f, true);
                   }
                
                   /**
                    * Creates an explosion. Args: entity, x, y, z, strength
                    */
                   public ExplosionCustom createExplosion(Entity p_72876_1_, double p_72876_2_, double p_72876_4_, double p_72876_6_, float p_72876_8_, boolean p_72876_9_)
                   {
                       return this.newExplosion(p_72876_1_, p_72876_2_, p_72876_4_, p_72876_6_, p_72876_8_, false, p_72876_9_);
                   }
                
                   /**
                    * returns a new explosion. Does initiation (at time of writing Explosion is not finished)
                    */
                   public ExplosionCustom newExplosion(Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_)
                   {
                    ExplosionCustom explosion = new ExplosionCustom(this.worldObj, p_72885_1_, p_72885_2_, p_72885_4_, p_72885_6_, p_72885_8_);
                       explosion.isFlaming = p_72885_9_;
                       explosion.isSmoking = p_72885_10_;
                       if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.worldObj, explosion)) return explosion;
                       explosion.doExplosionA();
                       explosion.doExplosionB(true);
                       return explosion;
                   }
                
                   /**
                    * (abstract) Protected helper method to write subclass entity data to NBT.
                    */
                   protected void writeEntityToNBT(NBTTagCompound p_70014_1_)
                   {
                       p_70014_1_.setByte("Fuse", (byte)this.fuse);
                   }
                
                   /**
                    * (abstract) Protected helper method to read subclass entity data from NBT.
                    */
                   protected void readEntityFromNBT(NBTTagCompound p_70037_1_)
                   {
                       this.fuse = p_70037_1_.getByte("Fuse");
                   }
                
                   @SideOnly(Side.CLIENT)
                   public float getShadowSize()
                   {
                       return 0.0F;
                   }
                
                   /**
                    * returns null or the entityliving it was placed or ignited by
                    */
                   public EntityLivingBase getTntPlacedBy()
                   {
                       return this.tntPlacedBy;
                   }
                }
                

                Et la classe de l’explosion :

                package com.sebenforce;
                
                import java.util.ArrayList;
                import java.util.HashMap;
                import java.util.HashSet;
                import java.util.Iterator;
                import java.util.List;
                import java.util.Map;
                import java.util.Random;
                
                import net.minecraft.block.Block;
                import net.minecraft.block.material.Material;
                import net.minecraft.enchantment.EnchantmentProtection;
                import net.minecraft.entity.Entity;
                import net.minecraft.entity.EntityLivingBase;
                import net.minecraft.entity.player.EntityPlayer;
                import net.minecraft.init.Blocks;
                import net.minecraft.util.AxisAlignedBB;
                import net.minecraft.util.DamageSource;
                import net.minecraft.util.MathHelper;
                import net.minecraft.util.Vec3;
                import net.minecraft.world.ChunkPosition;
                import net.minecraft.world.Explosion;
                import net.minecraft.world.World;
                
                public class ExplosionCustom extends Explosion
                {
                   /** whether or not the explosion sets fire to blocks around it */
                   public boolean isFlaming;
                   /** whether or not this explosion spawns smoke particles */
                   public boolean isSmoking = true;
                   private int field_77289_h = 16;
                   private Random explosionRNG = new Random();
                   private World worldObj;
                   public double explosionX;
                   public double explosionY;
                   public double explosionZ;
                   public Entity exploder;
                   public float explosionSize;
                   /** A list of ChunkPositions of blocks affected by this explosion */
                   public List affectedBlockPositions = new ArrayList();
                   private Map field_77288_k = new HashMap();
                   private static final String __OBFID = "CL_00000134";
                
                   public ExplosionCustom(World p_i1948_1_, Entity p_i1948_2_, double p_i1948_3_, double p_i1948_5_, double p_i1948_7_, float p_i1948_9_)
                   {
                     super(p_i1948_1_,p_i1948_2_ , p_i1948_3_, p_i1948_5_,p_i1948_7_, p_i1948_9_);
                   }
                
                   /**
                    * Does the first part of the explosion (destroy blocks)
                    */
                   public void doExplosionA()
                   {
                       float f = this.explosionSize;
                       HashSet hashset = new HashSet();
                       int i;
                       int j;
                       int k;
                       double d5;
                       double d6;
                       double d7;
                
                       for (i = 0; i < this.field_77289_h; ++i)
                       {
                           for (j = 0; j < this.field_77289_h; ++j)
                           {
                               for (k = 0; k < this.field_77289_h; ++k)
                               {
                                   if (i == 0 || i == this.field_77289_h - 1 || j == 0 || j == this.field_77289_h - 1 || k == 0 || k == this.field_77289_h - 1)
                                   {
                                       double d0 = (double)((float)i / ((float)this.field_77289_h - 1.0F) * 2.0F - 1.0F);
                                       double d1 = (double)((float)j / ((float)this.field_77289_h - 1.0F) * 2.0F - 1.0F);
                                       double d2 = (double)((float)k / ((float)this.field_77289_h - 1.0F) * 2.0F - 1.0F);
                                       double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
                                       d0 /= d3;
                                       d1 /= d3;
                                       d2 /= d3;
                                       float f1 = this.explosionSize * (0.7F + this.worldObj.rand.nextFloat() * 0.6F);
                                       d5 = this.explosionX;
                                       d6 = this.explosionY;
                                       d7 = this.explosionZ;
                
                                       for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F)
                                       {
                                           int j1 = MathHelper.floor_double(d5);
                                           int k1 = MathHelper.floor_double(d6);
                                           int l1 = MathHelper.floor_double(d7);
                                           Block block = this.worldObj.getBlock(j1, k1, l1);
                
                                           if (block.getMaterial() != Material.air)
                                           {
                                               float f3 = this.exploder != null ? this.exploder.func_145772_a(this, this.worldObj, j1, k1, l1, block) : block.getExplosionResistance(this.exploder, worldObj, j1, k1, l1, explosionX, explosionY, explosionZ);
                                               f1 -= (f3 + 0.3F) * f2;
                                           }
                
                                           if (f1 > 0.0F && (this.exploder == null || this.exploder.func_145774_a(this, this.worldObj, j1, k1, l1, block, f1)))
                                           {
                                               hashset.add(new ChunkPosition(j1, k1, l1));
                                           }
                
                                           d5 += d0 * (double)f2;
                                           d6 += d1 * (double)f2;
                                           d7 += d2 * (double)f2;
                                       }
                                   }
                               }
                           }
                       }
                
                       this.affectedBlockPositions.addAll(hashset);
                       this.explosionSize *= 2.0F;
                       i = MathHelper.floor_double(this.explosionX - (double)this.explosionSize - 1.0D);
                       j = MathHelper.floor_double(this.explosionX + (double)this.explosionSize + 1.0D);
                       k = MathHelper.floor_double(this.explosionY - (double)this.explosionSize - 1.0D);
                       int i2 = MathHelper.floor_double(this.explosionY + (double)this.explosionSize + 1.0D);
                       int l = MathHelper.floor_double(this.explosionZ - (double)this.explosionSize - 1.0D);
                       int j2 = MathHelper.floor_double(this.explosionZ + (double)this.explosionSize + 1.0D);
                       List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this.exploder, AxisAlignedBB.getBoundingBox((double)i, (double)k, (double)l, (double)j, (double)i2, (double)j2));
                       net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.worldObj, this, list, this.explosionSize);
                       Vec3 vec3 = Vec3.createVectorHelper(this.explosionX, this.explosionY, this.explosionZ);
                
                       for (int i1 = 0; i1 < list.size(); ++i1)
                       {
                           Entity entity = (Entity)list.get(i1);
                           double d4 = entity.getDistance(this.explosionX, this.explosionY, this.explosionZ) / (double)this.explosionSize;
                
                           if (d4 <= 1.0D)
                           {
                               d5 = entity.posX - this.explosionX;
                               d6 = entity.posY + (double)entity.getEyeHeight() - this.explosionY;
                               d7 = entity.posZ - this.explosionZ;
                               double d9 = (double)MathHelper.sqrt_double(d5 * d5 + d6 * d6 + d7 * d7);
                
                               if (d9 != 0.0D)
                               {
                                   d5 /= d9;
                                   d6 /= d9;
                                   d7 /= d9;
                                   double d10 = (double)this.worldObj.getBlockDensity(vec3, entity.boundingBox);
                                   double d11 = (1.0D - d4) * d10;
                                   entity.attackEntityFrom(DamageSource.setExplosionSource(this), (float)((int)((d11 * d11 + d11) / 2.0D * 8.0D * (double)this.explosionSize + 1.0D)));
                                   double d8 = EnchantmentProtection.func_92092_a(entity, d11);
                                   entity.motionX += d5 * d8;
                                   entity.motionY += d6 * d8;
                                   entity.motionZ += d7 * d8;
                
                                   if (entity instanceof EntityPlayer)
                                   {
                                       this.field_77288_k.put((EntityPlayer)entity, Vec3.createVectorHelper(d5 * d11, d6 * d11, d7 * d11));
                                   }
                               }
                           }
                       }
                
                       this.explosionSize = f;
                   }
                
                   /**
                    * Does the second part of the explosion (sound, particles, drop spawn)
                    */
                   public void doExplosionB(boolean p_77279_1_)
                   {
                       this.worldObj.playSoundEffect(this.explosionX, this.explosionY, this.explosionZ, "random.explode", 4.0F, (1.0F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F) * 0.7F);
                
                       if (this.explosionSize >= 2.0F && this.isSmoking)
                       {
                           this.worldObj.spawnParticle("hugeexplosion", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D);
                       }
                       else
                       {
                           this.worldObj.spawnParticle("largeexplode", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D);
                       }
                
                       Iterator iterator;
                       ChunkPosition chunkposition;
                       int i;
                       int j;
                       int k;
                       Block block;
                
                       if (this.isSmoking)
                       {
                           iterator = this.affectedBlockPositions.iterator();
                
                           while (iterator.hasNext())
                           {
                               chunkposition = (ChunkPosition)iterator.next();
                               i = chunkposition.chunkPosX;
                               j = chunkposition.chunkPosY;
                               k = chunkposition.chunkPosZ;
                               block = this.worldObj.getBlock(i, j, k);
                
                               if (p_77279_1_)
                               {
                                   double d0 = (double)((float)i + this.worldObj.rand.nextFloat());
                                   double d1 = (double)((float)j + this.worldObj.rand.nextFloat());
                                   double d2 = (double)((float)k + this.worldObj.rand.nextFloat());
                                   double d3 = d0 - this.explosionX;
                                   double d4 = d1 - this.explosionY;
                                   double d5 = d2 - this.explosionZ;
                                   double d6 = (double)MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5);
                                   d3 /= d6;
                                   d4 /= d6;
                                   d5 /= d6;
                                   double d7 = 0.5D / (d6 / (double)this.explosionSize + 0.1D);
                                   d7 *= (double)(this.worldObj.rand.nextFloat() * this.worldObj.rand.nextFloat() + 0.3F);
                                   d3 *= d7;
                                   d4 *= d7;
                                   d5 *= d7;
                                   this.worldObj.spawnParticle("explode", (d0 + this.explosionX * 1.0D) / 2.0D, (d1 + this.explosionY * 1.0D) / 2.0D, (d2 + this.explosionZ * 1.0D) / 2.0D, d3, d4, d5);
                                   this.worldObj.spawnParticle("smoke", d0, d1, d2, d3, d4, d5);
                               }
                
                               if (block.getMaterial() != Material.air)
                               {
                                   if (block.canDropFromExplosion(this))
                                   {
                                       block.dropBlockAsItemWithChance(this.worldObj, i, j, k, this.worldObj.getBlockMetadata(i, j, k), 1.0F / this.explosionSize, 0);
                                   }
                
                                   block.onBlockExploded(this.worldObj, i, j, k, this);
                               }
                           }
                       }
                
                       if (this.isFlaming)
                       {
                           iterator = this.affectedBlockPositions.iterator();
                
                           while (iterator.hasNext())
                           {
                               chunkposition = (ChunkPosition)iterator.next();
                               i = chunkposition.chunkPosX;
                               j = chunkposition.chunkPosY;
                               k = chunkposition.chunkPosZ;
                               block = this.worldObj.getBlock(i, j, k);
                               Block block1 = this.worldObj.getBlock(i, j - 1, k);
                
                               if (block.getMaterial() == Material.air && block1.func_149730_j() && this.explosionRNG.nextInt(3) == 0)
                               {
                                   this.worldObj.setBlock(i, j, k, Blocks.fire);
                               }
                           }
                       }
                   }
                
                   public Map func_77277_b()
                   {
                       return this.field_77288_k;
                   }
                
                   /**
                    * Returns either the entity that placed the explosive block, the entity that caused the explosion or null.
                    */
                   public EntityLivingBase getExplosivePlacedBy()
                   {
                       return this.exploder == null ? null : (this.exploder instanceof EntityTNTCustom ? ((EntityTNTCustom)this.exploder).getTntPlacedBy() : (this.exploder instanceof EntityLivingBase ? (EntityLivingBase)this.exploder : null));
                   }
                }
                
                1 réponse Dernière réponse Répondre Citer 0
                • AymericRedA Hors-ligne
                  AymericRed
                  dernière édition par

                  Tu as un npe à la ligne 80, c’est bien celle là : float f1 = this.explosionSize * (0.7F + this.worldObj.rand.nextFloat() * 0.6F); ?
                  Si oui, fais un print de this.worldObj puis this.worldObj.rand.

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

                    @‘AymericRed’:

                    Tu as un npe à la ligne 80, c’est bien celle là : float f1 = this.explosionSize * (0.7F + this.worldObj.rand.nextFloat() * 0.6F); ?
                    Si oui, fais un print de this.worldObj puis this.worldObj.rand.

                    J’ai donc ajouté cette ligne à la ligne 80 : System.out.println("Wordobj : " + this.worldObj + " worldObj.rand : " + this.worldObj.rand);
                    Cependant aucun texte ne s’affiche dans la console.

                    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

                      Supprimes également les lignes :
                      private static final String __OBFID = “CL_xxxxxxx”;
                      Sinon tu vas avoir des problèmes lors de la compilation.

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

                        D’accord j’ai bien supprimé cette ligne dans la classe entité et dans la classe explosion.
                        Sinon sais tu d’où peut provenir le crash ?

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

                          Salut,
                          Vraiment pas sur, j’ai regardé en coup de vent mais je crois qu’il y a une erreur dans la classe de l’entity :

                          
                          this(p_i1730_1_);
                          
                          

                          Devrait etre :

                          
                          super(p_i1730_1_);
                          
                          
                          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

                            Ça ne changera rien.
                            Faut trouver quelle variable est null et pourquoi.

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

                              @‘robin4002’:

                              Supprimes également les lignes :
                                private static final String __OBFID = “CL_xxxxxxx”;
                              Sinon tu vas avoir des problèmes lors de la compilation.

                              Oups j’en ai plein x)

                              Voila ma signature

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

                                Dans ta classe ExplosionCustom, essaie de modifier ton constructeur :

                                
                                public ExplosionCustom(World p_i1948_1_, Entity p_i1948_2_, double p_i1948_3_, double p_i1948_5_, double p_i1948_7_, float p_i1948_9_)
                                {
                                    super(p_i1948_1_, p_i1948_2_, p_i1948_3_, p_i1948_5_, p_i1948_7_, p_i1948_9_);
                                    this.worldObj = p_i1948_1_;
                                    this.exploder = p_i1948_2_;
                                    this.explosionX = p_i1948_3_;
                                    this.explosionY = p_i1948_5_;
                                    this.explosionZ = p_i1948_7_;
                                    this.explosionSize = p_i1948_9_;
                                }
                                
                                
                                1 réponse Dernière réponse Répondre Citer 1
                                • S Hors-ligne
                                  Sebenf0rce
                                  dernière édition par

                                  C’est bon ça marche merci beaucoup !!

                                  J’ai plus que le soucis de la tnt qui disparait quand elle est désactivé.
                                  J’ai fait ceci pour register mon Entité : EntityRegistry.registerModEntity(EntityTNTCustom.class, “EntityTNTCustom”, 30, Main.MODID, 80, 3, true);
                                  Est-bon ?

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

                                    Le problème ne vient pas de la déclaration mais plutot du block :
                                    Par exemple, la méthode

                                    
                                    public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
                                      {
                                          if (p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_))
                                          {
                                              this.onBlockDestroyedByPlayer(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, 1);
                                              p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_);
                                          }
                                      }
                                    
                                    

                                    va détecter un changement des blocs à coté de ta TNTCustome. Et si ce block active ta TNT (genre red torch etc…), alors un block d’air est placé à la place de ton block, il faut donc modifier cette ligne

                                    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

                                      Ah, il faut aussi enregistrer le rendu de l’entity comme celle de n’importe quelle entité.
                                      Pour le rendu tu peux reprendre le même code que le rendu de la tnt vanilla (RenderTNTPrimed)

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

                                        Ma classe EntityTNTCustom correspond exactement au même code que la classe RenderTNTPrimed pourtant 😮

                                        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

                                          Non, ta classe EntityTNTCustom correspond à EntityTNTPrimed.
                                          Maintenant il faut en plus faire un rendu.

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

                                            Ah oui autant pour moi.
                                            J’ai donc créé ma classe mais aucun changement. Ai-je oublié quelque chose ?
                                            Voici mon code :

                                            
                                            package com.sebenforce;
                                            
                                            import net.minecraft.client.renderer.RenderBlocks;
                                            import net.minecraft.client.renderer.entity.Render;
                                            import net.minecraft.client.renderer.texture.TextureMap;
                                            import net.minecraft.entity.Entity;
                                            import net.minecraft.init.Blocks;
                                            import net.minecraft.util.ResourceLocation;
                                            
                                            import org.lwjgl.opengl.GL11;
                                            
                                            import cpw.mods.fml.relauncher.Side;
                                            import cpw.mods.fml.relauncher.SideOnly;
                                            
                                            @SideOnly(Side.CLIENT)
                                            public class RenderTNTPrimed extends Render
                                            {
                                            private RenderBlocks blockRenderer = new RenderBlocks();
                                            
                                            public RenderTNTPrimed()
                                            {
                                            this.shadowSize = 0.5F;
                                            }
                                            
                                            /**
                                            * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
                                            * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
                                            * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" func_76986_a(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
                                            */
                                            public void doRender(EntityTNTCustom p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
                                            {
                                            GL11.glPushMatrix();
                                            GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_);
                                            float f2;
                                            
                                            if ((float)p_76986_1_.fuse - p_76986_9_ + 1.0F < 10.0F)
                                            {
                                            f2 = 1.0F - ((float)p_76986_1_.fuse - p_76986_9_ + 1.0F) / 10.0F;
                                            
                                            if (f2 < 0.0F)
                                            {
                                            f2 = 0.0F;
                                            }
                                            
                                            if (f2 > 1.0F)
                                            {
                                            f2 = 1.0F;
                                            }
                                            
                                            f2 *= f2;
                                            f2 *= f2;
                                            float f3 = 1.0F + f2 * 0.3F;
                                            GL11.glScalef(f3, f3, f3);
                                            }
                                            
                                            f2 = (1.0F - ((float)p_76986_1_.fuse - p_76986_9_ + 1.0F) / 100.0F) * 0.8F;
                                            this.bindEntityTexture(p_76986_1_);
                                            this.blockRenderer.renderBlockAsItem(Main.tntZenodium, 0, p_76986_1_.getBrightness(p_76986_9_));
                                            
                                            if (p_76986_1_.fuse / 5 % 2 == 0)
                                            {
                                            GL11.glDisable(GL11.GL_TEXTURE_2D);
                                            GL11.glDisable(GL11.GL_LIGHTING);
                                            GL11.glEnable(GL11.GL_BLEND);
                                            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);
                                            GL11.glColor4f(1.0F, 1.0F, 1.0F, f2);
                                            this.blockRenderer.renderBlockAsItem(Main.tntZenodium, 0, 1.0F);
                                            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                                            GL11.glDisable(GL11.GL_BLEND);
                                            GL11.glEnable(GL11.GL_LIGHTING);
                                            GL11.glEnable(GL11.GL_TEXTURE_2D);
                                            }
                                            
                                            GL11.glPopMatrix();
                                            }
                                            
                                            /**
                                            * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
                                            */
                                            protected ResourceLocation getEntityTexture(EntityTNTCustom p_110775_1_)
                                            {
                                            return TextureMap.locationBlocksTexture;
                                            }
                                            
                                            /**
                                            * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
                                            */
                                            protected ResourceLocation getEntityTexture(Entity p_110775_1_)
                                            {
                                            return this.getEntityTexture((EntityTNTCustom)p_110775_1_);
                                            }
                                            
                                            /**
                                            * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
                                            * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
                                            * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" func_76986_a(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
                                            */
                                            public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
                                            {
                                            this.doRender((EntityTNTCustom)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
                                            }
                                            }
                                            ```</t></t>
                                            1 réponse Dernière réponse Répondre Citer 0
                                            • 1
                                            • 2
                                            • 3
                                            • 2 / 3
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB