MFF

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

    Quelques bugs sur mes mobs

    Planifier Épinglé Verrouillé Déplacé Sans suite
    1.8
    22 Messages 4 Publieurs 4.7k 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.
    • FlowF Hors-ligne
      Flow
      dernière édition par

      Pourquoi créer tu un mob pour ta balle Oo En 1.8 c’est comme ca ? perso voici mes classe pour mon arc en 1.7.x je sais pas si ca peut t’aider

      EntityFlechette

      
      package mod.common.entity;
      
      import java.util.List;
      
      import mod.common.item.ItemRegister;
      import net.minecraft.block.Block;
      import net.minecraft.block.material.Material;
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.EntityLivingBase;
      import net.minecraft.entity.IProjectile;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.item.ItemStack;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.potion.Potion;
      import net.minecraft.potion.PotionEffect;
      import net.minecraft.util.AxisAlignedBB;
      import net.minecraft.util.MathHelper;
      import net.minecraft.util.MovingObjectPosition;
      import net.minecraft.util.Vec3;
      import net.minecraft.world.World;
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      
      public class EntityFlechette extends Entity
       implements IProjectile
      {
       private int field_145791_d = -1;
       private int field_145792_e = -1;
       private int field_145789_f = -1;
       private Block field_145790_g;
       private int inData;
       private boolean inGround;
       public int canBePickedUp;
       public int arrowShake;
       public Entity shootingEntity;
       private int ticksInGround;
       private int ticksInAir;
       private double damage = 2.0D;
       private int knockbackStrength;
      
       public EntityFlechette(World par1World)
       {
         super(par1World);
         this.renderDistanceWeight = 10.0D;
         setSize(0.5F, 0.5F);
       }
      
       public EntityFlechette(World par1World, double par2, double par4, double par6)
       {
         super(par1World);
         this.renderDistanceWeight = 10.0D;
         setSize(0.5F, 0.5F);
         setPosition(par2, par4, par6);
         this.yOffset = 0.0F;
       }
      
       public EntityFlechette(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, float par4, float par5)
       {
         super(par1World);
         this.renderDistanceWeight = 10.0D;
         this.shootingEntity = par2EntityLivingBase;
      
         if ((par2EntityLivingBase instanceof EntityPlayer))
         {
           this.canBePickedUp = 1;
         }
      
         this.posY = (par2EntityLivingBase.posY + par2EntityLivingBase.getEyeHeight() - 0.1000000014901161D);
         double d0 = par3EntityLivingBase.posX - par2EntityLivingBase.posX;
         double d1 = par3EntityLivingBase.boundingBox.minY + par3EntityLivingBase.height / 3.0F - this.posY;
         double d2 = par3EntityLivingBase.posZ - par2EntityLivingBase.posZ;
         double d3 = MathHelper.sqrt_double(d0 * d0 + d2 * d2);
      
         if (d3 >= 1.0E-007D)
         {
           float f2 = (float)(Math.atan2(d2, d0) * 180.0D / 3.141592653589793D) - 90.0F;
           float f3 = (float)-(Math.atan2(d1, d3) * 180.0D / 3.141592653589793D);
           double d4 = d0 / d3;
           double d5 = d2 / d3;
           setLocationAndAngles(par2EntityLivingBase.posX + d4, this.posY, par2EntityLivingBase.posZ + d5, f2, f3);
           this.yOffset = 0.0F;
           float f4 = (float)d3 * 0.2F;
           setThrowableHeading(d0, d1 + f4, d2, par4, par5);
         }
       }
      
       public EntityFlechette(World par1World, EntityLivingBase par2EntityLivingBase, float par3)
       {
         super(par1World);
         this.renderDistanceWeight = 10.0D;
         this.shootingEntity = par2EntityLivingBase;
      
         if ((par2EntityLivingBase instanceof EntityPlayer))
         {
           this.canBePickedUp = 1;
         }
      
         setSize(0.5F, 0.5F);
         setLocationAndAngles(par2EntityLivingBase.posX, par2EntityLivingBase.posY + par2EntityLivingBase.getEyeHeight(), par2EntityLivingBase.posZ, par2EntityLivingBase.rotationYaw, par2EntityLivingBase.rotationPitch);
         this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * 3.141593F) * 0.16F;
         this.posY -= 0.1000000014901161D;
         this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * 3.141593F) * 0.16F;
         setPosition(this.posX, this.posY, this.posZ);
         this.yOffset = 0.0F;
         this.motionX = (-MathHelper.sin(this.rotationYaw / 180.0F * 3.141593F) * MathHelper.cos(this.rotationPitch / 180.0F * 3.141593F));
         this.motionZ = (MathHelper.cos(this.rotationYaw / 180.0F * 3.141593F) * MathHelper.cos(this.rotationPitch / 180.0F * 3.141593F));
         this.motionY = (-MathHelper.sin(this.rotationPitch / 180.0F * 3.141593F));
         setThrowableHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F);
       }
      
       protected void entityInit()
       {
         this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
       }
      
       public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8)
       {
         float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5);
         par1 /= f2;
         par3 /= f2;
         par5 /= f2;
         par1 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8;
         par3 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8;
         par5 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8;
         par1 *= par7;
         par3 *= par7;
         par5 *= par7;
         this.motionX = par1;
         this.motionY = par3;
         this.motionZ = par5;
         float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
         this.prevRotationYaw = (this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / 3.141592653589793D));
         this.prevRotationPitch = (this.rotationPitch = (float)(Math.atan2(par3, f3) * 180.0D / 3.141592653589793D));
         this.ticksInGround = 0;
       }
      
       @SideOnly(Side.CLIENT)
       public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9)
       {
         setPosition(par1, par3, par5);
         setRotation(par7, par8);
       }
      
       @SideOnly(Side.CLIENT)
       public void setVelocity(double par1, double par3, double par5)
       {
         this.motionX = par1;
         this.motionY = par3;
         this.motionZ = par5;
      
         if ((this.prevRotationPitch == 0.0F) && (this.prevRotationYaw == 0.0F))
         {
           float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
           this.prevRotationYaw = (this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / 3.141592653589793D));
           this.prevRotationPitch = (this.rotationPitch = (float)(Math.atan2(par3, f) * 180.0D / 3.141592653589793D));
           this.prevRotationPitch = this.rotationPitch;
           this.prevRotationYaw = this.rotationYaw;
           setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
           this.ticksInGround = 0;
         }
       }
      
       public void onUpdate()
       {
         super.onUpdate();
      
         if ((this.prevRotationPitch == 0.0F) && (this.prevRotationYaw == 0.0F))
         {
           float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
           this.prevRotationYaw = (this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / 3.141592653589793D));
           this.prevRotationPitch = (this.rotationPitch = (float)(Math.atan2(this.motionY, f) * 180.0D / 3.141592653589793D));
         }
      
         Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
      
         if (block.getMaterial() != Material.air)
         {
           block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
           AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
      
           if ((axisalignedbb != null) && (axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))))
           {
             this.inGround = true;
           }
         }
      
         if (this.arrowShake > 0)
         {
           this.arrowShake -= 1;
         }
      
         if (this.inGround)
         {
           int j = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
      
           if ((block == this.field_145790_g) && (j == this.inData))
           {
             this.ticksInGround += 1;
      
             if (this.ticksInGround == 1200)
             {
               setDead();
             }
           }
           else
           {
             this.inGround = false;
             this.motionX *= this.rand.nextFloat() * 0.2F;
             this.motionY *= this.rand.nextFloat() * 0.2F;
             this.motionZ *= this.rand.nextFloat() * 0.2F;
             this.ticksInGround = 0;
             this.ticksInAir = 0;
           }
         }
         else
         {
           this.ticksInAir += 1;
           Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
           Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
           MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false);
           vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
           vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      
           if (movingobjectposition != null)
           {
             vec3 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
           }
      
           Entity entity = null;
           List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
           double d0 = 0.0D;
      
           for (int i = 0; i < list.size(); i++)
           {
             Entity entity1 = (Entity)list.get(i);
      
             if ((entity1.canBeCollidedWith()) && ((entity1 != this.shootingEntity) || (this.ticksInAir >= 5)))
             {
               float f1 = 0.3F;
               AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1);
               MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3);
      
               if (movingobjectposition1 != null)
               {
                 double d1 = vec31.distanceTo(movingobjectposition1.hitVec);
      
                 if ((d1 < d0) || (d0 == 0.0D))
                 {
                   entity = entity1;
                   d0 = d1;
                 }
               }
             }
           }
      
           if (entity != null)
           {
             movingobjectposition = new MovingObjectPosition(entity);
           }
      
           if ((movingobjectposition != null) && (movingobjectposition.entityHit != null) && ((movingobjectposition.entityHit instanceof EntityPlayer)))
           {
             EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit;
      
             if ((entityplayer.capabilities.disableDamage) || (((this.shootingEntity instanceof EntityPlayer)) && (!((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer))))
             {
               movingobjectposition = null;
             }
      
           }
      
           if (movingobjectposition != null)
           {
             if (movingobjectposition.entityHit != null)
             {
               float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
               int k = MathHelper.ceiling_double_int(f2 * this.damage);
      
               if (getIsCritical())
               {
                 k += this.rand.nextInt(k / 2 + 2);
               }
      
               if (((movingobjectposition.entityHit instanceof EntityLivingBase)) && (!this.worldObj.isRemote))
               {
                 ((EntityLivingBase)movingobjectposition.entityHit).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 1369, 99999999));
               }
             }
             else
             {
               this.field_145791_d = movingobjectposition.blockX;
               this.field_145792_e = movingobjectposition.blockY;
               this.field_145789_f = movingobjectposition.blockZ;
               this.field_145790_g = block;
               this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
               this.motionX = ((float)(movingobjectposition.hitVec.xCoord - this.posX));
               this.motionY = ((float)(movingobjectposition.hitVec.yCoord - this.posY));
               this.motionZ = ((float)(movingobjectposition.hitVec.zCoord - this.posZ));
               float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
               this.posX -= this.motionX / f2 * 0.0500000007450581D;
               this.posY -= this.motionY / f2 * 0.0500000007450581D;
               this.posZ -= this.motionZ / f2 * 0.0500000007450581D;
               playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
               this.inGround = true;
               this.arrowShake = 7;
               setIsCritical(false);
      
               if (this.field_145790_g.getMaterial() != Material.air)
               {
                 this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
               }
             }
           }
           if (getIsCritical())
           {
             for (int i = 0; i < 4; i++)
             {
               this.worldObj.spawnParticle("crit", this.posX + this.motionX * i / 4.0D, this.posY + this.motionY * i / 4.0D, this.posZ + this.motionZ * i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ);
             }
           }
      
           this.posX += this.motionX;
           this.posY += this.motionY;
           this.posZ += this.motionZ;
           float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
           this.rotationYaw = ((float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / 3.141592653589793D));
      
           for (this.rotationPitch = ((float)(Math.atan2(this.motionY, f2) * 180.0D / 3.141592653589793D)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F);
           while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
           {
             this.prevRotationPitch += 360.0F;
           }
      
           while (this.rotationYaw - this.prevRotationYaw < -180.0F)
           {
             this.prevRotationYaw -= 360.0F;
           }
      
           while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
           {
             this.prevRotationYaw += 360.0F;
           }
      
           this.rotationPitch = (this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F);
           this.rotationYaw = (this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F);
           float f3 = 0.99F;
           float f1 = 0.05F;
      
           if (isInWater())
           {
             for (int l = 0; l < 4; l++)
             {
               float f4 = 0.25F;
               this.worldObj.spawnParticle("bubble", this.posX - this.motionX * f4, this.posY - this.motionY * f4, this.posZ - this.motionZ * f4, this.motionX, this.motionY, this.motionZ);
             }
      
             f3 = 0.8F;
           }
      
           if (isWet())
           {
             extinguish();
           }
      
           this.motionX *= f3;
           this.motionY *= f3;
           this.motionZ *= f3;
           this.motionY -= f1;
           setPosition(this.posX, this.posY, this.posZ);
           func_145775_I();
         }
       }
      
       public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
       {
         par1NBTTagCompound.setShort("xTile", (short)this.field_145791_d);
         par1NBTTagCompound.setShort("yTile", (short)this.field_145792_e);
         par1NBTTagCompound.setShort("zTile", (short)this.field_145789_f);
         par1NBTTagCompound.setShort("life", (short)this.ticksInGround);
         par1NBTTagCompound.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145790_g));
         par1NBTTagCompound.setByte("inData", (byte)this.inData);
         par1NBTTagCompound.setByte("shake", (byte)this.arrowShake);
         par1NBTTagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
         par1NBTTagCompound.setByte("pickup", (byte)this.canBePickedUp);
         par1NBTTagCompound.setDouble("damage", this.damage);
       }
      
       public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
       {
         this.field_145791_d = par1NBTTagCompound.getShort("xTile");
         this.field_145792_e = par1NBTTagCompound.getShort("yTile");
         this.field_145789_f = par1NBTTagCompound.getShort("zTile");
         this.ticksInGround = par1NBTTagCompound.getShort("life");
         this.field_145790_g = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 0xFF);
         this.inData = (par1NBTTagCompound.getByte("inData") & 0xFF);
         this.arrowShake = (par1NBTTagCompound.getByte("shake") & 0xFF);
         this.inGround = (par1NBTTagCompound.getByte("inGround") == 1);
      
         if (par1NBTTagCompound.hasKey("damage", 99))
         {
           this.damage = par1NBTTagCompound.getDouble("damage");
         }
      
         if (par1NBTTagCompound.hasKey("pickup", 99))
         {
           this.canBePickedUp = par1NBTTagCompound.getByte("pickup");
         }
         else if (par1NBTTagCompound.hasKey("player", 99))
         {
           this.canBePickedUp = (par1NBTTagCompound.getBoolean("player") ? 1 : 0);
         }
       }
      
       public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)
       {
         if ((!this.worldObj.isRemote) && (this.inGround) && (this.arrowShake <= 0))
         {
           boolean flag = (this.canBePickedUp == 1) || ((this.canBePickedUp == 2) && (par1EntityPlayer.capabilities.isCreativeMode));
      
           if ((this.canBePickedUp == 1) && (!par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ItemRegister.itemFlechetteEmpty, 1))))
           {
             flag = false;
           }
      
           if (flag)
           {
             playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
             par1EntityPlayer.onItemPickup(this, 1);
             setDead();
           }
         }
       }
      
       protected boolean canTriggerWalking()
       {
         return false;
       }
      
       @SideOnly(Side.CLIENT)
       public float getShadowSize()
       {
         return 0.0F;
       }
      
       public void setDamage(double par1)
       {
         this.damage = par1;
       }
      
       public double getDamage()
       {
         return this.damage;
       }
      
       public void setIsCritical(boolean par1)
       {
         byte b0 = this.dataWatcher.getWatchableObjectByte(16);
      
         if (par1)
         {
           this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 0x1)));
         }
         else
         {
           this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & 0xFFFFFFFE)));
         }
       }
      
       public boolean getIsCritical()
       {
         byte b0 = this.dataWatcher.getWatchableObjectByte(16);
         return (b0 & 0x1) != 0;
       }
      }
      

      SarbacanneItem ( je sais le nom de classe est a modifier )

      
      package mod.common.item;
      
      import mod.common.entity.EntityFlechette;
      import net.minecraft.client.renderer.texture.IIconRegister;
      import net.minecraft.creativetab.CreativeTabs;
      import net.minecraft.enchantment.Enchantment;
      import net.minecraft.enchantment.EnchantmentHelper;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.item.EnumAction;
      import net.minecraft.item.Item;
      import net.minecraft.item.ItemStack;
      import net.minecraft.util.IIcon;
      import net.minecraft.world.World;
      import net.minecraftforge.common.MinecraftForge;
      import net.minecraftforge.event.entity.player.ArrowLooseEvent;
      import net.minecraftforge.event.entity.player.ArrowNockEvent;
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      
      public class SarbacaneItem extends Item
      {
      
       @SideOnly(Side.CLIENT)
       private IIcon[] iconArray;
      
       public SarbacaneItem()
       {
         this.maxStackSize = 1;
         setMaxDamage(38444);
         setCreativeTab(CreativeTabs.tabCombat);
       }
      
       public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
       {
         int j = getMaxItemUseDuration(par1ItemStack) - par4;
      
         ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, j);
         MinecraftForge.EVENT_BUS.post(event);
         if (event.isCanceled())
         {
           return;
         }
         j = event.charge;
      
         boolean flag = (par3EntityPlayer.capabilities.isCreativeMode) || (EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0);
      
         if ((flag) || (par3EntityPlayer.inventory.hasItem(ItemRegister.itemFlechette)))
         {
           float f = j / 20.0F;
           f = (f * f + f * 2.0F) / 3.0F;
      
           if (f < 0.1D)
           {
             return;
           }
      
           if (f > 1.0F)
           {
             f = 1.0F;
           }
      
           EntityFlechette entityflechette = new EntityFlechette(par2World, par3EntityPlayer, f * 2.0F);
      
           if (f == 1.0F)
           {
             entityflechette.setIsCritical(true);
           }
      
           par1ItemStack.damageItem(1, par3EntityPlayer);
           par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
      
           if (flag)
           {
             entityflechette.canBePickedUp = 2;
           }
           else
           {
             par3EntityPlayer.inventory.consumeInventoryItem(ItemRegister.itemFlechette);
           }
      
           if (!par2World.isRemote)
           {
             par2World.spawnEntityInWorld(entityflechette);
           }
         }
       }
      
       public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
       {
         return par1ItemStack;
       }
      
       public int getMaxItemUseDuration(ItemStack par1ItemStack)
       {
         return 72000;
       }
      
       public EnumAction getItemUseAction(ItemStack par1ItemStack)
       {
         return EnumAction.bow;
       }
      
       public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
       {
         ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack);
         MinecraftForge.EVENT_BUS.post(event);
         if (event.isCanceled())
         {
           return event.result;
         }
      
         if ((par3EntityPlayer.capabilities.isCreativeMode) || (par3EntityPlayer.inventory.hasItem(ItemRegister.itemFlechette)))
         {
           par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
         }
      
         return par1ItemStack;
       }
      
       @SideOnly(Side.CLIENT)
       public void registerIcons(IIconRegister iconregister)
       {
         this.itemIcon = iconregister.registerIcon("modminecraft:itemSarbacane");
       }
      
       @SideOnly(Side.CLIENT)
       public IIcon getItemIconForUseDuration(int par1)
       {
         return this.iconArray[par1];
       }
      }
      

      Oui ce gif est drôle.

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

        Je créer un mod Bullet, car un fusil qui tire une flèche… 😕
        Sinon, t’es classes ne m’aide pas beaucoup, mes armes à feu sont bien faites, c’ets juste les models qui déconnent, et la douille n’est pas affecté par la gravité

        Membre fantôme
        Je développe maintenant un jeu sur UnrealEngine4


        Contact :…

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

          @‘Eryah’:

          Je créer un mod Bullet, car un fusil qui tire une flèche… 😕

          *mob

          Et c’est pas des mobs que tu crées, mais des entités, d’où la confusion x)

          Mes mods :

          • Cookie Ore (1.7.10)

          Mod en cours : **E…

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

            muén pour moi Mob = Entité = Monstre, donc Sheep = Monstre, Poulet = Monstre, oui 🙂

            Membre fantôme
            Je développe maintenant un jeu sur UnrealEngine4


            Contact :…

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

              Donc pour toi une flèche c’est un monstre? ._.

              Mes mods :

              • Cookie Ore (1.7.10)

              Mod en cours : **E…

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

                Exactement !
                Nan, mais c’est juste que avant, ( vers la 1.8 Beta ), les animaux et tous étais plus rares, donc je croisais plus de monstres, mobs, Zombies, Creepers et tout. Et les flèches, pas grand monde savait ce que c’était réelement, je pensais pour ma part a un item modifié qui était jeté 🙂
                Bref, c’est resté, donc je dit toujours Mob pour les entités etc

                Membre fantôme
                Je développe maintenant un jeu sur UnrealEngine4


                Contact :…

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

                  Tu devrais t’habituer a dire entity car pour les gens qui corriges c’est pas DU TOUT logique xD Donc tes mobs sont des entitées donc ta Bullet est bien une entitée du coup ^^

                  Oui ce gif est drôle.

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

                    Oui, je confirme, c’est une entité 🙂
                    ( Quoique, j’hésite a faire de ma balle, un mob, genre quand tu tire, elle se retourne vers toit et te tue ( C’est une blague hein ))

                    Membre fantôme
                    Je développe maintenant un jeu sur UnrealEngine4


                    Contact :…

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

                      @‘Eryah’:

                      Oui, je confirme, c’est une entité 🙂
                      ( Quoique, j’hésite a faire de ma balle, un mob, genre quand tu tire, elle se retourne vers toit et te tue ( C’est une blague hein ))

                      Rigole pas la dernière fois , j’ai retournée l’entité Velociraptors a la place de la flechette jme suis fait buter du coup VDM xD.

                      Oui ce gif est drôle.

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

                        Je confirme, VDM xD

                        Membre fantôme
                        Je développe maintenant un jeu sur UnrealEngine4


                        Contact :…

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

                          Est-tu sûr que le rendu de ton model est bien appelé ? Rajoute des logs dans la fonction de render du model (dans la classe du model, pas celle du render). Pour ton entité qui ne supporte pas la gravité : si tu ne mets rien dans la fonction onUpdate ta balle risque pas de faire grand chose. Je te conseille d’aller voir le code de EntityThrowable (je te conseille de le recopier plutôt d’extends EntityThrowable, car (comme d’habitude) Mojang la codée avec les pieds : tout est en private).

                          Site web contenant mes scripts : http://SCAREXgaming.github.io

                          Pas de demandes de support par MP ni par skype SVP.
                          Je n'accepte sur skype que l…

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

                            Je ne veut pas extends mon entity bullet_casing EntityTrowable, car le rôle de l’entité est juste de tomber à tes pieds lors d’un tir (une douille quoi) et je ne vais pas me faire chier avec plein de.méthode inutile.

                            Sinon, mon ordinateur à décider.que.mon clavier écrivent plus, mais ouvrent les raccourcis. J’ai su le redémarrer, donc le print du modèle va devoir attendre

                            Envoyé de mon SM-G357FZ en utilisant Tapatalk

                            Membre fantôme
                            Je développe maintenant un jeu sur UnrealEngine4


                            Contact :…

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

                              Je n’ai pas dis d’extends EntityThrowable justement. Mais de recopier la classe pour la ré-écrire proprement. Histoire d’avoir une base solide (plus ou moins solide) sur laquelle démarrer.

                              Site web contenant mes scripts : http://SCAREXgaming.github.io

                              Pas de demandes de support par MP ni par skype SVP.
                              Je n'accepte sur skype que l…

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

                                Bon, je reprend ce topic, maintenant que je peut coder avec mon nouvel ordi
                                J’ai recopié la classe EntityThrowable, et la douille est maintenant entrainée par la gravité, mais passe a travers les blocs
                                j’ai tenté de mettre la gravité a 0 lors d’un contact bloc, rien n’y fait
                                Et mon entité Bullet n’a toujours pas son model, mais celui de la flèche

                                #Classe du render de la balle(Classe du render de la balle)

                                package eryah.usefulthings.client.render;
                                
                                import net.minecraft.client.Minecraft;
                                import net.minecraft.client.model.ModelBase;
                                import net.minecraft.client.renderer.GlStateManager;
                                import net.minecraft.client.renderer.Tessellator;
                                import net.minecraft.client.renderer.WorldRenderer;
                                import net.minecraft.client.renderer.entity.Render;
                                import net.minecraft.client.renderer.entity.RenderManager;
                                import net.minecraft.entity.Entity;
                                import net.minecraft.util.MathHelper;
                                import net.minecraft.util.ResourceLocation;
                                import net.minecraftforge.fml.relauncher.Side;
                                import net.minecraftforge.fml.relauncher.SideOnly;
                                
                                import org.lwjgl.opengl.GL11;
                                
                                import eryah.usefulthings.client.models.ModelBullet;
                                import eryah.usefulthings.entity.projectile.EBullet;
                                
                                @SideOnly(Side.CLIENT)
                                public class RenderBullet extends Render
                                {
                                    private static final ResourceLocation Textures = new ResourceLocation("ut:textures/entity/bullet.png");
                                    /** instance of ModelBoat for rendering */
                                    protected ModelBase modelBullet = new ModelBullet();
                                
                                    public RenderBullet(RenderManager p_i46193_1_, ModelBullet model, float shadow)
                                    {
                                        super(Minecraft.getMinecraft().getRenderManager());
                                    }
                                
                                    public void doRender(EBullet p_180551_1_, double p_180551_2_, double p_180551_4_, double p_180551_6_, float p_180551_8_, float p_180551_9_)
                                    {
                                        this.bindEntityTexture(p_180551_1_);
                                        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                                        GlStateManager.pushMatrix();
                                        GlStateManager.translate((float)p_180551_2_, (float)p_180551_4_, (float)p_180551_6_);
                                        GlStateManager.rotate(p_180551_1_.prevRotationYaw + (p_180551_1_.rotationYaw - p_180551_1_.prevRotationYaw) * p_180551_9_ - 90.0F, 0.0F, 1.0F, 0.0F);
                                        GlStateManager.rotate(p_180551_1_.prevRotationPitch + (p_180551_1_.rotationPitch - p_180551_1_.prevRotationPitch) * p_180551_9_, 0.0F, 0.0F, 1.0F);
                                        Tessellator tessellator = Tessellator.getInstance();
                                        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
                                        byte b0 = 0;
                                        float f2 = 0.0F;
                                        float f3 = 0.5F;
                                        float f4 = (float)(0 + b0 * 10) / 32.0F;
                                        float f5 = (float)(5 + b0 * 10) / 32.0F;
                                        float f6 = 0.0F;
                                        float f7 = 0.15625F;
                                        float f8 = (float)(5 + b0 * 10) / 32.0F;
                                        float f9 = (float)(10 + b0 * 10) / 32.0F;
                                        float f10 = 0.05625F;
                                        GlStateManager.enableRescaleNormal();
                                        float f11 = (float)p_180551_1_.arrowShake - p_180551_9_;
                                
                                        if (f11 > 0.0F)
                                        {
                                            float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
                                            GlStateManager.rotate(f12, 0.0F, 0.0F, 1.0F);
                                        }
                                
                                        GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F);
                                        GlStateManager.scale(f10, f10, f10);
                                        GlStateManager.translate(-4.0F, 0.0F, 0.0F);
                                        GL11.glNormal3f(f10, 0.0F, 0.0F);
                                        worldrenderer.startDrawingQuads();
                                        worldrenderer.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8);
                                        worldrenderer.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8);
                                        worldrenderer.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9);
                                        worldrenderer.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9);
                                        tessellator.draw();
                                        GL11.glNormal3f(-f10, 0.0F, 0.0F);
                                        worldrenderer.startDrawingQuads();
                                        worldrenderer.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8);
                                        worldrenderer.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8);
                                        worldrenderer.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9);
                                        worldrenderer.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9);
                                        tessellator.draw();
                                
                                        for (int i = 0; i < 4; ++i)
                                        {
                                            GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
                                            GL11.glNormal3f(0.0F, 0.0F, f10);
                                            worldrenderer.startDrawingQuads();
                                            worldrenderer.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4);
                                            worldrenderer.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4);
                                            worldrenderer.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5);
                                            worldrenderer.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5);
                                            tessellator.draw();
                                        }
                                
                                        GlStateManager.disableRescaleNormal();
                                        this.modelBullet.render(p_180551_1_, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
                                        GlStateManager.popMatrix();
                                
                                    }
                                
                                    protected ResourceLocation getEntityTexture(EBullet p_180550_1_)
                                    {
                                        return Textures;
                                    }
                                
                                    /**
                                     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
                                     */
                                    protected ResourceLocation getEntityTexture(Entity entity)
                                    {
                                        return this.getEntityTexture((EBullet)entity);
                                    }
                                
                                    /**
                                     * 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, double d1,
                                     * double d2, float f, float f1). But JAD is pre 1.5 so doe
                                     */
                                    public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float partialTicks)
                                    {
                                        this.doRender((EBullet)entity, x, y, z, p_76986_8_, partialTicks);
                                    }
                                }
                                

                                #Classe de la douille(Classe de la douille)

                                package eryah.usefulthings.entity.item;
                                
                                import java.util.List;
                                
                                import net.minecraft.block.Block;
                                import net.minecraft.entity.Entity;
                                import net.minecraft.entity.EntityLivingBase;
                                import net.minecraft.entity.player.EntityPlayer;
                                import net.minecraft.entity.projectile.EntityThrowable;
                                import net.minecraft.init.Blocks;
                                import net.minecraft.init.Items;
                                import net.minecraft.item.ItemStack;
                                import net.minecraft.nbt.NBTTagCompound;
                                import net.minecraft.util.AxisAlignedBB;
                                import net.minecraft.util.BlockPos;
                                import net.minecraft.util.EnumParticleTypes;
                                import net.minecraft.util.MathHelper;
                                import net.minecraft.util.MovingObjectPosition;
                                import net.minecraft.util.ResourceLocation;
                                import net.minecraft.util.Vec3;
                                import net.minecraft.world.World;
                                import net.minecraftforge.fml.relauncher.Side;
                                import net.minecraftforge.fml.relauncher.SideOnly;
                                
                                public class BulletCasing extends Entity{
                                
                                private int xTile = -1;
                                    private int yTile = -1;
                                    private int zTile = -1;
                                    private Block inTile;
                                    protected boolean inGround;
                                    public int throwableShake;
                                    /** The entity that threw this throwable item. */
                                    private EntityLivingBase thrower;
                                    private String throwerName;
                                    private int ticksInGround;
                                    private int ticksInAir;
                                    private static final String __OBFID = "CL_00001723";
                                
                                public BulletCasing(World worldIn)
                                    {
                                        super(worldIn);
                                
                                    }
                                
                                public void onCollideWithPlayer(EntityPlayer entityIn)
                                   {
                                               entityIn.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1));
                                               this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
                                               entityIn.onItemPickup(this, 1);
                                               this.setDead();            
                                   }
                                
                                @SideOnly(Side.CLIENT)
                                   public boolean isInRangeToRenderDist(double distance)
                                   {
                                       double d1 = this.getEntityBoundingBox().getAverageEdgeLength() * 4.0D;
                                       d1 *= 64.0D;
                                       return distance < d1 * d1;
                                   }
                                
                                   public BulletCasing(World worldIn, EntityLivingBase throwerIn)
                                   {
                                       super(worldIn);
                                       this.thrower = throwerIn;
                                       this.setSize(0.25F, 0.25F);
                                       this.setLocationAndAngles(throwerIn.posX, throwerIn.posY + (double)throwerIn.getEyeHeight(), throwerIn.posZ, throwerIn.rotationYaw, throwerIn.rotationPitch);
                                       this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
                                       this.posY -= 0.10000000149011612D;
                                       this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
                                       this.setPosition(this.posX, this.posY, this.posZ);
                                       float f = 0.4F;
                                       this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
                                       this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
                                       this.motionY = (double)(-MathHelper.sin((this.rotationPitch + this.getInaccuracy()) / 180.0F * (float)Math.PI) * f);
                                       this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, this.getVelocity(), 1.0F);
                                   }
                                
                                   public BulletCasing(World worldIn, double x, double y, double p_i1778_6_)
                                   {
                                       super(worldIn);
                                       this.ticksInGround = 0;
                                       this.setSize(0.25F, 0.25F);
                                       this.setPosition(x, y, p_i1778_6_);
                                   }
                                
                                   protected float getVelocity()
                                   {
                                       return 1.5F;
                                   }
                                
                                   protected float getInaccuracy()
                                   {
                                       return 0.0F;
                                   }
                                
                                   /**
                                    * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
                                    *  
                                    * @param inaccuracy Higher means more error.
                                    */
                                   public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy)
                                   {
                                       float f2 = MathHelper.sqrt_double(x * x + y * y + z * z);
                                       x /= (double)f2;
                                       y /= (double)f2;
                                       z /= (double)f2;
                                       x += this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
                                       y += this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
                                       z += this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
                                       x *= (double)velocity;
                                       y *= (double)velocity;
                                       z *= (double)velocity;
                                       this.motionX = x;
                                       this.motionY = y;
                                       this.motionZ = z;
                                       float f3 = MathHelper.sqrt_double(x * x + z * z);
                                       this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI);
                                       this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f3) * 180.0D / Math.PI);
                                       this.ticksInGround = 0;
                                   }
                                
                                   /**
                                    * Sets the velocity to the args. Args: x, y, z
                                    */
                                   @SideOnly(Side.CLIENT)
                                   public void setVelocity(double x, double y, double z)
                                   {
                                       this.motionX = x;
                                       this.motionY = y;
                                       this.motionZ = z;
                                
                                       if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
                                       {
                                           float f = MathHelper.sqrt_double(x * x + z * z);
                                           this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI);
                                           this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f) * 180.0D / Math.PI);
                                       }
                                   }
                                
                                   /**
                                    * Called to update the entity's position/logic.
                                    */
                                   public void onUpdate()
                                   {
                                       this.lastTickPosX = this.posX;
                                       this.lastTickPosY = this.posY;
                                       this.lastTickPosZ = this.posZ;
                                       super.onUpdate();
                                
                                       if (this.throwableShake > 0)
                                       {
                                           –this.throwableShake;
                                       }
                                
                                       if (this.inGround)
                                       {
                                           if (this.worldObj.getBlockState(new BlockPos(this.xTile, this.yTile, this.zTile)).getBlock() == this.inTile)
                                           {
                                               ++this.ticksInGround;
                                
                                               if (this.ticksInGround == 1200)
                                               {
                                                   this.setDead();
                                               }
                                
                                               return;
                                           }
                                
                                           this.inGround = false;
                                           this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
                                           this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
                                           this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
                                           this.ticksInGround = 0;
                                           this.ticksInAir = 0;
                                       }
                                       else
                                       {
                                           ++this.ticksInAir;
                                       }
                                
                                       Vec3 vec3 = new Vec3(this.posX, this.posY, this.posZ);
                                       Vec3 vec31 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
                                       MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec3, vec31);
                                       vec3 = new Vec3(this.posX, this.posY, this.posZ);
                                       vec31 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
                                
                                       if (movingobjectposition != null)
                                       {
                                           vec31 = new Vec3(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
                                       }
                                
                                       if (!this.worldObj.isRemote)
                                       {
                                           Entity entity = null;
                                           List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
                                           double d0 = 0.0D;
                                           EntityLivingBase entitylivingbase = this.getThrower();
                                
                                           for (int j = 0; j < list.size(); ++j)
                                           {
                                               Entity entity1 = (Entity)list.get(j);
                                
                                               if (entity1.canBeCollidedWith() && (entity1 != entitylivingbase || this.ticksInAir >= 5))
                                               {
                                                   float f = 0.3F;
                                                   AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand((double)f, (double)f, (double)f);
                                                   MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31);
                                
                                                   if (movingobjectposition1 != null)
                                                   {
                                                       double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
                                
                                                       if (d1 < d0 || d0 == 0.0D)
                                                       {
                                                           entity = entity1;
                                                           d0 = d1;
                                                       }
                                                   }
                                               }
                                           }
                                
                                           if (entity != null)
                                           {
                                               movingobjectposition = new MovingObjectPosition(entity);
                                           }
                                       }
                                
                                       if (movingobjectposition != null)
                                       {
                                           if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && this.worldObj.getBlockState(movingobjectposition.getBlockPos()).getBlock() == Blocks.portal)
                                           {
                                               this.setInPortal();
                                           }
                                           else
                                           {
                                               this.onImpact(movingobjectposition);
                                           }
                                       }
                                
                                       this.posX += this.motionX;
                                       this.posY += this.motionY;
                                       this.posZ += this.motionZ;
                                       float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
                                       this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
                                
                                       for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f1) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
                                       {
                                           ;
                                       }
                                
                                       while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
                                       {
                                           this.prevRotationPitch += 360.0F;
                                       }
                                
                                       while (this.rotationYaw - this.prevRotationYaw < -180.0F)
                                       {
                                           this.prevRotationYaw -= 360.0F;
                                       }
                                
                                       while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
                                       {
                                           this.prevRotationYaw += 360.0F;
                                       }
                                
                                       this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
                                       this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
                                       float f2 = 0.99F;
                                       float f3 = this.getGravityVelocity();
                                
                                       if (this.isInWater())
                                       {
                                           for (int i = 0; i < 4; ++i)
                                           {
                                               float f4 = 0.25F;
                                               this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ, new int[0]);
                                           }
                                
                                           f2 = 0.8F;
                                       }
                                
                                       this.motionX *= (double)f2;
                                       this.motionY *= (double)f2;
                                       this.motionZ *= (double)f2;
                                       this.motionY -= (double)f3;
                                       this.setPosition(this.posX, this.posY, this.posZ);
                                   }
                                
                                   /**
                                    * Gets the amount of gravity to apply to the thrown entity with each tick.
                                    */
                                   protected float getGravityVelocity()
                                   {
                                       return 0.03F;
                                   }
                                
                                   /**
                                    * Called when this EntityThrowable hits a block or entity.
                                    */
                                   protected void onImpact(MovingObjectPosition p_70184_1_) {
                                }
                                
                                   /**
                                    * (abstract) Protected helper method to write subclass entity data to NBT.
                                    */
                                   public void writeEntityToNBT(NBTTagCompound tagCompound)
                                   {
                                       tagCompound.setShort("xTile", (short)this.xTile);
                                       tagCompound.setShort("yTile", (short)this.yTile);
                                       tagCompound.setShort("zTile", (short)this.zTile);
                                       ResourceLocation resourcelocation = (ResourceLocation)Block.blockRegistry.getNameForObject(this.inTile);
                                       tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
                                       tagCompound.setByte("shake", (byte)this.throwableShake);
                                       tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
                                
                                       if ((this.throwerName == null || this.throwerName.length() == 0) && this.thrower instanceof EntityPlayer)
                                       {
                                           this.throwerName = this.thrower.getName();
                                       }
                                
                                       tagCompound.setString("ownerName", this.throwerName == null ? "" : this.throwerName);
                                   }
                                
                                   /**
                                    * (abstract) Protected helper method to read subclass entity data from NBT.
                                    */
                                   public void readEntityFromNBT(NBTTagCompound tagCompund)
                                   {
                                       this.xTile = tagCompund.getShort("xTile");
                                       this.yTile = tagCompund.getShort("yTile");
                                       this.zTile = tagCompund.getShort("zTile");
                                
                                       if (tagCompund.hasKey("inTile", 8))
                                       {
                                           this.inTile = Block.getBlockFromName(tagCompund.getString("inTile"));
                                       }
                                       else
                                       {
                                           this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255);
                                       }
                                
                                       this.throwableShake = tagCompund.getByte("shake") & 255;
                                       this.inGround = tagCompund.getByte("inGround") == 1;
                                       this.throwerName = tagCompund.getString("ownerName");
                                
                                       if (this.throwerName != null && this.throwerName.length() == 0)
                                       {
                                           this.throwerName = null;
                                       }
                                   }
                                
                                   public EntityLivingBase getThrower()
                                   {
                                       if (this.thrower == null && this.throwerName != null && this.throwerName.length() > 0)
                                       {
                                           this.thrower = this.worldObj.getPlayerEntityByName(this.throwerName);
                                       }
                                
                                       return this.thrower;
                                   }
                                
                                @Override
                                protected void entityInit() {
                                // TODO Auto-generated method stub
                                
                                }
                                
                                }
                                
                                

                                #Classe du render de la douille(Classe du render de la douille)

                                package eryah.usefulthings.client.render;
                                
                                import net.minecraft.client.Minecraft;
                                import net.minecraft.client.model.ModelBase;
                                import net.minecraft.client.renderer.GlStateManager;
                                import net.minecraft.client.renderer.entity.Render;
                                import net.minecraft.client.renderer.entity.RenderManager;
                                import net.minecraft.entity.Entity;
                                import net.minecraft.util.ResourceLocation;
                                import net.minecraftforge.fml.relauncher.Side;
                                import net.minecraftforge.fml.relauncher.SideOnly;
                                import eryah.usefulthings.client.models.ModelBulletCasing;
                                import eryah.usefulthings.entity.item.BulletCasing;
                                
                                @SideOnly(Side.CLIENT)
                                public class RenderBulletCasing extends Render
                                {
                                private static final ResourceLocation Textures = new ResourceLocation("ut:textures/entity/bullet_casing.png");
                                protected ModelBase model = new ModelBulletCasing();
                                
                                    public RenderBulletCasing(RenderManager p_i46185_1_, ModelBulletCasing model, float shadow)
                                    {
                                        super(Minecraft.getMinecraft().getRenderManager());
                                    }
                                
                                    /**
                                     * 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, double d1,
                                     * double d2, float f, float f1). But JAD is pre 1.5 so doe
                                     */
                                    public void doRender(BulletCasing entity, double x, double y, double z, float p_76986_8_, float partialTicks)
                                    {
                                        GlStateManager.pushMatrix();
                                        renderOffsetAABB(entity.getEntityBoundingBox(), x - entity.lastTickPosX, y - entity.lastTickPosY, z - entity.lastTickPosZ);
                                        this.model.render(entity, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
                                        GlStateManager.popMatrix();
                                    }
                                
                                    /**
                                     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
                                     */
                                    protected ResourceLocation getEntityTexture(BulletCasing entity)
                                    {
                                        return Textures;
                                    }
                                
                                    public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float partialTicks)
                                    {
                                        this.doRender((BulletCasing)entity, x, y, z, p_76986_8_, partialTicks);
                                    }
                                
                                    protected ResourceLocation getEntityTexture(Entity entity)
                                    {
                                        return this.getEntityTexture((BulletCasing)entity);
                                    }
                                
                                }
                                ```</t></t>

                                Membre fantôme
                                Je développe maintenant un jeu sur UnrealEngine4


                                Contact :…

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

                                  Ton code doit être dans la fonction onImpact qui sera appelé lorsque l’entité touchera un mob ou un bloc.

                                  Normal que ta balle est le rendu de la flèche, t’as mis le code du rendu de la flèche dedans

                                  Site web contenant mes scripts : http://SCAREXgaming.github.io

                                  Pas de demandes de support par MP ni par skype SVP.
                                  Je n'accepte sur skype que l…

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

                                    Pour la douille qui traverse le sol : C’est ce que j’ai fait

                                    Le render :
                                    Ah ok, donc ça

                                    Tessellator tessellator = Tessellator.getInstance();
                                           WorldRenderer worldrenderer = tessellator.getWorldRenderer();
                                           byte b0 = 0;
                                           float f2 = 0.0F;
                                           float f3 = 0.5F;
                                           float f4 = (float)(0 + b0 * 10) / 32.0F;
                                           float f5 = (float)(5 + b0 * 10) / 32.0F;
                                           float f6 = 0.0F;
                                           float f7 = 0.15625F;
                                           float f8 = (float)(5 + b0 * 10) / 32.0F;
                                           float f9 = (float)(10 + b0 * 10) / 32.0F;
                                           float f10 = 0.05625F;
                                           GlStateManager.enableRescaleNormal();
                                           float f11 = (float)p_180551_1_.arrowShake - p_180551_9_;
                                    
                                           if (f11 > 0.0F)
                                           {
                                               float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
                                               GlStateManager.rotate(f12, 0.0F, 0.0F, 1.0F);
                                           }
                                    
                                           GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F);
                                           GlStateManager.scale(f10, f10, f10);
                                           GlStateManager.translate(-4.0F, 0.0F, 0.0F);
                                           GL11.glNormal3f(f10, 0.0F, 0.0F);
                                           worldrenderer.startDrawingQuads();
                                           worldrenderer.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8);
                                           worldrenderer.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8);
                                           worldrenderer.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9);
                                           worldrenderer.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9);
                                           tessellator.draw();
                                           GL11.glNormal3f(-f10, 0.0F, 0.0F);
                                           worldrenderer.startDrawingQuads();
                                           worldrenderer.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8);
                                           worldrenderer.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8);
                                           worldrenderer.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9);
                                           worldrenderer.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9);
                                           tessellator.draw();
                                    
                                           for (int i = 0; i < 4; ++i)
                                           {
                                               GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
                                               GL11.glNormal3f(0.0F, 0.0F, f10);
                                               worldrenderer.startDrawingQuads();
                                               worldrenderer.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4);
                                               worldrenderer.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4);
                                               worldrenderer.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5);
                                               worldrenderer.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5);
                                               tessellator.draw();
                                           }
                                    

                                    C’est ce qui gère le modèle de la flèche ?
                                    Je pense que c’est ça, mais je suis pas sur de sélectioner les bonnes choses 😕
                                    Que faut-il garder ?

                                    package eryah.usefulthings.client.render;
                                    
                                    import net.minecraft.client.Minecraft;
                                    import net.minecraft.client.model.ModelBase;
                                    import net.minecraft.client.renderer.GlStateManager;
                                    import net.minecraft.client.renderer.Tessellator;
                                    import net.minecraft.client.renderer.WorldRenderer;
                                    import net.minecraft.client.renderer.entity.Render;
                                    import net.minecraft.client.renderer.entity.RenderManager;
                                    import net.minecraft.entity.Entity;
                                    import net.minecraft.util.MathHelper;
                                    import net.minecraft.util.ResourceLocation;
                                    import net.minecraftforge.fml.relauncher.Side;
                                    import net.minecraftforge.fml.relauncher.SideOnly;
                                    
                                    import org.lwjgl.opengl.GL11;
                                    
                                    import eryah.usefulthings.client.models.ModelBullet;
                                    import eryah.usefulthings.entity.projectile.EBullet;
                                    
                                    @SideOnly(Side.CLIENT)
                                    public class RenderBullet extends Render
                                    {
                                       private static final ResourceLocation Textures = new ResourceLocation("ut:textures/entity/bullet.png");
                                       /** instance of ModelBoat for rendering */
                                       protected ModelBase modelBullet = new ModelBullet();
                                    
                                       public RenderBullet(RenderManager p_i46193_1_, ModelBullet model, float shadow)
                                       {
                                           super(Minecraft.getMinecraft().getRenderManager());
                                       }
                                    
                                       public void doRender(EBullet p_180551_1_, double p_180551_2_, double p_180551_4_, double p_180551_6_, float p_180551_8_, float p_180551_9_)
                                       {
                                           this.bindEntityTexture(p_180551_1_);
                                           GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                                           GlStateManager.pushMatrix();
                                           GlStateManager.translate((float)p_180551_2_, (float)p_180551_4_, (float)p_180551_6_);
                                           GlStateManager.rotate(p_180551_1_.prevRotationYaw + (p_180551_1_.rotationYaw - p_180551_1_.prevRotationYaw) * p_180551_9_ - 90.0F, 0.0F, 1.0F, 0.0F);
                                           GlStateManager.rotate(p_180551_1_.prevRotationPitch + (p_180551_1_.rotationPitch - p_180551_1_.prevRotationPitch) * p_180551_9_, 0.0F, 0.0F, 1.0F);
                                           Tessellator tessellator = Tessellator.getInstance();
                                           WorldRenderer worldrenderer = tessellator.getWorldRenderer();
                                           byte b0 = 0;
                                           float f2 = 0.0F;
                                           float f3 = 0.5F;
                                           float f4 = (float)(0 + b0 * 10) / 32.0F;
                                           float f5 = (float)(5 + b0 * 10) / 32.0F;
                                           float f6 = 0.0F;
                                           float f7 = 0.15625F;
                                           float f8 = (float)(5 + b0 * 10) / 32.0F;
                                           float f9 = (float)(10 + b0 * 10) / 32.0F;
                                           float f10 = 0.05625F;
                                           GlStateManager.enableRescaleNormal();
                                           float f11 = (float)p_180551_1_.arrowShake - p_180551_9_;
                                    
                                           if (f11 > 0.0F)
                                           {
                                               float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
                                               GlStateManager.rotate(f12, 0.0F, 0.0F, 1.0F);
                                           }
                                    
                                           GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F);
                                           GlStateManager.scale(f10, f10, f10);
                                           GlStateManager.translate(-4.0F, 0.0F, 0.0F);
                                           GL11.glNormal3f(f10, 0.0F, 0.0F);
                                           worldrenderer.startDrawingQuads();
                                           worldrenderer.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8);
                                           worldrenderer.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8);
                                           worldrenderer.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9);
                                           worldrenderer.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9);
                                           tessellator.draw();
                                           GL11.glNormal3f(-f10, 0.0F, 0.0F);
                                           worldrenderer.startDrawingQuads();
                                           worldrenderer.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8);
                                           worldrenderer.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8);
                                           worldrenderer.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9);
                                           worldrenderer.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9);
                                           tessellator.draw();
                                    
                                           for (int i = 0; i < 4; ++i)
                                           {
                                               GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
                                               GL11.glNormal3f(0.0F, 0.0F, f10);
                                               worldrenderer.startDrawingQuads();
                                               worldrenderer.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4);
                                               worldrenderer.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4);
                                               worldrenderer.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5);
                                               worldrenderer.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5);
                                               tessellator.draw();
                                           }
                                    
                                           GlStateManager.disableRescaleNormal();
                                           this.modelBullet.render(p_180551_1_, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
                                           GlStateManager.popMatrix();
                                    
                                       }
                                    
                                       protected ResourceLocation getEntityTexture(EBullet p_180550_1_)
                                       {
                                           return Textures;
                                       }
                                    
                                       /**
                                        * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
                                        */
                                       protected ResourceLocation getEntityTexture(Entity entity)
                                       {
                                           return this.getEntityTexture((EBullet)entity);
                                       }
                                    
                                       /**
                                        * 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, double d1,
                                        * double d2, float f, float f1). But JAD is pre 1.5 so doe
                                        */
                                       public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float partialTicks)
                                       {
                                           this.doRender((EBullet)entity, x, y, z, p_76986_8_, partialTicks);
                                       }
                                    }
                                    

                                    J’ai enlevé la bonne partie du code, mais maintenant, le model se render 2-3blocs trop haut 😕
                                    Et j’au aussi remarqué un  glitch, étrange. Je pensais que mes balles disparaissent au bout de 2-3 secondes, mais non, enfaite, les balles reculent Reculent, monte, décendent, avance, enfin les balles font ce quelles veulent enfaite ( et restent en l’air ) de 4 blocs environ au bout d’un moment Oo

                                    EDIT : C’est bon, j’ai corrigé le problème du modèle de la balle, reste le modèle de la douille, et son nocilp permanent</t>

                                    Membre fantôme
                                    Je développe maintenant un jeu sur UnrealEngine4


                                    Contact :…

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

                                      Je comprends pas le problème avec la douille ? Le problème vient du rendu ou de l’entité ?

                                      Site web contenant mes scripts : http://SCAREXgaming.github.io

                                      Pas de demandes de support par MP ni par skype SVP.
                                      Je n'accepte sur skype que l…

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

                                        Le problème est que l’entity passe a travers les blocs, donc c’est la classe de l’entité

                                        Membre fantôme
                                        Je développe maintenant un jeu sur UnrealEngine4


                                        Contact :…

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

                                          Renvoi la classe de l’entité

                                          Site web contenant mes scripts : http://SCAREXgaming.github.io

                                          Pas de demandes de support par MP ni par skype SVP.
                                          Je n'accepte sur skype que l…

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

                                            Elle n’a pas changé (Classe d’EntityThrowable)

                                            package eryah.usefulthings.entity.item;
                                            
                                            import java.util.List;
                                            
                                            import net.minecraft.block.Block;
                                            import net.minecraft.entity.Entity;
                                            import net.minecraft.entity.EntityLivingBase;
                                            import net.minecraft.entity.player.EntityPlayer;
                                            import net.minecraft.entity.projectile.EntityThrowable;
                                            import net.minecraft.init.Blocks;
                                            import net.minecraft.init.Items;
                                            import net.minecraft.item.ItemStack;
                                            import net.minecraft.nbt.NBTTagCompound;
                                            import net.minecraft.util.AxisAlignedBB;
                                            import net.minecraft.util.BlockPos;
                                            import net.minecraft.util.EnumParticleTypes;
                                            import net.minecraft.util.MathHelper;
                                            import net.minecraft.util.MovingObjectPosition;
                                            import net.minecraft.util.ResourceLocation;
                                            import net.minecraft.util.Vec3;
                                            import net.minecraft.world.World;
                                            import net.minecraftforge.fml.relauncher.Side;
                                            import net.minecraftforge.fml.relauncher.SideOnly;
                                            
                                            public class BulletCasing extends Entity{
                                            
                                            private int xTile = -1;
                                               private int yTile = -1;
                                               private int zTile = -1;
                                               private Block inTile;
                                               protected boolean inGround;
                                               public int throwableShake;
                                               /** The entity that threw this throwable item. */
                                               private EntityLivingBase thrower;
                                               private String throwerName;
                                               private int ticksInGround;
                                               private int ticksInAir;
                                               private static final String __OBFID = "CL_00001723";
                                            
                                            public BulletCasing(World worldIn)
                                               {
                                                   super(worldIn);
                                            
                                               }
                                            
                                            public void onCollideWithPlayer(EntityPlayer entityIn)
                                               {
                                                           entityIn.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1));
                                                           this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
                                                           entityIn.onItemPickup(this, 1);
                                                           this.setDead();            
                                               }
                                            
                                            @SideOnly(Side.CLIENT)
                                               public boolean isInRangeToRenderDist(double distance)
                                               {
                                                   double d1 = this.getEntityBoundingBox().getAverageEdgeLength() * 4.0D;
                                                   d1 *= 64.0D;
                                                   return distance < d1 * d1;
                                               }
                                            
                                               public BulletCasing(World worldIn, EntityLivingBase throwerIn)
                                               {
                                                   super(worldIn);
                                                   this.thrower = throwerIn;
                                                   this.setSize(0.25F, 0.25F);
                                                   this.setLocationAndAngles(throwerIn.posX, throwerIn.posY + (double)throwerIn.getEyeHeight(), throwerIn.posZ, throwerIn.rotationYaw, throwerIn.rotationPitch);
                                                   this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
                                                   this.posY -= 0.10000000149011612D;
                                                   this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
                                                   this.setPosition(this.posX, this.posY, this.posZ);
                                                   float f = 0.4F;
                                                   this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
                                                   this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
                                                   this.motionY = (double)(-MathHelper.sin((this.rotationPitch + this.getInaccuracy()) / 180.0F * (float)Math.PI) * f);
                                                   this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, this.getVelocity(), 1.0F);
                                               }
                                            
                                               public BulletCasing(World worldIn, double x, double y, double p_i1778_6_)
                                               {
                                                   super(worldIn);
                                                   this.ticksInGround = 0;
                                                   this.setSize(0.25F, 0.25F);
                                                   this.setPosition(x, y, p_i1778_6_);
                                               }
                                            
                                               protected float getVelocity()
                                               {
                                                   return 1.5F;
                                               }
                                            
                                               protected float getInaccuracy()
                                               {
                                                   return 0.0F;
                                               }
                                            
                                               /**
                                                * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
                                                *  
                                                * @param inaccuracy Higher means more error.
                                                */
                                               public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy)
                                               {
                                                   float f2 = MathHelper.sqrt_double(x * x + y * y + z * z);
                                                   x /= (double)f2;
                                                   y /= (double)f2;
                                                   z /= (double)f2;
                                                   x += this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
                                                   y += this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
                                                   z += this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
                                                   x *= (double)velocity;
                                                   y *= (double)velocity;
                                                   z *= (double)velocity;
                                                   this.motionX = x;
                                                   this.motionY = y;
                                                   this.motionZ = z;
                                                   float f3 = MathHelper.sqrt_double(x * x + z * z);
                                                   this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI);
                                                   this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f3) * 180.0D / Math.PI);
                                                   this.ticksInGround = 0;
                                               }
                                            
                                               /**
                                                * Sets the velocity to the args. Args: x, y, z
                                                */
                                               @SideOnly(Side.CLIENT)
                                               public void setVelocity(double x, double y, double z)
                                               {
                                                   this.motionX = x;
                                                   this.motionY = y;
                                                   this.motionZ = z;
                                            
                                                   if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
                                                   {
                                                       float f = MathHelper.sqrt_double(x * x + z * z);
                                                       this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI);
                                                       this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f) * 180.0D / Math.PI);
                                                   }
                                               }
                                            
                                               /**
                                                * Called to update the entity's position/logic.
                                                */
                                               public void onUpdate()
                                               {
                                                   this.lastTickPosX = this.posX;
                                                   this.lastTickPosY = this.posY;
                                                   this.lastTickPosZ = this.posZ;
                                                   super.onUpdate();
                                            
                                                   if (this.throwableShake > 0)
                                                   {
                                                       –this.throwableShake;
                                                   }
                                            
                                                   if (this.inGround)
                                                   {
                                                       if (this.worldObj.getBlockState(new BlockPos(this.xTile, this.yTile, this.zTile)).getBlock() == this.inTile)
                                                       {
                                                           ++this.ticksInGround;
                                            
                                                           if (this.ticksInGround == 1200)
                                                           {
                                                               this.setDead();
                                                           }
                                            
                                                           return;
                                                       }
                                            
                                                       this.inGround = false;
                                                       this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
                                                       this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
                                                       this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
                                                       this.ticksInGround = 0;
                                                       this.ticksInAir = 0;
                                                   }
                                                   else
                                                   {
                                                       ++this.ticksInAir;
                                                   }
                                            
                                                   Vec3 vec3 = new Vec3(this.posX, this.posY, this.posZ);
                                                   Vec3 vec31 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
                                                   MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec3, vec31);
                                                   vec3 = new Vec3(this.posX, this.posY, this.posZ);
                                                   vec31 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
                                            
                                                   if (movingobjectposition != null)
                                                   {
                                                       vec31 = new Vec3(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
                                                   }
                                            
                                                   if (!this.worldObj.isRemote)
                                                   {
                                                       Entity entity = null;
                                                       List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
                                                       double d0 = 0.0D;
                                                       EntityLivingBase entitylivingbase = this.getThrower();
                                            
                                                       for (int j = 0; j < list.size(); ++j)
                                                       {
                                                           Entity entity1 = (Entity)list.get(j);
                                            
                                                           if (entity1.canBeCollidedWith() && (entity1 != entitylivingbase || this.ticksInAir >= 5))
                                                           {
                                                               float f = 0.3F;
                                                               AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand((double)f, (double)f, (double)f);
                                                               MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31);
                                            
                                                               if (movingobjectposition1 != null)
                                                               {
                                                                   double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
                                            
                                                                   if (d1 < d0 || d0 == 0.0D)
                                                                   {
                                                                       entity = entity1;
                                                                       d0 = d1;
                                                                   }
                                                               }
                                                           }
                                                       }
                                            
                                                       if (entity != null)
                                                       {
                                                           movingobjectposition = new MovingObjectPosition(entity);
                                                       }
                                                   }
                                            
                                                   if (movingobjectposition != null)
                                                   {
                                                       if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && this.worldObj.getBlockState(movingobjectposition.getBlockPos()).getBlock() == Blocks.portal)
                                                       {
                                                           this.setInPortal();
                                                       }
                                                       else
                                                       {
                                                           this.onImpact(movingobjectposition);
                                                       }
                                                   }
                                            
                                                   this.posX += this.motionX;
                                                   this.posY += this.motionY;
                                                   this.posZ += this.motionZ;
                                                   float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
                                                   this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
                                            
                                                   for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f1) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
                                                   {
                                                       ;
                                                   }
                                            
                                                   while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
                                                   {
                                                       this.prevRotationPitch += 360.0F;
                                                   }
                                            
                                                   while (this.rotationYaw - this.prevRotationYaw < -180.0F)
                                                   {
                                                       this.prevRotationYaw -= 360.0F;
                                                   }
                                            
                                                   while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
                                                   {
                                                       this.prevRotationYaw += 360.0F;
                                                   }
                                            
                                                   this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
                                                   this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
                                                   float f2 = 0.99F;
                                                   float f3 = this.getGravityVelocity();
                                            
                                                   if (this.isInWater())
                                                   {
                                                       for (int i = 0; i < 4; ++i)
                                                       {
                                                           float f4 = 0.25F;
                                                           this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ, new int[0]);
                                                       }
                                            
                                                       f2 = 0.8F;
                                                   }
                                            
                                                   this.motionX *= (double)f2;
                                                   this.motionY *= (double)f2;
                                                   this.motionZ *= (double)f2;
                                                   this.motionY -= (double)f3;
                                                   this.setPosition(this.posX, this.posY, this.posZ);
                                               }
                                            
                                               /**
                                                * Gets the amount of gravity to apply to the thrown entity with each tick.
                                                */
                                               protected float getGravityVelocity()
                                               {
                                                   return 0.03F;
                                               }
                                            
                                               /**
                                                * Called when this EntityThrowable hits a block or entity.
                                                */
                                               protected void onImpact(MovingObjectPosition p_70184_1_) {
                                            }
                                            
                                               /**
                                                * (abstract) Protected helper method to write subclass entity data to NBT.
                                                */
                                               public void writeEntityToNBT(NBTTagCompound tagCompound)
                                               {
                                                   tagCompound.setShort("xTile", (short)this.xTile);
                                                   tagCompound.setShort("yTile", (short)this.yTile);
                                                   tagCompound.setShort("zTile", (short)this.zTile);
                                                   ResourceLocation resourcelocation = (ResourceLocation)Block.blockRegistry.getNameForObject(this.inTile);
                                                   tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
                                                   tagCompound.setByte("shake", (byte)this.throwableShake);
                                                   tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
                                            
                                                   if ((this.throwerName == null || this.throwerName.length() == 0) && this.thrower instanceof EntityPlayer)
                                                   {
                                                       this.throwerName = this.thrower.getName();
                                                   }
                                            
                                                   tagCompound.setString("ownerName", this.throwerName == null ? "" : this.throwerName);
                                               }
                                            
                                               /**
                                                * (abstract) Protected helper method to read subclass entity data from NBT.
                                                */
                                               public void readEntityFromNBT(NBTTagCompound tagCompund)
                                               {
                                                   this.xTile = tagCompund.getShort("xTile");
                                                   this.yTile = tagCompund.getShort("yTile");
                                                   this.zTile = tagCompund.getShort("zTile");
                                            
                                                   if (tagCompund.hasKey("inTile", 8))
                                                   {
                                                       this.inTile = Block.getBlockFromName(tagCompund.getString("inTile"));
                                                   }
                                                   else
                                                   {
                                                       this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255);
                                                   }
                                            
                                                   this.throwableShake = tagCompund.getByte("shake") & 255;
                                                   this.inGround = tagCompund.getByte("inGround") == 1;
                                                   this.throwerName = tagCompund.getString("ownerName");
                                            
                                                   if (this.throwerName != null && this.throwerName.length() == 0)
                                                   {
                                                       this.throwerName = null;
                                                   }
                                               }
                                            
                                               public EntityLivingBase getThrower()
                                               {
                                                   if (this.thrower == null && this.throwerName != null && this.throwerName.length() > 0)
                                                   {
                                                       this.thrower = this.worldObj.getPlayerEntityByName(this.throwerName);
                                                   }
                                            
                                                   return this.thrower;
                                               }
                                            
                                            @Override
                                            protected void entityInit() {
                                            // TODO Auto-generated method stub
                                            
                                            }
                                            
                                            }
                                            
                                            

                                            Membre fantôme
                                            Je développe maintenant un jeu sur UnrealEngine4


                                            Contact :…

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

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB