Search in sources :

Example 1 with PikeEntity

use of com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity in project upgrade-aquatic by team-abnormals.

the class HideInPickerelweedGoal method shouldExecute.

@Override
public boolean shouldExecute() {
    if (!this.mustUpdate && (this.creature.getIdleTime() >= 100 || this.creature.getRNG().nextInt(this.executionChance) != 0)) {
        return false;
    }
    Vector3d vec3d = this.getPosition();
    if (vec3d == null) {
        return false;
    } else {
        if (((PikeEntity) this.creature).isPickerelweedNearby()) {
            this.x = vec3d.x;
            this.y = vec3d.y;
            this.z = vec3d.z;
            this.mustUpdate = false;
            return true;
        }
    }
    return false;
}
Also used : Vector3d(net.minecraft.util.math.vector.Vector3d) PikeEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity)

Example 2 with PikeEntity

use of com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity in project upgrade-aquatic by team-abnormals.

the class HideInPickerelweedGoal method getPosition.

@Nullable
protected Vector3d getPosition() {
    PikeEntity pike = (PikeEntity) this.creature;
    if (pike.isPickerelweedNearby()) {
        int pickedWeed = pike.getRNG().nextInt(pike.getNearbyPickerelweeds().size());
        BlockPos pos = pike.getNearbyPickerelweeds().get(pickedWeed);
        return new Vector3d(pos.getX(), pos.getY(), pos.getZ());
    }
    return null;
}
Also used : Vector3d(net.minecraft.util.math.vector.Vector3d) BlockPos(net.minecraft.util.math.BlockPos) PikeEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity) Nullable(javax.annotation.Nullable)

Example 3 with PikeEntity

use of com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity in project upgrade-aquatic by team-abnormals.

the class PikeAttackGoal method checkAndPerformAttack.

@Override
protected void checkAndPerformAttack(LivingEntity enemy, double distToEnemySqr) {
    PikeEntity pike = (PikeEntity) this.attacker;
    double attackReach = this.getAttackReachSqr(enemy);
    if (distToEnemySqr <= attackReach && this.func_234040_h_()) {
        this.func_234039_g_();
        if (pike.getAttackTarget() != null) {
            if (enemy instanceof AbstractFishEntity || enemy instanceof AnimalEntity) {
                pike.setAttackCooldown(pike.getRNG().nextInt(550) + 50);
                enemy.startRiding(pike, true);
                pike.setAttackTarget(null);
            } else {
                enemy.attackEntityFrom(DamageSource.causeMobDamage(pike), 1.5F);
            }
        }
    }
}
Also used : AbstractFishEntity(net.minecraft.entity.passive.fish.AbstractFishEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) PikeEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity)

Example 4 with PikeEntity

use of com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity in project upgrade-aquatic by team-abnormals.

the class PikeAttackGoal method startExecuting.

@Override
public void startExecuting() {
    PikeEntity pike = (PikeEntity) this.attacker;
    if (pike.getItemStackFromSlot(EquipmentSlotType.MAINHAND) != null && pike.getAttackTarget() instanceof AbstractFishEntity || pike.getItemStackFromSlot(EquipmentSlotType.MAINHAND) != null && pike.getAttackTarget() instanceof TurtleEntity) {
        pike.spitOutItem(pike.getItemStackFromSlot(EquipmentSlotType.MAINHAND));
    }
    super.startExecuting();
}
Also used : TurtleEntity(net.minecraft.entity.passive.TurtleEntity) AbstractFishEntity(net.minecraft.entity.passive.fish.AbstractFishEntity) PikeEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity)

Aggregations

PikeEntity (com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity)4 AbstractFishEntity (net.minecraft.entity.passive.fish.AbstractFishEntity)2 Vector3d (net.minecraft.util.math.vector.Vector3d)2 Nullable (javax.annotation.Nullable)1 AnimalEntity (net.minecraft.entity.passive.AnimalEntity)1 TurtleEntity (net.minecraft.entity.passive.TurtleEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1