Jump to content

[1.7.10] EntityThrowable issue


deenkayros

Recommended Posts

Hello,

 

When my custom Entity try to throw the EntityThrowable it's invisible, instead work fine when i try to do it with myself entityplayer.

 

please help

 

EntityThrowable

public class SummonSphereShoes extends EntityThrowable
{
    private EntityPlayer player;
    private float my_rotation = 0.0F;
    
    public SummonSphereShoes(World par1World)
    {
        super(par1World);
    }

    public SummonSphereShoes(World par1World, EntityPlayer par2EntityLivingBase)
    {
        super(par1World, par2EntityLivingBase);
        this.player = par2EntityLivingBase;
    }
    
    public SummonSphereShoes(World par1World, double par2, double par4, double par6)
    {
        super(par1World, par2, par4, par6);
    }
    
    /**
     * Called when this EntityThrowable hits a block or entity.
     */
    protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
    {
        if (par1MovingObjectPosition.entityHit != null)
        {
          float var2 = 3.0F;
          par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), var2);
        }
        for (int var3 = 0; var3 < 4; var3++)
        {
          this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
          this.worldObj.spawnParticle("reddust", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
        }
        if (!this.worldObj.isRemote) {
          setDead();
        }
    }
    
    public void onUpdate()
    {
      super.onUpdate();
      
      this.my_rotation += 20.0F;
      while (this.my_rotation > 360.0F) {
        this.my_rotation -= 360.0F;
      }
      this.rotationPitch = (this.prevRotationPitch = this.my_rotation);
    }
    
}

 

Entity

public class EntityElf extends EntityTameable implements IRangedAttackMob {

    public EntityElf(World p_i1696_1_)
    {
        super(p_i1696_1_);
        this.setSize(0.5F, 1.75F);
        this.getNavigator().setAvoidsWater(true);
        this.tasks.addTask(1, new EntityAISwimming(this));
        this.tasks.addTask(2, this.aiSit);
        this.tasks.addTask(3, new EntityAIAvoidEntity(this, EntityMob.class, 0.8F, 0.80000000000000004D, 1.3300000000000001D));
        
    }

    /**
     * Returns true if the newer Entity AI code should be run
     */
    public boolean isAIEnabled()
    {
        return true;
    }

    protected void entityInit()
    {
        super.entityInit();
        this.dataWatcher.addObject(13, new Byte((byte)0));
        this.dataWatcher.addObject(18, new Float(this.getHealth()));
        //this.dataWatcher.addObject(19, new Byte((byte)0));
        //this.dataWatcher.addObject(20, new Byte((byte)BlockColored.func_150032_b(1)));
    }

    /**
     * Attack the specified entity using a ranged attack.
     */
    public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
    {
        int j = this.rand.nextInt(3);
        
        for (int k = 0; k < j; ++k)
        {
        	SummonSphereShoes var2 = new SummonSphereShoes(this.worldObj);
            double var3 = p_82196_1_.posX - this.posX;
            double var5 = p_82196_1_.posY + p_82196_1_.getEyeHeight() - 1.1D - var2.posY;
            double var7 = p_82196_1_.posZ - this.posZ;
            float var9 = MathHelper.sqrt_double(var3 * var3 + var7 * var7) * 0.2F;
            var2.setThrowableHeading(var3, var5 + var9, var7, 1.8F, 4.0F);
            
            this.worldObj.playSoundAtEntity(this, "random.bow", 0.75F, 1.0F / (getRNG().nextFloat() * 0.4F + 0.8F));
            this.worldObj.spawnEntityInWorld(var2);
        }
    }
    
}

Link to comment
Share on other sites

While this isn't going to solve your problem...

 

SummonSphereShoes var2
double var3
double var5
double var7

 

Egads man, use intelligent variable names, please.  This reeks of decompiled and copy-pasted code.

 

this.rand.nextInt(3);
/*...*/
getRNG().nextFloat();

 

Dafuk?  Why didn't you use this.rand both times?  It's a protected variable, there's no reason to use the public getter, much less using it in one place and not-using it in another inside the same method.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.