From 4ba7596ba4a6d4b5e809a25e78acd0b9faabd22f Mon Sep 17 00:00:00 2001 From: SHsuperCM Date: Sat, 16 Oct 2021 16:13:16 +0300 Subject: CIT Enchantment's speed and rotation, added glint speed multiplier to config --- .../fabric/citresewn/pack/cits/CITEnchantment.java | 54 +++++++++++++--------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'src/main/java/shcm/shsupercm/fabric/citresewn/pack') diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java index b3b344a..09fbb90 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java @@ -1,10 +1,15 @@ package shcm.shsupercm.fabric.citresewn.pack.cits; +import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.*; import net.minecraft.resource.ResourceType; import net.minecraft.util.Identifier; +import net.minecraft.util.Util; +import net.minecraft.util.math.Matrix4f; +import net.minecraft.util.math.Vec3f; import shcm.shsupercm.fabric.citresewn.CITResewn; +import shcm.shsupercm.fabric.citresewn.config.CITResewnConfig; import shcm.shsupercm.fabric.citresewn.ex.CITParseException; import shcm.shsupercm.fabric.citresewn.mixin.citenchantment.BufferBuilderStorageAccessor; import shcm.shsupercm.fabric.citresewn.mixin.citenchantment.RenderPhaseAccessor; @@ -82,72 +87,77 @@ public class CITEnchantment extends CIT { } public enum GlintRenderLayer { - ARMOR_GLINT("armor_glint", layer -> layer + ARMOR_GLINT("armor_glint", 8f, layer -> layer .shader(RenderPhaseAccessor.ARMOR_GLINT_SHADER()) .writeMaskState(RenderPhaseAccessor.COLOR_MASK()) .cull(RenderPhaseAccessor.DISABLE_CULLING()) .depthTest(RenderPhaseAccessor.EQUAL_DEPTH_TEST()) .transparency(RenderPhaseAccessor.GLINT_TRANSPARENCY()) - .texturing(RenderPhaseAccessor.GLINT_TEXTURING()) .layering(RenderPhaseAccessor.VIEW_OFFSET_Z_LAYERING())), - ARMOR_ENTITY_GLINT("armor_entity_glint", layer -> layer + ARMOR_ENTITY_GLINT("armor_entity_glint", 0.16f, layer -> layer .shader(RenderPhaseAccessor.ARMOR_ENTITY_GLINT_SHADER()) .writeMaskState(RenderPhaseAccessor.COLOR_MASK()) .cull(RenderPhaseAccessor.DISABLE_CULLING()) .depthTest(RenderPhaseAccessor.EQUAL_DEPTH_TEST()) .transparency(RenderPhaseAccessor.GLINT_TRANSPARENCY()) - .texturing(RenderPhaseAccessor.ENTITY_GLINT_TEXTURING()) .layering(RenderPhaseAccessor.VIEW_OFFSET_Z_LAYERING())), - GLINT_TRANSLUCENT("glint_translucent", layer -> layer + GLINT_TRANSLUCENT("glint_translucent", 8f, layer -> layer .shader(RenderPhaseAccessor.TRANSLUCENT_GLINT_SHADER()) .writeMaskState(RenderPhaseAccessor.COLOR_MASK()) .cull(RenderPhaseAccessor.DISABLE_CULLING()) .depthTest(RenderPhaseAccessor.EQUAL_DEPTH_TEST()) .transparency(RenderPhaseAccessor.GLINT_TRANSPARENCY()) - .target(RenderPhaseAccessor.ITEM_TARGET()) - .texturing(RenderPhaseAccessor.GLINT_TEXTURING())), - GLINT("glint", layer -> layer + .target(RenderPhaseAccessor.ITEM_TARGET())), + GLINT("glint", 8f, layer -> layer .shader(RenderPhaseAccessor.GLINT_SHADER()) .writeMaskState(RenderPhaseAccessor.COLOR_MASK()) .cull(RenderPhaseAccessor.DISABLE_CULLING()) .depthTest(RenderPhaseAccessor.EQUAL_DEPTH_TEST()) - .transparency(RenderPhaseAccessor.GLINT_TRANSPARENCY()) - .texturing(RenderPhaseAccessor.GLINT_TEXTURING())), - DIRECT_GLINT("glint_direct", layer -> layer + .transparency(RenderPhaseAccessor.GLINT_TRANSPARENCY())), + DIRECT_GLINT("glint_direct", 8f, layer -> layer .shader(RenderPhaseAccessor.DIRECT_GLINT_SHADER()) .writeMaskState(RenderPhaseAccessor.COLOR_MASK()) .cull(RenderPhaseAccessor.DISABLE_CULLING()) .depthTest(RenderPhaseAccessor.EQUAL_DEPTH_TEST()) - .transparency(RenderPhaseAccessor.GLINT_TRANSPARENCY()) - .texturing(RenderPhaseAccessor.GLINT_TEXTURING())), - ENTITY_GLINT("entity_glint", layer -> layer + .transparency(RenderPhaseAccessor.GLINT_TRANSPARENCY())), + ENTITY_GLINT("entity_glint", 0.16f, layer -> layer .shader(RenderPhaseAccessor.ENTITY_GLINT_SHADER()) .writeMaskState(RenderPhaseAccessor.COLOR_MASK()) .cull(RenderPhaseAccessor.DISABLE_CULLING()) .depthTest(RenderPhaseAccessor.EQUAL_DEPTH_TEST()) .transparency(RenderPhaseAccessor.GLINT_TRANSPARENCY()) - .target(RenderPhaseAccessor.ITEM_TARGET()) - .texturing(RenderPhaseAccessor.ENTITY_GLINT_TEXTURING())), - DIRECT_ENTITY_GLINT("entity_glint_direct", layer -> layer + .target(RenderPhaseAccessor.ITEM_TARGET())), + DIRECT_ENTITY_GLINT("entity_glint_direct", 0.16f, layer -> layer .shader(RenderPhaseAccessor.DIRECT_ENTITY_GLINT_SHADER()) .writeMaskState(RenderPhaseAccessor.COLOR_MASK()) .cull(RenderPhaseAccessor.DISABLE_CULLING()) .depthTest(RenderPhaseAccessor.EQUAL_DEPTH_TEST()) - .transparency(RenderPhaseAccessor.GLINT_TRANSPARENCY()) - .texturing(RenderPhaseAccessor.ENTITY_GLINT_TEXTURING())); + .transparency(RenderPhaseAccessor.GLINT_TRANSPARENCY())); public final String name; - protected final Consumer setup; + private final Consumer setup; + private final float scale; - GlintRenderLayer(String name, Consumer setup) { + GlintRenderLayer(String name, float scale, Consumer setup) { this.name = name; + this.scale = scale; this.setup = setup; } public RenderLayer build(CITEnchantment enchantment) { + final float speed = enchantment.speed, rotation = enchantment.rotation; //noinspection ConstantConditions RenderLayer.MultiPhaseParameters.Builder layer = RenderLayer.MultiPhaseParameters.builder() - .texture(new RenderPhase.Texture(enchantment.textureIdentifier, true, false)); + .texture(new RenderPhase.Texture(enchantment.textureIdentifier, false, false)) + .texturing(new RenderPhase.Texturing("citresewn_glint_texturing", () -> { + float l = Util.getMeasuringTimeMs() * CITResewnConfig.INSTANCE().citenchantment_scroll_multiplier * speed; + float x = (l % 110000f) / 110000f; + float y = (l % 30000f) / 30000f; + Matrix4f matrix4f = Matrix4f.translate(-x, y, 0.0f); + matrix4f.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(rotation + 10f)); + matrix4f.multiply(Matrix4f.scale(scale, scale, scale)); + RenderSystem.setTextureMatrix(matrix4f); + }, RenderSystem::resetTextureMatrix)); this.setup.accept(layer); -- cgit