Search in sources :

Example 1 with DyeColor

use of net.minecraft.util.DyeColor in project frame-fabric by moddingplayground.

the class FrameBannerPatternConversions method makeData.

/**
 * Parses the given NBT data into a list of {@link FrameBannerPatternData} objects.
 *
 * @param nbt a nullable {@link NbtList} with Frame banner pattern data
 */
public static List<FrameBannerPatternData> makeData(NbtList nbt) {
    List<FrameBannerPatternData> res = new ArrayList<>();
    if (nbt != null) {
        for (NbtElement t : nbt) {
            NbtCompound patternNbt = (NbtCompound) t;
            FrameBannerPattern pattern = FrameBannerPatterns.REGISTRY.get(new Identifier(patternNbt.getString("Pattern")));
            if (pattern != null) {
                DyeColor color = DyeColor.byId(patternNbt.getInt("Color"));
                int index = patternNbt.getInt("Index");
                res.add(new FrameBannerPatternData(pattern, color, index));
            }
        }
    }
    return res;
}
Also used : Identifier(net.minecraft.util.Identifier) NbtCompound(net.minecraft.nbt.NbtCompound) ArrayList(java.util.ArrayList) NbtElement(net.minecraft.nbt.NbtElement) FrameBannerPattern(net.moddingplayground.frame.api.bannerpatterns.v0.FrameBannerPattern) DyeColor(net.minecraft.util.DyeColor)

Example 2 with DyeColor

use of net.minecraft.util.DyeColor in project frame-fabric by moddingplayground.

the class BannerItemMixin method frame_addBannerPatternLine.

@Unique
private static void frame_addBannerPatternLine(NbtCompound nbt, List<Text> lines) {
    Identifier id = Identifier.tryParse(nbt.getString("Pattern"));
    DyeColor color = DyeColor.byId(nbt.getInt("Color"));
    if (id != null) {
        FrameBannerPattern pattern = FrameBannerPatterns.REGISTRY.get(id);
        if (pattern != null)
            pattern.addPatternLine(lines, color);
    }
}
Also used : Identifier(net.minecraft.util.Identifier) FrameBannerPattern(net.moddingplayground.frame.api.bannerpatterns.v0.FrameBannerPattern) DyeColor(net.minecraft.util.DyeColor) Unique(org.spongepowered.asm.mixin.Unique)

Example 3 with DyeColor

use of net.minecraft.util.DyeColor in project KiwiClient by TangyKiwi.

the class Tooltips method getShulkerColor.

public Color getShulkerColor(ItemStack shulkerItem) {
    if (!(shulkerItem.getItem() instanceof BlockItem))
        return Color.WHITE;
    Block block = ((BlockItem) shulkerItem.getItem()).getBlock();
    if (block == Blocks.ENDER_CHEST)
        return new Color(0, 50, 50);
    if (!(block instanceof ShulkerBoxBlock))
        return Color.WHITE;
    ShulkerBoxBlock shulkerBlock = (ShulkerBoxBlock) ShulkerBoxBlock.getBlockFromItem(shulkerItem.getItem());
    DyeColor dye = shulkerBlock.getColor();
    if (dye == null)
        return Color.WHITE;
    final float[] colors = dye.getColorComponents();
    return new Color(colors[0], colors[1], colors[2], 1f);
}
Also used : DyeColor(net.minecraft.util.DyeColor) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) Block(net.minecraft.block.Block) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) DyeColor(net.minecraft.util.DyeColor)

Example 4 with DyeColor

use of net.minecraft.util.DyeColor in project frame-fabric by moddingplayground.

the class BannerBlockEntityRendererMixin method frame_renderBannerPattern.

@Unique
private static void frame_renderBannerPattern(FrameBannerPatternData data, MatrixStack stack, VertexConsumerProvider vertices, ModelPart part, int light, int overlay, boolean banner) {
    BannerContext context = BannerContext.from(banner);
    FrameBannerPattern pattern = data.pattern();
    Identifier id = pattern.getSpriteId(context);
    SpriteIdentifier spriteId = FRAME_SPRITE_IDS.apply(context.getAtlas(), id);
    DyeColor color = data.color();
    float[] colors = color.getColorComponents();
    part.render(stack, spriteId.getVertexConsumer(vertices, RenderLayer::getEntityNoOutline), light, overlay, colors[0], colors[1], colors[2], 1.0f);
}
Also used : SpriteIdentifier(net.minecraft.client.util.SpriteIdentifier) BannerContext(net.moddingplayground.frame.api.bannerpatterns.v0.BannerContext) SpriteIdentifier(net.minecraft.client.util.SpriteIdentifier) Identifier(net.minecraft.util.Identifier) FrameBannerPattern(net.moddingplayground.frame.api.bannerpatterns.v0.FrameBannerPattern) DyeColor(net.minecraft.util.DyeColor) Unique(org.spongepowered.asm.mixin.Unique)

Example 5 with DyeColor

use of net.minecraft.util.DyeColor in project MasaGadget by plusls.

the class MixinRenderUtils method renderTradeOfferList.

@Inject(method = "renderInventoryOverlay", at = @At(value = "RETURN"))
private static void renderTradeOfferList(MinecraftClient mc, MatrixStack matrixStack, CallbackInfo ci) {
    if (!Configs.Tweakeroo.INVENTORY_PREVIEW_SUPPORT_TRADE_OFFER_LIST.getBooleanValue()) {
        return;
    }
    Entity entity = TraceUtil.getTraceEntity();
    if (!(entity instanceof MerchantEntity)) {
        return;
    }
    SimpleInventory simpleInventory = new SimpleInventory(MAX_TRADE_OFFER_SIZE);
    for (TradeOffer tradeOffer : ((MerchantEntity) entity).getOffers()) {
        for (int i = 0; i < simpleInventory.size(); ++i) {
            ItemStack itemStack = simpleInventory.getStack(i);
            if (itemStack.isEmpty()) {
                simpleInventory.setStack(i, tradeOffer.getSellItem().copy());
                break;
            }
        }
    }
    int x = GuiUtils.getScaledWindowWidth() / 2 - 88;
    int y = GuiUtils.getScaledWindowHeight() / 2 - 5;
    int slotOffsetX = 8;
    int slotOffsetY = 8;
    InventoryOverlay.InventoryRenderType type = InventoryOverlay.InventoryRenderType.GENERIC;
    DyeColor dye = DyeColor.GREEN;
    float[] colors = dye.getColorComponents();
    fi.dy.masa.malilib.render.RenderUtils.color(colors[0], colors[1], colors[2], 1.0F);
    InventoryOverlay.renderInventoryBackground(type, x, y, MAX_TRADE_OFFER_SIZE, MAX_TRADE_OFFER_SIZE, MinecraftClient.getInstance());
    InventoryOverlay.renderInventoryStacks(type, simpleInventory, x + slotOffsetX, y + slotOffsetY, MAX_TRADE_OFFER_SIZE, 0, MAX_TRADE_OFFER_SIZE, mc);
    fi.dy.masa.malilib.render.RenderUtils.color(1.0F, 1.0F, 1.0F, 1.0F);
}
Also used : Entity(net.minecraft.entity.Entity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) InventoryOverlay(fi.dy.masa.malilib.render.InventoryOverlay) ItemStack(net.minecraft.item.ItemStack) DyeColor(net.minecraft.util.DyeColor) SimpleInventory(net.minecraft.inventory.SimpleInventory) TradeOffer(net.minecraft.village.TradeOffer) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

DyeColor (net.minecraft.util.DyeColor)5 Identifier (net.minecraft.util.Identifier)3 FrameBannerPattern (net.moddingplayground.frame.api.bannerpatterns.v0.FrameBannerPattern)3 Unique (org.spongepowered.asm.mixin.Unique)2 InventoryOverlay (fi.dy.masa.malilib.render.InventoryOverlay)1 ArrayList (java.util.ArrayList)1 Block (net.minecraft.block.Block)1 ShulkerBoxBlock (net.minecraft.block.ShulkerBoxBlock)1 SpriteIdentifier (net.minecraft.client.util.SpriteIdentifier)1 Entity (net.minecraft.entity.Entity)1 MerchantEntity (net.minecraft.entity.passive.MerchantEntity)1 SimpleInventory (net.minecraft.inventory.SimpleInventory)1 ItemStack (net.minecraft.item.ItemStack)1 NbtCompound (net.minecraft.nbt.NbtCompound)1 NbtElement (net.minecraft.nbt.NbtElement)1 TradeOffer (net.minecraft.village.TradeOffer)1 BannerContext (net.moddingplayground.frame.api.bannerpatterns.v0.BannerContext)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1