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