Search in sources :

Example 1 with IFriendlyPlayer

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);
        }
    });
}
Also used : IFriendlyPlayer(nomble.beebuddy.duck.IFriendlyPlayer) IFriendlyBee(nomble.beebuddy.duck.IFriendlyBee) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IFriendlyPlayer

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());
}
Also used : IFriendlyPlayer(nomble.beebuddy.duck.IFriendlyPlayer) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 3 with IFriendlyPlayer

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();
    }
}
Also used : IFriendlyPlayer(nomble.beebuddy.duck.IFriendlyPlayer) Identifier(net.minecraft.util.Identifier) ModelPart(net.minecraft.client.model.ModelPart) BeeEntityModelAccessor(nomble.beebuddy.client.mixin.accessor.BeeEntityModelAccessor) VertexConsumer(net.minecraft.client.render.VertexConsumer) CompoundTag(net.minecraft.nbt.CompoundTag)

Example 4 with IFriendlyPlayer

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();
}
Also used : IFriendlyPlayer(nomble.beebuddy.duck.IFriendlyPlayer) IFriendlyBee(nomble.beebuddy.duck.IFriendlyBee) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

IFriendlyPlayer (nomble.beebuddy.duck.IFriendlyPlayer)4 BlockPos (net.minecraft.util.math.BlockPos)2 IFriendlyBee (nomble.beebuddy.duck.IFriendlyBee)2 ModelPart (net.minecraft.client.model.ModelPart)1 VertexConsumer (net.minecraft.client.render.VertexConsumer)1 ItemStack (net.minecraft.item.ItemStack)1 CompoundTag (net.minecraft.nbt.CompoundTag)1 Identifier (net.minecraft.util.Identifier)1 Vec3d (net.minecraft.util.math.Vec3d)1 BeeEntityModelAccessor (nomble.beebuddy.client.mixin.accessor.BeeEntityModelAccessor)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1