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);
}
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);
}
});
}
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();
}
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);
}
}
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"));
}
}
Aggregations