• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    Problèmes d'entité

    Sans suite
    1.7.10
    3
    5
    1350
    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.
    • JustPingo
      JustPingo dernière édition par

      Bonjour à tous !

      https://www.youtube.com/watch?v=jigqOU2zNCE
      (désolé j’avais oublié mon anti-pop)

      Appel de l’entité :

      EntityFlyingBlock entityflyingblock = new EntityFlyingBlock(worldObj, worldObj.getBlock(xCoord, yCoord, zCoord), sat);
      
      entityflyingblock.setPosition(xCoord, yCoord+0.1D, zCoord);
      worldObj.setBlockToAir(xCoord, yCoord, zCoord);
      worldObj.spawnEntityInWorld(entityflyingblock);
      

      Entité :

      package pingo.una.common;
      
      import net.minecraft.block.Block;
      import net.minecraft.entity.Entity;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.world.World;
      
      public class EntityFlyingBlock extends Entity {
      
      public Block block;
      public int metadata;
      
      private Satellite sat;
      private AddOn addOn;
      
      private int tickCounter;
      
      public int maxHeight;
      
      public EntityFlyingBlock(World world, Block block, Satellite sat, AddOn addOn) {
      super(world);
      this.setSize(1.0F, 1.0F); 
              this.yOffset = 0.5F; 
              this.preventEntitySpawning = true;
              this.block = block;
              this.sat = sat;
              this.addOn = addOn;
              this.maxHeight = world.getActualHeight() + 8;
      }
      
      public EntityFlyingBlock(World world, Block block, Satellite sat) {
      super(world);
      this.setSize(1.0F, 1.0F); 
              this.yOffset = 0.5F; 
              this.preventEntitySpawning = true;
              this.block = block;
              this.sat = sat;
              this.maxHeight = world.getActualHeight() + 8;
      }
      
          public EntityFlyingBlock(World world, Block block) {
      super(world);
      this.setSize(1.0F, 1.0F); 
              this.yOffset = 0.5F; 
              this.preventEntitySpawning = true;
              this.block = block;
              this.maxHeight = world.getActualHeight() + 8;
      }
      
          public EntityFlyingBlock(World world) {
      super(world);
      this.setSize(1.0F, 1.0F); 
              this.yOffset = 0.5F; 
              this.tickCounter = 0;
              this.preventEntitySpawning = true;
              this.maxHeight = world.getActualHeight() + 8;
      }
      
      @Override
      public void onUpdate()
          {
              this.moveEntity(0, 0.5, 0);
              this.tickCounter++;
              if (this.tickCounter % 2 == 0) {
              if (worldObj.isRemote) {
              worldObj.spawnParticle("flame", posX + 0.5D * rand.nextDouble(), posY-0.1D, posZ + 0.5D * rand.nextDouble(), 0.0D, 0.0D, 0.0D);
              worldObj.spawnParticle("flame", posX+0.5D + 0.5D * rand.nextDouble(), posY-0.1D, posZ + 0.5D * rand.nextDouble(), 0.0D, 0.0D, 0.0D);
              worldObj.spawnParticle("flame", posX + 0.5D * rand.nextDouble(), posY-0.1D, posZ+0.5D + 0.5D * rand.nextDouble(), 0.0D, 0.0D, 0.0D);
              worldObj.spawnParticle("flame", posX+0.5D + 0.5D * rand.nextDouble(), posY-0.1D, posZ+0.5D + 0.5D * rand.nextDouble(), 0.0D, 0.0D, 0.0D);
              this.tickCounter = 0;
              // particles : flame
              // spawnParticle
              }
              }
              if (this.isCollided) {
              this.worldObj.createExplosion(null, posX, posY, posZ, 4F, true);
              this.kill();
              } else if (this.posY > this.maxHeight) {
              this.callback();
              this.kill();
              }
          }
      
      public void callback() {
      if (!worldObj.isRemote) {
      System.out.println("callback");
      if (this.addOn != null && this.sat != null) {
      this.sat.newAddOn(this.addOn);
      } else if (this.sat != null) {
      UberNetworkingAntennas.satellites.add(sat);
      System.out.println("Added satellite");
      }
      }
      }
      
      @Override
      protected void entityInit() {
      
      }
      
      protected void writeEntityToNBT(NBTTagCompound nbttag)
          {
              nbttag.setInteger("tickCounter", this.tickCounter);
          }
      
          protected void readEntityFromNBT(NBTTagCompound nbttag)
          {
              if (nbttag.hasKey("tickCounter")) this.tickCounter = nbttag.getInteger("tickCounter");
          }
      
      }
      

      Render :

      @SideOnly(Side.CLIENT)
      
      public class RenderEntityFlyingBlock extends Render
      {
          private RenderBlocks blockRenderer = new RenderBlocks();
      
          public void renderEntityFlyingBlock(EntityFlyingBlock entity, double par2, double par4, double par6, float par8, float par9) {        
              if (entity.block == null) entity.block = UberNetworkingAntennas.satelliteCore; 
          GL11.glPushMatrix();
              GL11.glTranslatef((float) par2, (float) par4, (float) par6);
              this.blockRenderer.renderBlockAsItem(entity.block, 0, entity.getBrightness(par9));
              GL11.glPopMatrix();
          }
      
          public void doRender(Entity entity, double par2, double par4, double par6, float par8, float par9)
          {
              this.renderEntityFlyingBlock((EntityFlyingBlock)entity, par2, par4, par6, par8, par9);
          }
      
      @Override
      protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
      return null;
      }
      
      }
      

      Oh, et au fait, l’entité n’arrive pas à prendre la texture du block dynamiquement. Des idées ?

      Merci d’avance !


      Über Networking Antennas

      1 réponse Dernière réponse Répondre Citer 0
      • mindany2
        mindany2 dernière édition par

        Salut ^^
        Je ne te savais pas youtubeur 😛 
        A vue d’oeil dans ton code il y a

        
        worldObj.spawnParticle("flame", posX + 0.5D * rand.nextDouble(), posY-0.1D, posZ + 0.5D * rand.nextDouble(), 0.0D, 0.0D, 0.0D);
        
                worldObj.spawnParticle("flame", posX+0.5D + 0.5D * rand.nextDouble(), posY-0.1D, posZ + 0.5D * rand.nextDouble(), 0.0D, 0.0D, 0.0D);
        
                worldObj.spawnParticle("flame", posX + 0.5D * rand.nextDouble(), posY-0.1D, posZ+0.5D + 0.5D * rand.nextDouble(), 0.0D, 0.0D, 0.0D);
        
                worldObj.spawnParticle("flame", posX+0.5D + 0.5D * rand.nextDouble(), posY-0.1D, posZ+0.5D + 0.5D * rand.nextDouble(), 0.0D, 0.0D, 0.0D);
        
        ​
        

        –>

        posX+0.5D + 0.5D * rand.nextDouble(), posY-0.1D, posZ+0.5D + 0.5D * rand.nextDouble(), 0.0D, 0.0D, 0.0D);
        

        Je ne suis pas connaisseur mais là tes particules ne sont pas sous le bloc, je pense que c’est fait exprès mais peut-être que le nombre est trop élevé, essaye de le baisser un peu

        ^^

        1 réponse Dernière réponse Répondre Citer 0
        • JustPingo
          JustPingo dernière édition par

          Nan nan !

          Ca tout va bien, le problème n’est pas ici (cet algorithme marche très bien, il permet une répartition aléatoire des particules sur la surface des blocks).

          Le problème c’est que l’entité n’est pas centrée par rapport à sa position de décollage, je n’ai pas dû être assez clair car les particules sont au bon endroit mais pas l’entité (alors que ces particules sont calculées par rapport à la position client de l’entité).

          Le deuxième problème est que parfois l’entité est transparente avant d’apparaître.


          Über Networking Antennas

          1 réponse Dernière réponse Répondre Citer 0
          • Gugu
            Gugu dernière édition par

            Essaie de faire F3 + B pour voir l’hitbox de l’entity. Ton render est peut-être un peu a côté.

            "If you have a comprehensive explanation for everything then it decreases uncertainty and anxiety and reduces your cognitive load. And if you can use that simplifying algorithm to put yourself on the side of moral virtue then you’re constantly a good person with a minimum of effort."
            ― Jordan B. Peterson

            1 réponse Dernière réponse Répondre Citer 0
            • JustPingo
              JustPingo dernière édition par

              La hitbox est au niveau du render, render décalé par rapport à la bonne coordonnée.


              Über Networking Antennas

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

              MINECRAFT FORGE FRANCE © 2018

              Powered by NodeBB