Search in sources :

Example 1 with IFriendlyBee

use of nomble.beebuddy.duck.IFriendlyBee in project beebuddy by queenofthebees.

the class FollowFriendGoal method canStart.

@Override
public boolean canStart() {
    PlayerEntity f = ((IFriendlyBee) (Object) bee).beebuddy$getFriendPlayer().orElse(null);
    if (f == null) {
        return false;
    }
    IFriendlyBee b = (IFriendlyBee) (Object) bee;
    return (bee.getNavigation().isIdle() && !b.beebuddy$getPollinateGoalRunning() && !b.beebuddy$getMoveToFlowerGoalRunning() && (bee.squaredDistanceTo(f) > 144D)) || (bee.squaredDistanceTo(f) > 400D);
}
Also used : IFriendlyBee(nomble.beebuddy.duck.IFriendlyBee) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 2 with IFriendlyBee

use of nomble.beebuddy.duck.IFriendlyBee in project beebuddy by queenofthebees.

the class SitOnHeadGoal method tick.

@Override
public void tick() {
    ((IFriendlyBee) (Object) bee).beebuddy$getFriendPlayer().ifPresent(f -> {
        BlockPos target = f.getBlockPos().up(2);
        if (bee.getBlockPos().getManhattanDistance(target) < 3) {
            if (tick++ >= 40) {
                if (bee.hasNectar()) {
                    ((IFriendlyBee) (Object) bee).callSetHasNectar(false);
                    f.removeStatusEffect(StatusEffects.POISON);
                    f.eatFood(bee.world, new ItemStack(Items.HONEY_BOTTLE));
                }
                tick = 0;
                ((IFriendlyPlayer) (Object) f).beebuddy$makeHeadFriend(bee);
            }
        } else {
            double x = target.getX() + 0.5D;
            double y = target.getY();
            double z = target.getZ() + 0.5D;
            bee.getNavigation().startMovingTo(x, y, z, 0.5D);
        }
    });
}
Also used : IFriendlyPlayer(nomble.beebuddy.duck.IFriendlyPlayer) IFriendlyBee(nomble.beebuddy.duck.IFriendlyBee) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 3 with IFriendlyBee

use of nomble.beebuddy.duck.IFriendlyBee in project beebuddy by queenofthebees.

the class SitOnHeadGoal method shouldContinue.

@Override
public boolean shouldContinue() {
    IFriendlyBee b = (IFriendlyBee) (Object) bee;
    return b.beebuddy$getFriendPlayer().map(f -> {
        BlockPos t = f.getBlockPos().up(2);
        Vec3d v = f.getVelocity();
        return f.world.getBlockState(t).isOf(Blocks.AIR) && v.getX() == 0D && v.getZ() == 0D && !((IFriendlyPlayer) (Object) f).beebuddy$hasHeadFriend();
    }).orElse(false) && !bee.hasAngerTime();
}
Also used : IFriendlyPlayer(nomble.beebuddy.duck.IFriendlyPlayer) IFriendlyBee(nomble.beebuddy.duck.IFriendlyBee) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d)

Example 4 with IFriendlyBee

use of nomble.beebuddy.duck.IFriendlyBee in project beebuddy by queenofthebees.

the class BeeEntityMixin method makePrideChild.

@Inject(method = "createChild", at = @At("HEAD"), cancellable = true)
private void makePrideChild(ServerWorld world, PassiveEntity entity, CallbackInfoReturnable<BeeEntity> cbir) {
    if (entity instanceof BeeEntity) {
        IFriendlyBee partner = (IFriendlyBee) (Object) entity;
        BeeEntity child = (BeeEntity) EntityType.BEE.create(world);
        IFriendlyBee fchild = (IFriendlyBee) (Object) child;
        String ours = beebuddy$getNectarType();
        String theirs = partner.beebuddy$getNectarType();
        fchild.beebuddy$setNectarType(this.random.nextBoolean() ? ours : theirs);
        if (beebuddy$getFriend().equals(partner.beebuddy$getFriend())) {
            beebuddy$getFriend().ifPresent(u -> {
                fchild.beebuddy$setFriend(Optional.of(u));
                fchild.beebuddy$friendify();
            });
        }
        cbir.setReturnValue(child);
    }
}
Also used : BeeEntity(net.minecraft.entity.passive.BeeEntity) IFriendlyBee(nomble.beebuddy.duck.IFriendlyBee) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with IFriendlyBee

use of nomble.beebuddy.duck.IFriendlyBee in project beebuddy by queenofthebees.

the class BeeEntityRendererMixin method getPrideTexture.

@Inject(method = "getTexture", at = @At("HEAD"), cancellable = true)
private void getPrideTexture(BeeEntity bee, CallbackInfoReturnable<Identifier> cbir) {
    String type = ((IFriendlyBee) (Object) bee).beebuddy$getNectarType();
    if (!type.equals("default")) {
        String texture = "textures/entity/bee/" + type + "_bee";
        texture += bee.hasAngerTime() ? "_angry" : "";
        texture += bee.hasNectar() ? "_nectar" : "";
        cbir.setReturnValue(new Identifier("beebuddy", texture + ".png"));
    }
}
Also used : Identifier(net.minecraft.util.Identifier) IFriendlyBee(nomble.beebuddy.duck.IFriendlyBee) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

IFriendlyBee (nomble.beebuddy.duck.IFriendlyBee)5 BlockPos (net.minecraft.util.math.BlockPos)2 IFriendlyPlayer (nomble.beebuddy.duck.IFriendlyPlayer)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 BeeEntity (net.minecraft.entity.passive.BeeEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ItemStack (net.minecraft.item.ItemStack)1 Identifier (net.minecraft.util.Identifier)1 Vec3d (net.minecraft.util.math.Vec3d)1