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

Résolu Faire un double extends

1.7.x
1.7.10
3
14
523
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.
  • D
    Drastic dernière édition par 1 sept. 2019, 15:12

    Bonjour, pour faire ma “Dynamite”, j’ai besoin d’extends la classe EntityThrowable pour la lancer mais aussi la classe Entity pour la faire exploser. comment faire ?

    1 réponse Dernière réponse Répondre Citer 0
    • Heaven
      Heaven dernière édition par Heaven 1 sept. 2019, 15:53 1 sept. 2019, 15:47

      ok j ai trouver un bout de code qui devrais te servir

      package flaxbeard.dynamite.entity;
      import cpw.mods.fml.common.network.PacketDispatcher;
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      import java.io.ByteArrayOutputStream;
      import java.io.DataOutputStream;
      import java.util.List;
      import flaxbeard.dynamite.DynamiteMod;
      import net.minecraft.block.Block;
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.EntityLiving;
      import net.minecraft.entity.IProjectile;
      import net.minecraft.entity.item.EntityItem;
      import net.minecraft.entity.monster.EntityBlaze;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.entity.projectile.EntityThrowable;
      import net.minecraft.item.ItemStack;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.network.packet.Packet250CustomPayload;
      import net.minecraft.util.AxisAlignedBB;
      import net.minecraft.util.DamageSource;
      import net.minecraft.util.EnumMovingObjectType;
      import net.minecraft.util.MathHelper;
      import net.minecraft.util.MovingObjectPosition;
      import net.minecraft.util.Vec3;
      import net.minecraft.world.World;
      public class EntityDynamite extends EntityThrowable
      {
      boolean stopped = false;
      boolean bounce = false;
      public int type = 0;
      int fuse;
      public EntityDynamite(World par1World) {
      super(par1World);
      }
      public EntityDynamite(World par1World, double x, double y, double z, float yaw, float pitch, double force, int fuseLength, int ty) {
      super(par1World);
      this.setRotation(yaw, 0);
      System.out.println(yaw);
      System.out.println(pitch);
      double xHeading = -MathHelper.sin((yaw * 3.141593F) / 180F);
      double zHeading = MathHelper.cos((yaw * 3.141593F) / 180F);
      motionX = force*xHeading*MathHelper.cos((pitch / 180F) * 3.141593F);
      motionY = -force*MathHelper.sin((pitch / 180F) * 3.141593F);
      motionZ = force*zHeading*MathHelper.cos((pitch / 180F) * 3.141593F);
      setPosition(x+xHeading*0.8, y+1.5, z+zHeading*0.8);
      prevPosX = posX;
      prevPosY = posY;
      prevPosZ = posZ;
      fuse = fuseLength;
      type = ty;
      System.out.println(type);
      }
      public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
      {
      return false;
      }
      public EntityDynamite(World world, Entity entity, double force, int ty)
      {
      this(world, entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch, force, 50, ty);
      }
      public void onUpdate()
      {
      if(fuse-- <= 0)
      {
      if (!worldObj.isRemote) {
      worldObj.createExplosion(null, posX, posY, posZ, 2.0F, true);
      this.setDead();
      }
      }
      if(stopped && !worldObj.isRemote) {
      ByteArrayOutputStream bos = new ByteArrayOutputStream(7);
      DataOutputStream outputStream = new DataOutputStream(bos);
      try
      {
      outputStream.writeByte(1);
      outputStream.writeInt(this.entityId);
      outputStream.writeInt((int) posX);
      outputStream.writeInt((int) posY);
      outputStream.writeInt((int) posZ);
      }
      catch (Exception ex)
      {
      ex.printStackTrace();
      }
      Packet250CustomPayload packet = new Packet250CustomPayload();
      packet.channel = "DynamiteMod";
      packet.data = bos.toByteArray();
      packet.length = bos.size();
      PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 50, worldObj.provider.dimensionId, packet);
      }
      if(!(stopped))
      {
      double prevVelX = motionX;
      double prevVelY = motionY;
      double prevVelZ = motionZ;
      prevPosX = posX;
      prevPosY = posY;
      prevPosZ = posZ;
      moveEntity(motionX, motionY, motionZ);
      boolean collided = false;
      if(motionX!=prevVelX)
      {
      if (type == 1) {
      stopped = true;
      motionX = 0;
      motionY = 0;
      motionZ = 0;
      }
      else
      {
      motionX = -0.5*prevVelX;
      collided = true;
      }
      }
      if(motionZ!=prevVelZ)
      {
      if (type == 1) {
      stopped = true;
      motionX = 0;
      motionY = 0;
      motionZ = 0;
      }
      else
      {
      motionZ = -0.5*prevVelZ;
      }
      }
      if(motionY!=prevVelY)
      {
      if (type == 1) {
      stopped = true;
      motionX = 0;
      motionY = 0;
      motionZ = 0;
      }
      else
      {
      motionY = -prevVelY;
      collided = true;
      }
      }
      else
      {
      motionY -= 0.04;
      }
      if(collided)
      {
      motionX *= 0.5;
      motionY *= 0.1;
      motionZ *= 0.5;
      }
      motionX *= 0.99;
      motionY *= 0.99;
      motionZ *= 0.99;
      System.out.println(Boolean.toString(worldObj.isRemote) + Integer.toString(entityId));
      if(onGround && (motionX*motionX+motionY*motionY+motionZ*motionZ)<0.02)
      {
      stopped = true;
      motionX = 0;
      motionY = 0;
      motionZ = 0;
      }
      }
      }
      @Override
      protected void onImpact(MovingObjectPosition movingobjectposition) {
      // TODO Auto-generated method stub
      }
      public void stop(int x, int y, int z) {
      stopped = true;
      this.posX = x;
      this.posY = y;
      this.posZ = z;
      System.out.println("i trai to stop but i fal.");
      }
      }
      1 réponse Dernière réponse Répondre Citer 0
      • John_71
        John_71 dernière édition par 1 sept. 2019, 15:16

        Par hasard, est-ce-que EntityThrowable extends Entity ?
        Si c’est le cas, tu as juste à faire un extends EntityThrowable !

        • Maintient des mods et modpacks en `1.18.2`
        • Je suis un membre apprécié et joueur, j'ai déjà obtenu 2 points de réputation.

        1 réponse Dernière réponse Répondre Citer 0
        • D
          Drastic dernière édition par 1 sept. 2019, 15:21

          oui mais si je met

          private void explode()
                      {
                          float f = 4.0F;
                          this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true);
                      }
          

          ca me met une erreur : the method explode is undefined for the type “maclasse”

          package com.extremium.mod.entity;
          import net.minecraft.entity.Entity;
          import net.minecraft.entity.EntityLivingBase;
          import net.minecraft.entity.monster.EntityBlaze;
          import net.minecraft.entity.projectile.EntityThrowable;
          import net.minecraft.util.DamageSource;
          import net.minecraft.util.MovingObjectPosition;
          import net.minecraft.world.World;
          public class DynamiteEntity extends EntityThrowable
          {
          private static final String __OBFID = "CL_00001722";
          public DynamiteEntity(World p_i1773_1_)
          {
          super(p_i1773_1_);
          }
          public DynamiteEntity(World p_i1774_1_, EntityLivingBase p_i1774_2_)
          {
          super(p_i1774_1_, p_i1774_2_);
          }
          public DynamiteEntity(World p_i1775_1_, double p_i1775_2_, double p_i1775_4_, double p_i1775_6_)
          {
          super(p_i1775_1_, p_i1775_2_, p_i1775_4_, p_i1775_6_);
          }
          /**
          * Called when this EntityThrowable hits a block or entity.
          */
          protected void onImpact(MovingObjectPosition p_70184_1_)
          {
          if (p_70184_1_.entityHit != null)
          {
          byte b0 = 0;
          if (p_70184_1_.entityHit instanceof EntityBlaze)
          {
          b0 = 3;
          }
          p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)b0);
          private void explode()
          {
          float f = 4.0F;
          this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true);
          }
          }
          for (int i = 0; i < 8; ++i)
          {
          }
          if (!this.worldObj.isRemote)
          {
          this.setDead();
          }
          }
          }
          1 réponse Dernière réponse Répondre Citer 0
          • John_71
            John_71 dernière édition par 1 sept. 2019, 15:25

            Ton

            private void explode()
            {
                float f = 4.0F;
                this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true);
            }
            

            est mal placé (déjà dans une méthode de ta classe).
            Il n’y a pas une méthode qui fait la même chose et que tu pourrais appeler à la place ?

            • Maintient des mods et modpacks en `1.18.2`
            • Je suis un membre apprécié et joueur, j'ai déjà obtenu 2 points de réputation.

            1 réponse Dernière réponse Répondre Citer 1
            • Heaven
              Heaven dernière édition par 1 sept. 2019, 15:28

              tu pourrais peut être regarder dans la classe de la Tnt ?

              1 réponse Dernière réponse Répondre Citer 1
              • D
                Drastic dernière édition par 1 sept. 2019, 15:39

                alors en fait g mis le explode alors que pas besoin. par contre, comment régler la taille de l’explosion ?

                1 réponse Dernière réponse Répondre Citer 0
                • Heaven
                  Heaven dernière édition par Heaven 1 sept. 2019, 15:43 1 sept. 2019, 15:40

                  et bien il faut voir dans la classe de la Tnt
                  je ne suis pas sur mais cette méthode peut etre utile

                  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)
                  {
                  EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(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);
                  }
                  }
                  1 réponse Dernière réponse Répondre Citer 1
                  • D
                    Drastic dernière édition par 1 sept. 2019, 15:43

                    oui mais je netrouve pas 😞

                    1 réponse Dernière réponse Répondre Citer 0
                    • Heaven
                      Heaven dernière édition par 1 sept. 2019, 15:44

                      je viens de te donner la soluce (peut etre)

                      D 1 réponse Dernière réponse 1 sept. 2019, 15:46 Répondre Citer 1
                      • D
                        Drastic @Heaven dernière édition par 1 sept. 2019, 15:46

                        @Heaven malheureusement la soluce n’y est pas

                        1 réponse Dernière réponse Répondre Citer 0
                        • Heaven
                          Heaven dernière édition par Heaven 1 sept. 2019, 15:53 1 sept. 2019, 15:47

                          ok j ai trouver un bout de code qui devrais te servir

                          package flaxbeard.dynamite.entity;
                          import cpw.mods.fml.common.network.PacketDispatcher;
                          import cpw.mods.fml.relauncher.Side;
                          import cpw.mods.fml.relauncher.SideOnly;
                          import java.io.ByteArrayOutputStream;
                          import java.io.DataOutputStream;
                          import java.util.List;
                          import flaxbeard.dynamite.DynamiteMod;
                          import net.minecraft.block.Block;
                          import net.minecraft.entity.Entity;
                          import net.minecraft.entity.EntityLiving;
                          import net.minecraft.entity.IProjectile;
                          import net.minecraft.entity.item.EntityItem;
                          import net.minecraft.entity.monster.EntityBlaze;
                          import net.minecraft.entity.player.EntityPlayer;
                          import net.minecraft.entity.projectile.EntityThrowable;
                          import net.minecraft.item.ItemStack;
                          import net.minecraft.nbt.NBTTagCompound;
                          import net.minecraft.network.packet.Packet250CustomPayload;
                          import net.minecraft.util.AxisAlignedBB;
                          import net.minecraft.util.DamageSource;
                          import net.minecraft.util.EnumMovingObjectType;
                          import net.minecraft.util.MathHelper;
                          import net.minecraft.util.MovingObjectPosition;
                          import net.minecraft.util.Vec3;
                          import net.minecraft.world.World;
                          public class EntityDynamite extends EntityThrowable
                          {
                          boolean stopped = false;
                          boolean bounce = false;
                          public int type = 0;
                          int fuse;
                          public EntityDynamite(World par1World) {
                          super(par1World);
                          }
                          public EntityDynamite(World par1World, double x, double y, double z, float yaw, float pitch, double force, int fuseLength, int ty) {
                          super(par1World);
                          this.setRotation(yaw, 0);
                          System.out.println(yaw);
                          System.out.println(pitch);
                          double xHeading = -MathHelper.sin((yaw * 3.141593F) / 180F);
                          double zHeading = MathHelper.cos((yaw * 3.141593F) / 180F);
                          motionX = force*xHeading*MathHelper.cos((pitch / 180F) * 3.141593F);
                          motionY = -force*MathHelper.sin((pitch / 180F) * 3.141593F);
                          motionZ = force*zHeading*MathHelper.cos((pitch / 180F) * 3.141593F);
                          setPosition(x+xHeading*0.8, y+1.5, z+zHeading*0.8);
                          prevPosX = posX;
                          prevPosY = posY;
                          prevPosZ = posZ;
                          fuse = fuseLength;
                          type = ty;
                          System.out.println(type);
                          }
                          public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
                          {
                          return false;
                          }
                          public EntityDynamite(World world, Entity entity, double force, int ty)
                          {
                          this(world, entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch, force, 50, ty);
                          }
                          public void onUpdate()
                          {
                          if(fuse-- <= 0)
                          {
                          if (!worldObj.isRemote) {
                          worldObj.createExplosion(null, posX, posY, posZ, 2.0F, true);
                          this.setDead();
                          }
                          }
                          if(stopped && !worldObj.isRemote) {
                          ByteArrayOutputStream bos = new ByteArrayOutputStream(7);
                          DataOutputStream outputStream = new DataOutputStream(bos);
                          try
                          {
                          outputStream.writeByte(1);
                          outputStream.writeInt(this.entityId);
                          outputStream.writeInt((int) posX);
                          outputStream.writeInt((int) posY);
                          outputStream.writeInt((int) posZ);
                          }
                          catch (Exception ex)
                          {
                          ex.printStackTrace();
                          }
                          Packet250CustomPayload packet = new Packet250CustomPayload();
                          packet.channel = "DynamiteMod";
                          packet.data = bos.toByteArray();
                          packet.length = bos.size();
                          PacketDispatcher.sendPacketToAllAround(posX, posY, posZ, 50, worldObj.provider.dimensionId, packet);
                          }
                          if(!(stopped))
                          {
                          double prevVelX = motionX;
                          double prevVelY = motionY;
                          double prevVelZ = motionZ;
                          prevPosX = posX;
                          prevPosY = posY;
                          prevPosZ = posZ;
                          moveEntity(motionX, motionY, motionZ);
                          boolean collided = false;
                          if(motionX!=prevVelX)
                          {
                          if (type == 1) {
                          stopped = true;
                          motionX = 0;
                          motionY = 0;
                          motionZ = 0;
                          }
                          else
                          {
                          motionX = -0.5*prevVelX;
                          collided = true;
                          }
                          }
                          if(motionZ!=prevVelZ)
                          {
                          if (type == 1) {
                          stopped = true;
                          motionX = 0;
                          motionY = 0;
                          motionZ = 0;
                          }
                          else
                          {
                          motionZ = -0.5*prevVelZ;
                          }
                          }
                          if(motionY!=prevVelY)
                          {
                          if (type == 1) {
                          stopped = true;
                          motionX = 0;
                          motionY = 0;
                          motionZ = 0;
                          }
                          else
                          {
                          motionY = -prevVelY;
                          collided = true;
                          }
                          }
                          else
                          {
                          motionY -= 0.04;
                          }
                          if(collided)
                          {
                          motionX *= 0.5;
                          motionY *= 0.1;
                          motionZ *= 0.5;
                          }
                          motionX *= 0.99;
                          motionY *= 0.99;
                          motionZ *= 0.99;
                          System.out.println(Boolean.toString(worldObj.isRemote) + Integer.toString(entityId));
                          if(onGround && (motionX*motionX+motionY*motionY+motionZ*motionZ)<0.02)
                          {
                          stopped = true;
                          motionX = 0;
                          motionY = 0;
                          motionZ = 0;
                          }
                          }
                          }
                          @Override
                          protected void onImpact(MovingObjectPosition movingobjectposition) {
                          // TODO Auto-generated method stub
                          }
                          public void stop(int x, int y, int z) {
                          stopped = true;
                          this.posX = x;
                          this.posY = y;
                          this.posZ = z;
                          System.out.println("i trai to stop but i fal.");
                          }
                          }
                          1 réponse Dernière réponse Répondre Citer 0
                          • D
                            Drastic dernière édition par 1 sept. 2019, 16:57

                            merci, mais je ne sais toujours pas comment faire pour mettre un model + texture

                            1 réponse Dernière réponse Répondre Citer 0
                            • Heaven
                              Heaven dernière édition par 1 sept. 2019, 16:58

                              la je ne pourrais pas t aider demande sur le discorde ou regarde dans la classe de le boule de neige jsp

                              D 1 réponse Dernière réponse 1 sept. 2019, 17:01 Répondre Citer 0
                              • D
                                Drastic @Heaven dernière édition par 1 sept. 2019, 17:01

                                @Heaven merci

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

                                MINECRAFT FORGE FRANCE © 2018

                                Powered by NodeBB