Search in sources :

Example 1 with MessageBirthdayParty

use of blusunrize.immersiveengineering.common.util.network.MessageBirthdayParty in project ImmersiveEngineering by BluSunrize.

the class EntityRevolvershot method onImpact.

protected void onImpact(RayTraceResult mop) {
    boolean headshot = false;
    if (mop.entityHit instanceof EntityLivingBase)
        headshot = Utils.isVecInEntityHead((EntityLivingBase) mop.entityHit, new Vec3d(posX, posY, posZ));
    if (this.bulletType != null) {
        IBullet bullet = BulletHandler.getBullet(bulletType);
        if (bullet != null)
            bullet.onHitTarget(world, mop, this.shootingEntity, this, headshot);
        if (headshot && mop.entityHit instanceof EntityAgeable && ((EntityAgeable) mop.entityHit).isChild() && ((EntityLivingBase) mop.entityHit).getHealth() <= 0) {
            if (this.shootingEntity instanceof EntityPlayer)
                Utils.unlockIEAdvancement((EntityPlayer) this.shootingEntity, "main/secret_birthdayparty");
            world.playSound(null, posX, posY, posZ, IESounds.birthdayParty, SoundCategory.PLAYERS, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
            ImmersiveEngineering.packetHandler.sendToDimension(new MessageBirthdayParty((EntityLivingBase) mop.entityHit), world.provider.getDimension());
        }
    }
    if (!this.world.isRemote) {
        // if(bulletType==3)
        // world.createExplosion(shootingEntity, posX, posY, posZ, 2, false);
        this.secondaryImpact(mop);
    }
    if (mop.typeOfHit == Type.BLOCK) {
        IBlockState state = this.world.getBlockState(mop.getBlockPos());
        if (state.getBlock().getMaterial(state) != Material.AIR)
            state.getBlock().onEntityCollision(this.world, mop.getBlockPos(), state, this);
    }
    this.setDead();
}
Also used : IBullet(blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet) IBlockState(net.minecraft.block.state.IBlockState) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAgeable(net.minecraft.entity.EntityAgeable) MessageBirthdayParty(blusunrize.immersiveengineering.common.util.network.MessageBirthdayParty)

Aggregations

IBullet (blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet)1 MessageBirthdayParty (blusunrize.immersiveengineering.common.util.network.MessageBirthdayParty)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityAgeable (net.minecraft.entity.EntityAgeable)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1