Search in sources :

Example 1 with ItemSpearBase

use of team.cqr.cqrepoured.item.spear.ItemSpearBase in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityAIAttackSpecialSpear method stopAttack.

@Override
public void stopAttack(AbstractEntityCQR attacker, LivingEntity target) {
    Vector3d vec1 = attacker.getEyePosition(1.0F);
    double x = target.getX() - vec1.x;
    double y = MathHelper.clamp(vec1.y, target.getY(), target.getY() + target.getBbHeight()) - vec1.y;
    double z = target.getZ() - vec1.z;
    double dist = MathHelper.sqrt(x * x + z * z);
    double yaw = MathHelper.atan2(-x, z);
    double pitch = MathHelper.atan2(-y, dist);
    Vector3d vec2 = Vector3d.directionFromRotation((float) Math.toDegrees(pitch), (float) Math.toDegrees(yaw));
    ItemStack stack = attacker.getMainHandItem();
    ItemSpearBase item = ((ItemSpearBase) stack.getItem());
    double reachDistance = attacker.getBbWidth() + 0.85D + item.getReach() * 2.5D;
    BoundingBox bb = new BoundingBox(new Vector3d(-0.25D, -0.25D, 0.0D), new Vector3d(0.25D, 0.25D, reachDistance), yaw, pitch, vec1);
    for (LivingEntity entity : BoundingBox.getEntitiesInsideBB(attacker.level, attacker, LivingEntity.class, bb)) {
        if (!attacker.getFaction().isAlly(entity)) {
            // TODO apply enchantments
            entity.hurt(DamageSource.mobAttack(attacker), 1.0F + item.getDamage());
        }
    }
    Vector3d vec3 = vec1.add(new Vector3d(-0.4D, -0.5D, 0.0D).xRot((float) -pitch).yRot((float) -yaw));
    for (double d = reachDistance; d >= 0.0D; d--) {
        Vector3d vec4 = vec3.add(vec2.scale(d));
        ((ServerWorld) attacker.level).sendParticles(ParticleTypes.SMOKE, vec4.x, vec4.y, vec4.z, 1, 0, 0, 0, 0.05);
    }
    attacker.level.playSound(null, attacker.getX(), attacker.getY(), attacker.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, attacker.getSoundSource(), 1.0F, 1.0F);
    attacker.swing(Hand.MAIN_HAND);
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ServerWorld(net.minecraft.world.server.ServerWorld) Vector3d(net.minecraft.util.math.vector.Vector3d) ItemSpearBase(team.cqr.cqrepoured.item.spear.ItemSpearBase) BoundingBox(team.cqr.cqrepoured.util.math.BoundingBox) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ItemSpearBase

use of team.cqr.cqrepoured.item.spear.ItemSpearBase in project ChocolateQuestRepoured by TeamChocoQuest.

the class ModelCQRBiped method setupAnim.

/**
 * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms and
 * legs, where par1 represents the time(so
 * that arms and legs swing back and forth) and par2 represents how "far" arms and legs
 * can swing at most.
 */
@Override
public void setupAnim(T pEntity, float pLimbSwing, float pLimbSwingAmount, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch) {
    final boolean isSpinToWinActive = (pEntity instanceof AbstractEntityCQR && ((AbstractEntityCQR) pEntity).isSpinToWinActive() && !this.riding);
    if (isSpinToWinActive) {
        pLimbSwing = 0;
        pLimbSwingAmount = 0;
        float f = pAgeInTicks * 16.0F;
        // GlStateManager.rotate(f, 0F, 1F, 0F);
        this.body.yRot = (float) Math.toRadians(f);
    }
    if (pEntity.isCrouching()) {
        this.bipedCape.y = 2.0F;
    } else {
        this.bipedCape.y = 0.0F;
    }
    // super.setRotationAngles(pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch, scaleFactor, pEntity);
    super.setupAnim(pEntity, pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch);
    if (pEntity instanceof AbstractEntityCQR) {
        AbstractEntityCQR cqrEnt = ((AbstractEntityCQR) pEntity);
        if (isSpinToWinActive) {
            this.leftArm.zRot = (float) Math.toRadians(-90F);
            this.rightArm.zRot = (float) Math.toRadians(90F);
        } else if (cqrEnt.isSpellCharging() && cqrEnt.isSpellAnimated()) {
            this.renderSpellAnimation(cqrEnt, pAgeInTicks);
        } else {
            boolean flagSide = cqrEnt.isLeftHanded();
            if (cqrEnt.hasAttackTarget() && (cqrEnt.getMainHandItem().getItem() instanceof ItemRevolver || cqrEnt.getMainHandItem().getItem() instanceof ItemHookshotBase) && !(cqrEnt.getMainHandItem().getItem() instanceof ItemMusket)) {
                if (flagSide) {
                    this.leftArm.xRot -= new Float(Math.toRadians(90F));
                } else {
                    this.rightArm.xRot -= new Float(Math.toRadians(90F));
                }
            }
            if (cqrEnt.hasAttackTarget() && (cqrEnt.getMainHandItem().getItem() instanceof ItemRevolver || cqrEnt.getMainHandItem().getItem() instanceof ItemHookshotBase) && !(cqrEnt.getMainHandItem().getItem() instanceof ItemMusket)) {
                if (flagSide) {
                    this.rightArm.xRot -= new Float(Math.toRadians(90F));
                } else {
                    this.leftArm.xRot -= new Float(Math.toRadians(90F));
                }
            }
        }
    }
    ItemStack stack = ((AbstractEntityCQR) pEntity).getMainHandItem();
    if (stack.getItem() instanceof ItemSpearBase) {
        this.renderSpearHoldingAnimation();
    }
    if (true && stack.getItem() instanceof ItemGreatSword) {
        this.renderGreatSwordHoldingAnimation();
    }
    copyModelAngles(this.leftLeg, this.bipedLeftLegwear);
    copyModelAngles(this.rightLeg, this.bipedRightLegwear);
    copyModelAngles(this.leftArm, this.bipedLeftArmwear);
    copyModelAngles(this.rightArm, this.bipedRightArmwear);
    copyModelAngles(this.body, this.bipedBodyWear);
}
Also used : ItemRevolver(team.cqr.cqrepoured.item.gun.ItemRevolver) ItemSpearBase(team.cqr.cqrepoured.item.spear.ItemSpearBase) AbstractEntityCQR(team.cqr.cqrepoured.entity.bases.AbstractEntityCQR) ItemGreatSword(team.cqr.cqrepoured.item.sword.ItemGreatSword) ItemStack(net.minecraft.item.ItemStack) ItemHookshotBase(team.cqr.cqrepoured.item.ItemHookshotBase) ItemMusket(team.cqr.cqrepoured.item.gun.ItemMusket)

Example 3 with ItemSpearBase

use of team.cqr.cqrepoured.item.spear.ItemSpearBase in project ChocolateQuestRepoured by TeamChocoQuest.

the class AbstractEntityCQR method getAttackReach.

public double getAttackReach(LivingEntity target) {
    double reach = ((double) this.getBbWidth() + (double) target.getBbWidth()) * 0.5D + 0.85D;
    ItemStack stack = this.getMainHandItem();
    if (stack.getItem() instanceof ItemSpearBase) {
        reach += ((ItemSpearBase) stack.getItem()).getReach();
    }
    return reach;
}
Also used : ItemSpearBase(team.cqr.cqrepoured.item.spear.ItemSpearBase) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)3 ItemSpearBase (team.cqr.cqrepoured.item.spear.ItemSpearBase)3 LivingEntity (net.minecraft.entity.LivingEntity)1 Vector3d (net.minecraft.util.math.vector.Vector3d)1 ServerWorld (net.minecraft.world.server.ServerWorld)1 AbstractEntityCQR (team.cqr.cqrepoured.entity.bases.AbstractEntityCQR)1 ItemHookshotBase (team.cqr.cqrepoured.item.ItemHookshotBase)1 ItemMusket (team.cqr.cqrepoured.item.gun.ItemMusket)1 ItemRevolver (team.cqr.cqrepoured.item.gun.ItemRevolver)1 ItemGreatSword (team.cqr.cqrepoured.item.sword.ItemGreatSword)1 BoundingBox (team.cqr.cqrepoured.util.math.BoundingBox)1