Jump to content

Entity projectile goes straight through block


invizzble
 Share

Recommended Posts

My entity doesn't explode if it hits a block while a say it has to ,, am i using the wrong if statement?

 

package invizzble.mods.nc.entities.projectiles;

import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.effect.EntityWeatherEffect;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class EntityStaffODarknessAmmo extends EntityThrowable{

    public EntityStaffODarknessAmmo(World par1World)
    {
        super(par1World);
    }
    
    public EntityStaffODarknessAmmo(World par1World,EntityLivingBase par2EntityLivingBase) {
        super(par1World, par2EntityLivingBase);

    }
    
    private int explosionRadius= 3;
    
    @Override
    protected void onImpact(MovingObjectPosition par1Movingobjectposition) {
        
        if (par1Movingobjectposition.entityHit != null)
        {
            byte b0 = 30;

            par1Movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)b0);
            this.setDead();
        }
        if(!this.worldObj.isRemote){ // i found the !this.worldObj.isRemote int the entityEgg and the EntitySnowball, why doesn't it explode?
            this.worldObj.createExplosion(this, this.chunkCoordX, this.chunkCoordY, this.chunkCoordZ, explosionRadius, true);
        }
        
        
    }
    
    @Override
    protected float getGravityVelocity()
    {
        return 0F;
    }

}

Link to comment
Share on other sites

You were also telling the entity to die before it even checked that wether it was client or server... You are supposed to this.setDead(); in the if(!this.worldObj.isRemote) statement

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

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
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.

 Share



×
×
  • Create New...

Important Information

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