Search in sources :

Example 1 with EntityBubble

use of team.cqr.cqrepoured.entity.misc.EntityBubble in project ChocolateQuestRepoured by TeamChocoQuest.

the class ProjectileBubble method applyEntityCollision.

@Override
public void applyEntityCollision(Entity entityHit) {
    if (entityHit == this.shooter) {
        return;
    }
    if (entityHit instanceof EntityBubble || entityHit instanceof ProjectileBubble) {
        return;
    }
    if (entityHit.isRiding() && entityHit.getRidingEntity() instanceof EntityBubble) {
        return;
    }
    if (entityHit instanceof MobEntity && ((MobEntity) entityHit).getActiveItemStack().getItem() instanceof ShieldItem) {
        return;
    }
    entityHit.attackEntityFrom(DamageSource.causeIndirectMagicDamage(this.shooter, this), this.damage);
    float pitch = (1.0F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.2F) * 0.7F;
    this.world.playSound(this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PLAYER_SWIM, SoundCategory.PLAYERS, 4, pitch, true);
    EntityBubble bubbles = new EntityBubble(this.world);
    bubbles.moveToBlockPosAndAngles(entityHit.getPosition().add(0, 0.25, 0), entityHit.rotationYaw, entityHit.rotationPitch);
    this.world.spawnEntity(bubbles);
    entityHit.startRiding(bubbles, true);
    this.setDead();
}
Also used : ShieldItem(net.minecraft.item.ShieldItem) EntityBubble(team.cqr.cqrepoured.entity.misc.EntityBubble) MobEntity(net.minecraft.entity.MobEntity)

Aggregations

MobEntity (net.minecraft.entity.MobEntity)1 ShieldItem (net.minecraft.item.ShieldItem)1 EntityBubble (team.cqr.cqrepoured.entity.misc.EntityBubble)1