Added support for a glowing effect around glowing bracelets when canvas is installed

This commit is contained in:
Sollace 2021-02-10 13:18:01 +02:00
parent a566dd2075
commit 62ca1de596
4 changed files with 49 additions and 6 deletions

View file

@ -22,6 +22,14 @@ minecraft {
}
repositories {
maven {
name = "dblsaiko"
url = "https://maven.dblsaiko.net/"
}
maven {
name = "Cotton"
url = "http://server.bbkr.space:8081/artifactory/libs-release/"
}
maven {
name = 'minelp'
url = 'http://repo.minelittlepony-mod.com/maven/snapshot'
@ -60,6 +68,10 @@ dependencies {
modCompileOnly("io.github.prospector:modmenu:${project.modmenu_version}") {
transitive = false
}
modCompileOnly("grondag:canvas-mc116:${project.canvas_version}") {
exclude(group: "net.fabricmc.fabric-api")
exclude(module: "fabric-loader")
}
}
processResources {

View file

@ -6,7 +6,7 @@ org.gradle.daemon=false
minecraft_version=1.16.4
yarn_mappings=1.16.4+build.6
loader_version=0.10.6+build.214
fabric_version=0.25.1+build.416-1.16
fabric_version=0.30.0+1.16
# Mod Properties
group=com.minelittlepony
@ -18,5 +18,6 @@ org.gradle.daemon=false
# Dependencies
modmenu_version=1.14.+
canvas_version=1.0.+
minelp_version=4.2.1-1.16.2-SNAPSHOT
kirin_version=1.7.1-1.16.2-SNAPSHOT

View file

@ -14,7 +14,6 @@ import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
@ -59,10 +58,13 @@ public class BraceletFeatureRenderer<
arm.render(stack, consumer, lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
}
VertexConsumer consumer = ItemRenderer.getArmorGlintConsumer(renderContext, RenderLayer.getArmorCutoutNoCull(TEXTURE), false, false);
boolean glowing = ((GlowableItem)item.getItem()).isGlowing(item);
VertexConsumer consumer = CanvasCompat.getGlowingConsumer(glowing, renderContext, RenderLayer.getArmorCutoutNoCull(TEXTURE));
model.setAngles(getContextModel());
model.setVisible(entity.getMainArm());
model.render(stack, consumer, ((GlowableItem)item.getItem()).isGlowing(item) ? 0x0F00F0 : lightUv, OverlayTexture.DEFAULT_UV, Color.r(j), Color.g(j), Color.b(j), 1);
model.render(stack, consumer, glowing ? 0x0F00F0 : lightUv, OverlayTexture.DEFAULT_UV, Color.r(j), Color.g(j), Color.b(j), 1);
}
}

View file

@ -0,0 +1,28 @@
package com.minelittlepony.unicopia.client.render;
import grondag.canvas.material.state.MaterialFinderImpl;
import grondag.canvas.material.state.RenderLayerHelper;
import grondag.frex.api.material.FrexVertexConsumerProvider;
import net.fabricmc.fabric.api.renderer.v1.RendererAccess;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.ItemRenderer;
final class CanvasCompat {
static VertexConsumer getGlowingConsumer(boolean glowing, VertexConsumerProvider renderContext, RenderLayer layer) {
if (!glowing || !RendererAccess.INSTANCE.hasRenderer() || !FabricLoader.getInstance().isModLoaded("canvas")) {
return ItemRenderer.getArmorGlintConsumer(renderContext, layer, false, false);
}
if (!(renderContext instanceof FrexVertexConsumerProvider)) {
return ItemRenderer.getArmorGlintConsumer(renderContext, layer, false, false);
}
return ((FrexVertexConsumerProvider)renderContext).getConsumer(MaterialFinderImpl.threadLocal()
.copyFrom(RenderLayerHelper.copyFromLayer(layer))
.emissive(true)
.find());
}
}