use of nomble.beebuddy.duck.IFriendlyPlayer 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.IFriendlyPlayer in project beebuddy by queenofthebees.
the class ServerPlayerEntityMixin method copyFriend.
@Inject(method = "copyFrom", at = @At("TAIL"))
private void copyFriend(ServerPlayerEntity o, boolean a, CallbackInfo cbi) {
IFriendlyPlayer old = (IFriendlyPlayer) (Object) o;
old.beebuddy$setHeadFriendNbt(this.beebuddy$getHeadFriendNbt());
}
use of nomble.beebuddy.duck.IFriendlyPlayer in project beebuddy by queenofthebees.
the class HeadFriendFeatureRenderer method render.
@Override
public void render(MatrixStack matrices, VertexConsumerProvider vcp, int light, T player, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
IFriendlyPlayer friend = (IFriendlyPlayer) (Object) player;
if (friend.beebuddy$hasHeadFriend()) {
CompoundTag t = friend.beebuddy$getHeadFriendNbt();
if (fake == null) {
fake = new FakeBeeEntity(player.world);
}
Identifier tex = null;
if (t.contains("BeeBuddyNectar")) {
String type = t.getString("BeeBuddyNectar");
if (!t.getString("BeeBuddyNectar").equals("default")) {
String texture = "textures/entity/bee/" + type + "_bee.png";
tex = new Identifier("beebuddy", texture);
}
}
if (tex == null) {
tex = new Identifier("textures/entity/bee/bee.png");
}
VertexConsumer v = vcp.getBuffer(bee.getLayer(tex));
ModelPart h = this.getContextModel().getHead();
matrices.push();
if (player.isInSneakingPose()) {
// offsets from BipedEntityModel
matrices.translate(0F, 0.2625F, 0F);
}
matrices.multiply(Vector3f.POSITIVE_Z.getRadialQuaternion(h.roll));
matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(h.yaw));
matrices.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(h.pitch));
float ageMod = t.getInt("Age") >= 0 ? 2F : 1F;
float headPos = player.isInSneakingPose() ? -1.4875F : -1.5F;
matrices.translate(0F, ageMod * headPos - 0.4375, 0F);
matrices.scale(ageMod, ageMod, ageMod);
BeeEntityModelAccessor bea = (BeeEntityModelAccessor) (Object) bee;
bee.setAngles(fake, 0F, 0F, animationProgress, 0F, 0F);
bea.beebuddy$getBody().pitch = 0F;
bea.beebuddy$getBody().pivotY = 19F;
bee.render(matrices, v, light, OverlayTexture.DEFAULT_UV, 1F, 1F, 1F, 1F);
matrices.pop();
}
}
use of nomble.beebuddy.duck.IFriendlyPlayer 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();
}
Aggregations