Search in sources :

Example 1 with BannerBlockEntity

use of net.minecraft.block.entity.BannerBlockEntity in project Carrier by GabrielOlvH.

the class CarriableBanner method render.

@Override
@Environment(EnvType.CLIENT)
public void render(@NotNull PlayerEntity player, @NotNull CarrierComponent carrier, @NotNull MatrixStack matrices, @NotNull VertexConsumerProvider vcp, float tickDelta, int light) {
    BlockState blockState = getParent().getDefaultState();
    BannerBlockEntity banner = getEntity();
    banner.readNbt(carrier.getCarryingData().getBlockEntityTag());
    ((AccessorBannerBlockEntity) banner).setBaseColor(((AbstractBannerBlock) blockState.getBlock()).getColor());
    matrices.push();
    matrices.scale(0.6f, 0.6f, 0.6f);
    float yaw = MathHelper.lerpAngleDegrees(tickDelta, player.prevBodyYaw, player.bodyYaw);
    matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-yaw));
    matrices.translate(-0.5, 0.4, -0.05);
    MinecraftClient.getInstance().getBlockRenderManager().renderBlockAsEntity(blockState, matrices, vcp, light, OverlayTexture.DEFAULT_UV);
    if (MinecraftClient.isFancyGraphicsOrBetter())
        getEntityRenderer().render(banner, tickDelta, matrices, vcp, light, OverlayTexture.DEFAULT_UV);
    matrices.pop();
}
Also used : BlockState(net.minecraft.block.BlockState) AccessorBannerBlockEntity(me.steven.carrier.mixin.AccessorBannerBlockEntity) BannerBlockEntity(net.minecraft.block.entity.BannerBlockEntity) AccessorBannerBlockEntity(me.steven.carrier.mixin.AccessorBannerBlockEntity) Environment(net.fabricmc.api.Environment)

Aggregations

AccessorBannerBlockEntity (me.steven.carrier.mixin.AccessorBannerBlockEntity)1 Environment (net.fabricmc.api.Environment)1 BlockState (net.minecraft.block.BlockState)1 BannerBlockEntity (net.minecraft.block.entity.BannerBlockEntity)1