Свой лук и стрела

Всем привет ! Недавно наткнулся на одну проблему ,которую не могу победить уже второй день.

 Суть проблемы такова: 
- В общем то я делал лук( с кастомным дамагом от стрел), и естественно я запилил свое ентити для стрелы и спавнил именно его. Но суть в том, что моя стрела прилетает в меня же! Искал где может быть проблема, и не нашел.
-Причем я пробовал спавнить не своё ентити а ентити стандартной стрелы, тогда все норм. Также я пробовал просто взять и скопипастить код у ентити стрелы( без изменений),ну естественно кое где аннотаций Override поставил и всё.  Но и это не дало результатов! Стрела также летит в меня! Прикол в том что подобное происходит лишь в режиме выживания!
 
Может хоть ВЫ мне поможете.
 
Чем помочь? Кода Entity стрелы нет и нет кода как ты его спавниш.
   Уверен векторы стрелы совпадают с векторами игрока? Т.е. стрела сравниться направлена в ту сторону куда смотрит игрок.
   Я пока-что не сильно разбирался с Entity'ями, по-этому точного решения я вряд-ли дам.
 
В майне проблема решается так: в первые несколько тиков полета стрелы она не взаимодействует с тем, кто её выпустил. А спавнится она в игроке, это норма.
Код:
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
// остатки логики, проверяющей попадание
}
 
timaxa007 написал(а):
Чем помочь? Кода Entity стрелы нет и нет кода как ты его спавниш.
   Уверен векторы стрелы совпадают с векторами игрока? Т.е. стрела сравниться направлена в ту сторону куда смотрит игрок.
   Я пока-что не сильно разбирался с Entity'ями, по-этому точного решения я вряд-ли дам.
Говорю же стандартный класс ентити стрелы скопипастил!
[merge_posts_bbcode]Добавлено: 22.08.2015 15:50:59[/merge_posts_bbcode]

GloomyFolken написал(а):
В майне проблема решается так: в первые несколько тиков полета стрелы она не взаимодействует с тем, кто её выпустил. А спавнится она в игроке, это норма.
Код:
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
// остатки логики, проверяющей попадание
}
Извини за тупость, но где и как проверять?
 
а как этот метод называется? Прост с моим английским(сорри)
 
Не могу понять так-как в рендере совсем не смыслю!
Помогите пж- стрела в любом случае отлетает от меня и возращается обратно!(только в режиме выживания)
Вот код ентити стрелы:
Код:
package ru.lightway.entity;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S2BPacketChangeGameState;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
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 EntityLightwayArrow extends EntityArrow
{
    protected int xTile = -1;
    protected int yTile = -1;
    protected int zTile = -1;
    protected Block inTile;
    protected int inData;
    protected boolean inGround;
    public int canBePickedUp;
    public int arrowShake;
    public Entity shootingEntity;
    protected int ticksInGround;
    protected int ticksInAir;
    public double damageMin;
    public double damageMax;
    protected int knockbackStrength;
    public Item ammoItem;
    
    public EntityLightwayArrow(World w) {
        super(w);
        this.renderDistanceWeight = 10.0D;
        this.setSize(0.5F, 0.5F);
    }

    public EntityLightwayArrow(World w, double x, double y, double z) {
        super(w);
        this.renderDistanceWeight = 10.0D;
        this.setSize(0.5F, 0.5F);
        this.setPosition(x, y, z);
        this.yOffset = 0.0F;
    }

    public EntityLightwayArrow(World w, EntityLivingBase shooter, EntityLivingBase target, float p_i1755_4_, float p_i1755_5_, float damage, String texture) {
        super(w);
        this.renderDistanceWeight = 10.0D;
        this.shootingEntity = shooter;
        this.damageMax = this.damageMin = damage;
        this.dataWatcher.updateObject(17, texture);

        if (shooter instanceof EntityPlayer)
        {
            this.canBePickedUp = 1;
        }

        this.posY = shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D;
        double d0 = target.posX - shooter.posX;
        double d1 = target.boundingBox.minY + (double)(target.height / 3.0F) - this.posY;
        double d2 = target.posZ - shooter.posZ;
        double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);

        if (d3 >= 1.0E-7D)
        {
            float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
            float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI));
            double d4 = d0 / d3;
            double d5 = d2 / d3;
            this.setLocationAndAngles(shooter.posX + d4, this.posY, shooter.posZ + d5, f2, f3);
            this.yOffset = 0.0F;
            float f4 = (float)d3 * 0.2F;
            this.setThrowableHeading(d0, d1 + (double)f4 -1, d2, p_i1755_4_, p_i1755_5_);
        }
    }

    public EntityLightwayArrow(World w, EntityLivingBase shooter, float p_i1756_3_, float damageMin, float damageMax, String texturename) {
        super(w);
        this.renderDistanceWeight = 10.0D;
        this.shootingEntity = shooter;
        this.damageMin = damageMin;
        this.damageMax = damageMax;
        this.dataWatcher.updateObject(17, texturename);

        if (shooter instanceof EntityPlayer)
        {
            this.canBePickedUp = 1;
        }

        this.setSize(0.5F, 0.5F);
        this.setLocationAndAngles(shooter.posX, shooter.posY + (double)shooter.getEyeHeight(), shooter.posZ, shooter.rotationYaw, shooter.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);
        this.yOffset = 0.0F;
        this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
        this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
        this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
        this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 1.0F);
    }

    @Override
    protected void entityInit()
    {
        this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
        this.dataWatcher.addObject(17, "");
    }

    @Override
    public void setThrowableHeading(double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, float p_70186_8_)
    {
        float f2 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_3_ * p_70186_3_ + p_70186_5_ * p_70186_5_);
        p_70186_1_ /= (double)f2;
        p_70186_3_ /= (double)f2;
        p_70186_5_ /= (double)f2;
        p_70186_1_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
        p_70186_3_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
        p_70186_5_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
        p_70186_1_ *= (double)p_70186_7_;
        p_70186_3_ *= (double)p_70186_7_;
        p_70186_5_ *= (double)p_70186_7_;
        this.motionX = p_70186_1_;
        this.motionY = p_70186_3_;
        this.motionZ = p_70186_5_;
        float f3 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_5_ * p_70186_5_);
        this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70186_1_, p_70186_5_) * 180.0D / Math.PI);
        this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70186_3_, (double)f3) * 180.0D / Math.PI);
        this.ticksInGround = 0;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_)
    {
        this.setPosition(p_70056_1_, p_70056_3_, p_70056_5_);
        this.setRotation(p_70056_7_, p_70056_8_);
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_)
    {
        this.motionX = p_70016_1_;
        this.motionY = p_70016_3_;
        this.motionZ = p_70016_5_;

        if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
        {
            float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_);
            this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI);
            this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, (double)f) * 180.0D / Math.PI);
            this.prevRotationPitch = this.rotationPitch;
            this.prevRotationYaw = this.rotationYaw;
            this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
            this.ticksInGround = 0;
        }
    }

    @Override
    public void onUpdate()
    {
        super.onEntityUpdate();

        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 / Math.PI);
            this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI);
        }

        Block block = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);

        if (block.getMaterial() != Material.air)
        {
            block.setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile);
            AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile);

            if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))
            {
                this.inGround = true;
            }
        }

        if (this.arrowShake > 0)
        {
            --this.arrowShake;
        }

        if (this.inGround)
        {
            int j = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);

            if (block == this.inTile && j == this.inData)
            {
                ++this.ticksInGround;

                if (this.ticksInGround == 1200)
                {
                    this.setDead();
                }
            }
            else
            {
                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 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 position = this.worldObj.rayTraceBlocks(vec31, vec3, 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 (position != null)
            {
                vec3 = Vec3.createVectorHelper(position.hitVec.xCoord, position.hitVec.yCoord, position.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;
            int i;
            float f1;

            for (i = 0; i < list.size(); ++i)
            {
                Entity entity1 = (Entity)list.get(i);

                if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
                {
                    f1 = 0.3F;
                    AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double)f1, (double)f1, (double)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) position = new MovingObjectPosition(entity);

            if (position != null && position.entityHit != null && position.entityHit instanceof EntityPlayer)
            {
                EntityPlayer entityplayer = (EntityPlayer)position.entityHit;

                if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer))
                {
                    position = null;
                }
            }

            float f2;
            float f4;

            if (position != null)
            {
                if (position.entityHit != null)
                {
                    f2 = MathHelper.sqrt_double(4*(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ));
                    int k = MathHelper.ceiling_double_int(f2 * (this.damageMin));
                    if(k>this.damageMax) k = MathHelper.ceiling_double_int(this.damageMax);

                    if (this.getIsCritical())
                    {
                        k += this.rand.nextInt(k / 3 + 2);
                    }

                    DamageSource damagesource = null;

                    if (this.shootingEntity == null)
                    {
                        damagesource = DamageSource.causeArrowDamage(this, this);
                    }
                    else
                    {
                        damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
                    }
                    

                    if (position.entityHit.attackEntityFrom(damagesource, (float)k))
                    {
                        if(this.getTextureName() == "hunterArrow" && position.entityHit instanceof EntityLivingBase){
                            ((EntityLivingBase)position.entityHit).addPotionEffect(new PotionEffect(Potion.poison.id, 40, 2));
                        }

                        if (this.isBurning() && !(position.entityHit instanceof EntityEnderman)) position.entityHit.setFire(5);
                        if(this.getTextureName() == "infernoArrow") position.entityHit.setFire(12);
                        
                        if(this.getTextureName() == "bluefireArrow" || this.getTextureName() == "snowstormArrow") this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 3.0F, false);
                        if (position.entityHit instanceof EntityLivingBase)
                        {
                            EntityLivingBase entitylivingbase = (EntityLivingBase)position.entityHit;

                            if (this.knockbackStrength > 0)
                            {
                                f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);

                                if (f4 > 0.0F)
                                {
                                    position.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4);
                                }
                            }

                            if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase)
                            {
                                EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity);
                                EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase);
                            }

                            if (this.shootingEntity != null && position.entityHit != this.shootingEntity && position.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)
                            {
                                ((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
                            }
                        }

                        this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));

                        if (!(position.entityHit instanceof EntityEnderman))
                        {
                            this.setDead();
                        }
                    }
                    else
                    {
                        this.motionX *= -0.10000000149011612D;
                        this.motionY *= -0.10000000149011612D;
                        this.motionZ *= -0.10000000149011612D;
                        this.rotationYaw += 180.0F;
                        this.prevRotationYaw += 180.0F;
                        this.ticksInAir = 5;
                    }
                }
                else
                {
                    this.xTile = position.blockX;
                    this.yTile = position.blockY;
                    this.zTile = position.blockZ;
                    this.inTile = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);
                    this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
                    this.motionX = (double)((float)(position.hitVec.xCoord - this.posX));
                    this.motionY = (double)((float)(position.hitVec.yCoord - this.posY));
                    this.motionZ = (double)((float)(position.hitVec.zCoord - this.posZ));
                    f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
                    this.posX -= this.motionX / (double)f2 * 0.05000000074505806D;
                    this.posY -= this.motionY / (double)f2 * 0.05000000074505806D;
                    this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D;
                    this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
                    this.inGround = true;
                    this.arrowShake = 7;
                    this.ticksInAir = 5;
                    this.setIsCritical(false);

                    if (this.inTile.getMaterial() != Material.air)
                    {
                        this.inTile.onEntityCollidedWithBlock(this.worldObj, this.xTile, this.yTile, this.zTile, this);
                    }
                }
            }

            if (this.getIsCritical())
            {
                for (i = 0; i < 4; ++i)
                {
                    this.worldObj.spawnParticle("crit", this.posX + this.motionX * (double)i / 4.0D, this.posY + this.motionY * (double)i / 4.0D, this.posZ + this.motionZ * (double)i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ);
                }
            }

            this.posX += this.motionX;
            this.posY += this.motionY;
            this.posZ += this.motionZ;
            f2 = 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)f2) * 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 f3 = 0.99F;
            f1 = 0.05F;

            if (this.isInWater())
            {
                for (int l = 0; l < 4; ++l)
                {
                    f4 = 0.25F;
                    this.worldObj.spawnParticle("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);
                }

                f3 = 0.8F;
            }

            if (this.isWet())
            {
                this.extinguish();
            }

            this.motionX *= (double)f3;
            this.motionY *= (double)f3;
            this.motionZ *= (double)f3;
            this.motionY -= (double)f1;
            this.setPosition(this.posX, this.posY, this.posZ);
            this.doBlockCollisions();
            
            if((this.worldObj.getBlock((int)Math.round(this.posX), (int)Math.floor(this.posY)-1, (int)Math.round(this.posZ)) != Blocks.air || this.worldObj.getBlock((int)Math.round(this.posX), (int)Math.floor(this.posY), (int)Math.round(this.posZ)) != Blocks.air || this.worldObj.getBlock((int)Math.round(this.posX)+1, (int)Math.floor(this.posY), (int)Math.round(this.posZ)) != Blocks.air || this.worldObj.getBlock((int)Math.round(this.posX)-1, (int)Math.floor(this.posY), (int)Math.round(this.posZ)) != Blocks.air || this.worldObj.getBlock((int)Math.round(this.posX), (int)Math.floor(this.posY), (int)Math.round(this.posZ)+1) != Blocks.air || this.worldObj.getBlock((int)Math.round(this.posX), (int)Math.floor(this.posY), (int)Math.round(this.posZ)-1) != Blocks.air || this.worldObj.getBlock((int)Math.round(this.posX), (int)Math.floor(this.posY)+1, (int)Math.round(this.posZ)) != Blocks.air) && this.getTextureName() == "snowstormArrow"){
                this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 3.0F, false);
                this.setDead();
            }
        }
    }

    private void doBlockCollisions() {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void writeEntityToNBT(NBTTagCompound tag)
    {
        tag.setShort("xTile", (short)this.xTile);
        tag.setShort("yTile", (short)this.yTile);
        tag.setShort("zTile", (short)this.zTile);
        tag.setShort("life", (short)this.ticksInGround);
        tag.setByte("inTile", (byte)Block.getIdFromBlock(this.inTile));
        tag.setByte("inData", (byte)this.inData);
        tag.setByte("shake", (byte)this.arrowShake);
        tag.setByte("inGround", (byte)(this.inGround ? 1 : 0));
        tag.setByte("pickup", (byte)this.canBePickedUp);
        tag.setDouble("damage", this.damageMin);
        tag.setString("texture", this.dataWatcher.getWatchableObjectString(17));
    }

    @Override
    public void readEntityFromNBT(NBTTagCompound tag)
    {
        this.xTile = tag.getShort("xTile");
        this.yTile = tag.getShort("yTile");
        this.zTile = tag.getShort("zTile");
        this.ticksInGround = tag.getShort("life");
        this.inTile = Block.getBlockById(tag.getByte("inTile") & 255);
        this.inData = tag.getByte("inData") & 255;
        this.arrowShake = tag.getByte("shake") & 255;
        this.inGround = tag.getByte("inGround") == 1;
        this.dataWatcher.updateObject(17, tag.getString("texture"));

        if (tag.hasKey("damage", 99))
        {
            this.damageMin = tag.getDouble("damage");
        }

        if (tag.hasKey("pickup", 99))
        {
            this.canBePickedUp = tag.getByte("pickup");
        }
        else if (tag.hasKey("player", 99))
        {
            this.canBePickedUp = tag.getBoolean("player") ? 1 : 0;
        }
    }

    @Override
    public void onCollideWithPlayer(EntityPlayer p_70100_1_)
    {
        if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
        {
            boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && p_70100_1_.capabilities.isCreativeMode;

            if (this.canBePickedUp == 1 && !p_70100_1_.inventory.addItemStackToInventory(new ItemStack(ammoItem, 1)))
            {
                flag = false;
            }

            if (flag)
            {
                this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
                p_70100_1_.onItemPickup(this, 1);
                this.setDead();
            }
        }
    }

    @Override
    protected boolean canTriggerWalking()
    {
        return false;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public float getShadowSize()
    {
        return 0.0F;
    }

    @Override
    public void setDamage(double p_70239_1_)
    {
        this.damageMin = p_70239_1_;
    }

    @Override
    public double getDamage()
    {
        return this.damageMin;
    }

    @Override
    public void setKnockbackStrength(int p_70240_1_)
    {
        this.knockbackStrength = p_70240_1_;
    }

    @Override
    public boolean canAttackWithItem()
    {
        return false;
    }

    @Override
    public void setIsCritical(boolean p_70243_1_)
    {
        byte b0 = this.dataWatcher.getWatchableObjectByte(16);

        if (p_70243_1_)
        {
            this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1)));
        }
        else
        {
            this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2)));
        }
    }

    @Override
    public boolean getIsCritical()
    {
        byte b0 = this.dataWatcher.getWatchableObjectByte(16);
        return (b0 & 1) != 0;
    }
    
    public void setAmmoItem(Item ammo){
        this.ammoItem = ammo;
    }
    
    public String getTextureName(){
        return this.dataWatcher.getWatchableObjectString(17);
    }
    }
[merge_posts_bbcode]Добавлено: 24.08.2015 11:53:28[/merge_posts_bbcode]

Вот скрин: http://storage1.static.itmages.ru/i/15/0824/h_1440399265_9675654_e3d5ba25b8.png
 
1) Причем тут рендер вообще?
2) Какой конструктор юзаешь? Скорее всего, ты не задаешь shootingEntity
 
GloomyFolken написал(а):
1) Причем тут рендер вообще?
2) Какой конструктор юзаешь? Скорее всего, ты не задаешь shootingEntity
Притом, что стрела летит не так как нужно, но урон наносится тому кто впереди(то-есть летела бы она правильно)
[merge_posts_bbcode]Добавлено: 24.08.2015 12:07:47[/merge_posts_bbcode]

Код выложил! [font=Verdana, Helvetica, Arial, sans-serif]shootingEntity определяю.[/font]
 
Блин а скажи что не так! Что скинуть?? Конструктору я передаю параметр- ентити игрока, а в самом конструкторе переопределяю его в schootingEntity
[merge_posts_bbcode]Добавлено: 24.08.2015 12:15:10[/merge_posts_bbcode]

Вот код лука если нужно: 
Код:
package ru.lightway.items;

import java.util.ArrayList;
import java.util.List;

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.Item;
import net.minecraft.item.ItemBow;
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 ru.lightway.entity.EntityLightwayArrow;
import ru.lightway.mod.Modinfo;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemModBow extends ItemBow {

    public static List<Item> bowList = new ArrayList<Item>();
    public static final int                DEFAULT_MAX_USE_DURATION = 72000;
    @SideOnly(Side.CLIENT)
    protected IIcon[]                      IIconArray;
    protected String                       name;
    protected String                       textureName;
    protected final String[]               texture;
    protected int                          damageMin;
    protected int                           damageMax;
    protected int                          maxUseDuration;
    protected boolean                      unbreakable;
    protected Item                         arrow;
    protected boolean                      needArrow = true;
    protected String arrowTex;
    private String sound = "random.bow";
    private boolean vethean = false;

    public ItemModBow(String name, int uses, int damageMin, int damageMax, Item arrow) {
        this(name, uses, damageMin, damageMax, DEFAULT_MAX_USE_DURATION, arrow);
    }
    
    public ItemModBow(String name, int uses, int damageMin, int damageMax, String arrowTex) {
        this(name, uses, damageMin, damageMax, DEFAULT_MAX_USE_DURATION, null);
        this.arrowTex = arrowTex;
    }
    
    public ItemModBow(String name, int uses, int damageMin, int damageMax, Item arrow, String arrowTex) {
        this(name, uses, damageMin, damageMax, DEFAULT_MAX_USE_DURATION, arrow);
        this.arrowTex = arrowTex;
    }
    
    public ItemModBow(String name, int uses, int damageMin, int damageMax, int maxUseDuraction) {
        this(name, uses, damageMin, damageMax, maxUseDuraction, null);
    }
    
    public ItemModBow(String name, int uses, int damageMin, int damageMax, int maxUseDuraction, Item arrow, String arrowTex) {
        this(name, uses, damageMin, damageMax, maxUseDuraction, arrow);
        this.arrowTex = arrowTex;
    }

    public ItemModBow(String name, int uses, int damageMin, int damageMax, int maxUseDuraction, Item arrow) {
        
        this.name = name;
        this.textureName = Modinfo.MODID+":" + name;
        if (arrow == null) needArrow = false;
        else this.arrow = arrow;
        this.damageMin = damageMin;
        this.damageMax = damageMax;
        this.maxUseDuration = maxUseDuraction;
        unbreakable = true;
        this.maxStackSize = 1;
        this.setCreativeTab(CreativeTabs.tabCombat);
        this.texture = new String[] { textureName + "_0", textureName + "_1", textureName + "_2", textureName + "_3" };
        setUnlocalizedName(name);
        GameRegistry.registerItem(this, name);
        
        bowList.add(this);
    }

    @Override
    @SideOnly(Side.CLIENT)
    public void registerIcons(IIconRegister icon) {
        itemIcon = icon.registerIcon(texture[0]);
        IIconArray = new IIcon[texture.length];
        for(int i = 0; i < texture.length; i++)
            IIconArray[i] = icon.registerIcon(texture[i]);
    }

    @Override
    @SideOnly(Side.CLIENT)
    public IIcon getItemIconForUseDuration(int icon) {
        return IIconArray[icon];
    }

    @Override
    public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
        if (player.getItemInUse() == null) return itemIcon;
        int pulling = stack.getMaxItemUseDuration() - useRemaining;
        if (pulling >= 18/(DEFAULT_MAX_USE_DURATION/this.getMaxItemUseDuration(stack))) return IIconArray[3];
        if (pulling > 13/(DEFAULT_MAX_USE_DURATION/this.getMaxItemUseDuration(stack))) return IIconArray[2];
        if (pulling > 0) return IIconArray[1];
        return IIconArray[0];
    }

    @Override
    public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int itemUseCount) {
        int maxItemUse = getMaxItemUseDuration(stack) - itemUseCount;
        ArrowLooseEvent event = new ArrowLooseEvent(player, stack, maxItemUse);
        MinecraftForge.EVENT_BUS.post(event);
        if (event.isCanceled()) return;
        maxItemUse = event.charge;
        boolean infiniteAmmo = !needArrow || player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0;
        if (infiniteAmmo || player.inventory.hasItem(arrow)) {
            float timeRatio = DEFAULT_MAX_USE_DURATION/this.getMaxItemUseDuration(stack);
            float scaledItemUse = ((float) maxItemUse / 20.0F)*timeRatio;
            scaledItemUse = (scaledItemUse * scaledItemUse + scaledItemUse * 2) / 3;
            if ((double) scaledItemUse < 0.1) return;
            if (scaledItemUse > 1) scaledItemUse = 1;
            EntityLightwayArrow entityarrow;
            if(this.arrow != null && this.arrowTex == null) entityarrow = new EntityLightwayArrow(world, player, scaledItemUse*2, damageMin, damageMax, arrow.getUnlocalizedName().replace("item.", ""));
            else entityarrow = new EntityLightwayArrow(world, player, scaledItemUse*2, damageMin, damageMax, this.arrowTex);
            entityarrow.setAmmoItem(arrow);
            if (scaledItemUse == 1) entityarrow.setIsCritical(true);
            int powerLevel = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
            if (powerLevel > 0) entityarrow.setDamage(entityarrow.getDamage() + (double) powerLevel * 0.5 + 0.5);
            int punchLevel = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
            if (punchLevel > 0) entityarrow.setKnockbackStrength(punchLevel);
            if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0) entityarrow.setFire(100);
            if (!unbreakable) stack.damageItem(1, player);
            world.playSoundAtEntity(player, this.sound, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + scaledItemUse * 0.5F);
            if (infiniteAmmo) entityarrow.canBePickedUp = 2;
            else player.inventory.consumeInventoryItem(arrow);
            if (!world.isRemote) world.spawnEntityInWorld(entityarrow);
        }
    }

    @Override
    public int getMaxItemUseDuration(ItemStack stack) {
        return maxUseDuration;
    }

   

    @Override
    public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
        ArrowNockEvent nockEvent = new ArrowNockEvent(player, stack);
        MinecraftForge.EVENT_BUS.post(nockEvent);
        if (nockEvent.isCanceled()) return nockEvent.result;
        boolean infiniteAmmo = !needArrow || player.capabilities.isCreativeMode || (EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0 && player.inventory.hasItem(arrow));
        if (infiniteAmmo || player.inventory.hasItem(arrow))
            player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
        return stack;
    }
    
    public ItemModBow setSound(String newSound) {
        this.sound = newSound;
        return this;
    }
 
Окей, shootingEntity ты задаешь, очевидной проблемы тут нет.
1) Твоя стрела точно успевает за пять тиков (0.25 с) отлететь от игрока?
2) Зачем было копировать весь код из EntityArrow, но при этом оставлять extends EntityArrow? Самое хреновое - это объявление полей с тем же названием, что и в родительском классе. Без понятия, связана ли с этим проблема, но воспринимать код из-за этого невозможно. Никогда так не делай.
 
Можно вроде или нужно EntityTroweable или как то так.
 
Уверен на сто процентов,что дело в рендере! Ибо стрелы, которые возращаются ко, мне нельзя подобратью А через несколько секунд они исчезают и появляются там, куда должны были на самом деле попасть
 
Это не может быть рендер по одной простой причине: рендер отвечает за отрисовку.
Любые логические действия, происходящие со стрелой - выполняются в апдейтах и ему подобных, где как раз и осуществляется перемещение стрелы в пространстве.
Что ж ты слепо споришь с другими? Ты хочешь, чтобы тебе помогли или доказать что-то?
Для начала исправь те проблемы, на которые тебе указали.
 
Назад
Сверху