use of net.moddingplayground.frame.api.bannerpatterns.v0.FrameBannerPattern 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.moddingplayground.frame.api.bannerpatterns.v0.FrameBannerPattern 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.moddingplayground.frame.api.bannerpatterns.v0.FrameBannerPattern in project frame-fabric by moddingplayground.
the class LoomScreenMixin method proxyPutPatterns.
/**
* If the pattern index indicates a Frame pattern, put the Frame
* pattern in the item NBT instead of a vanilla pattern.
*/
@Redirect(method = "drawBanner", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NbtCompound;put(Ljava/lang/String;Lnet/minecraft/nbt/NbtElement;)Lnet/minecraft/nbt/NbtElement;", ordinal = 0))
private NbtElement proxyPutPatterns(NbtCompound nbt, String key, NbtElement patterns) {
frame_singlePattern.clear();
if (frame_bannerPatternIndex < 0) {
int frameBannerPatternIdx = -frame_bannerPatternIndex - (1 + BannerPattern.LOOM_APPLICABLE_COUNT);
FrameBannerPattern pattern = FrameBannerPatternsInternal.get(frameBannerPatternIdx);
NbtList framePatterns = new NbtList();
NbtCompound patternNbtElement = new NbtCompound();
patternNbtElement.putString("Pattern", pattern.getId().toString());
patternNbtElement.putInt("Color", 0);
patternNbtElement.putInt("Index", 1);
framePatterns.add(patternNbtElement);
// pop dummy vanilla banner pattern
NbtList vanillaPatterns = (NbtList) patterns;
assert vanillaPatterns.size() == 2 : vanillaPatterns.size();
vanillaPatterns.remove(1);
nbt.put(FrameBannerPatternAccess.NBT_KEY, framePatterns);
frame_singlePattern.add(new FrameBannerPatternData(pattern, DyeColor.WHITE, 1));
}
FrameBannerPatternRenderContext.setFrameBannerPatterns(frame_singlePattern);
return nbt.put(key, patterns);
}
use of net.moddingplayground.frame.api.bannerpatterns.v0.FrameBannerPattern 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);
}
Aggregations