diff --git a/build.gradle b/build.gradle index 68b5173f..5029cdb8 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,12 @@ subprojects { // mappings loom.officialMojangMappings() // The following line declares the yarn mappings you may select this one as well. //mappings "net.fabricmc:yarn:1.19+build.4:v2" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" +// mappings loom.layered { +// //it.mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" +// it.mappings "dev.architectury:yarn-mappings-patch-forge:1.20.4+build.1" +// } implementation group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.10' } diff --git a/common/CHANGELOG.md b/common/CHANGELOG.md index 1eef6ec5..8d963ce8 100644 --- a/common/CHANGELOG.md +++ b/common/CHANGELOG.md @@ -1,5 +1,14 @@ [**ETF Changelog:**] +[5.1] + +- mob spawner entities can now variate their textures again. +- moved some temp rework code into more compatible mixins for mod compatibility +- more stable implementation of the 5.0 rework changes for emissives +- random properties now also allow ranges with the format - instead of only - *(OptiFine parity)* +- fixed a crash in the skin tool +- fixed a shoulder parrot crash + [5.0] diff --git a/common/build.gradle b/common/build.gradle index 021f2cf3..e928b750 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -19,6 +19,10 @@ dependencies { modImplementation("maven.modrinth:sodium:${project.sodium_version}") { exclude(group: "net.fabricmc.fabric-api") } + + modImplementation("maven.modrinth:iris:${project.iris_version}") { + exclude(group: "net.fabricmc.fabric-api") + } } publishing { diff --git a/common/src/main/java/traben/entity_texture_features/compat/ETF3DBodyLayerFeatureRenderer.java b/common/src/main/java/traben/entity_texture_features/compat/ETF3DBodyLayerFeatureRenderer.java deleted file mode 100644 index c6346ee8..00000000 --- a/common/src/main/java/traben/entity_texture_features/compat/ETF3DBodyLayerFeatureRenderer.java +++ /dev/null @@ -1,64 +0,0 @@ -package traben.entity_texture_features.compat; - -import dev.tr7zw.skinlayers.accessor.PlayerSettings; -import dev.tr7zw.skinlayers.renderlayers.BodyLayerFeatureRenderer; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.feature.FeatureRendererContext; -import net.minecraft.client.render.entity.model.PlayerEntityModel; -import net.minecraft.client.render.item.ItemRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; -import traben.entity_texture_features.ETFClientCommon; -import traben.entity_texture_features.features.ETFManager; -import traben.entity_texture_features.features.player.ETFPlayerTexture; - -//class exists to introduce extra, ETF interacting, child functionality to 3d Skin layer mod featureRenderers -//this will replace the featureRender added by 3d skin layers mod -// -// as long as inheritance remains valid this should remain future-proof -public class ETF3DBodyLayerFeatureRenderer extends BodyLayerFeatureRenderer { - private VertexConsumerProvider thisProvider = null; - - public ETF3DBodyLayerFeatureRenderer(FeatureRendererContext> renderLayerParent) { - super(renderLayerParent); - } - - // simply captures vertexConsumerProvider - @Override - public void render(MatrixStack poseStack, VertexConsumerProvider multiBufferSource, int i, AbstractClientPlayerEntity player, float f, float g, float h, float j, float k, float l) { - thisProvider = multiBufferSource; - super.render(poseStack, multiBufferSource, i, player, f, g, h, j, k, l); - } - - // simply defers the parent renderLayers method until ETF has had a chance to change the vertex consumer - @Override - public void renderLayers(AbstractClientPlayerEntity abstractClientPlayer, PlayerSettings settings, MatrixStack matrixStack, VertexConsumer vertices, int light, int overlay) { - ETFPlayerTexture thisETF = ETFManager.getInstance().getPlayerTexture(abstractClientPlayer, abstractClientPlayer.getSkinTextures().texture()); - if (thisETF != null) { - Identifier skin = thisETF.getBaseTextureIdentifierOrNullForVanilla(abstractClientPlayer); - if (skin != null) { - vertices = thisProvider.getBuffer(RenderLayer.getEntityTranslucent(skin)); - } - // mesh may be slightly incorrect if texture has changed significantly - // only minor changes expected, typically to the face for blinking - super.renderLayers(abstractClientPlayer, settings, matrixStack, vertices, light, overlay); - - // further meshes are correct as emissive and enchant are only overlays - Identifier emissiveSkin = thisETF.getBaseTextureEmissiveIdentifierOrNullForNone(); - if (emissiveSkin != null) { - vertices = thisProvider.getBuffer(RenderLayer.getEntityTranslucent(emissiveSkin)); - super.renderLayers(abstractClientPlayer, settings, matrixStack, vertices, ETFClientCommon.EMISSIVE_FEATURE_LIGHT_VALUE, overlay); - } - Identifier enchantSkin = thisETF.getBaseTextureEnchantIdentifierOrNullForNone(); - if (enchantSkin != null) { - vertices = ItemRenderer.getArmorGlintConsumer(thisProvider, RenderLayer.getArmorCutoutNoCull(enchantSkin), false, true); - super.renderLayers(abstractClientPlayer, settings, matrixStack, vertices, light, overlay); - } - } else { - super.renderLayers(abstractClientPlayer, settings, matrixStack, vertices, light, overlay); - } - } -} diff --git a/common/src/main/java/traben/entity_texture_features/compat/ETF3DHeadLayerFeatureRenderer.java b/common/src/main/java/traben/entity_texture_features/compat/ETF3DHeadLayerFeatureRenderer.java deleted file mode 100644 index 5cdebcf2..00000000 --- a/common/src/main/java/traben/entity_texture_features/compat/ETF3DHeadLayerFeatureRenderer.java +++ /dev/null @@ -1,63 +0,0 @@ -package traben.entity_texture_features.compat; - -import dev.tr7zw.skinlayers.accessor.PlayerSettings; -import dev.tr7zw.skinlayers.renderlayers.HeadLayerFeatureRenderer; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.feature.FeatureRendererContext; -import net.minecraft.client.render.entity.model.PlayerEntityModel; -import net.minecraft.client.render.item.ItemRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; -import traben.entity_texture_features.ETFClientCommon; -import traben.entity_texture_features.features.ETFManager; -import traben.entity_texture_features.features.player.ETFPlayerTexture; - -//class exists to introduce extra, ETF interacting, child functionality to 3d Skin layer mod featureRenderers -//this will replace the featureRender added by 3d skin layers mod -// -// as long as inheritance remains valid this should remain future-proof -public class ETF3DHeadLayerFeatureRenderer extends HeadLayerFeatureRenderer { - private VertexConsumerProvider thisProvider = null; - - public ETF3DHeadLayerFeatureRenderer(FeatureRendererContext> renderLayerParent) { - super(renderLayerParent); - } - - // simply captures vertexConsumerProvider - @Override - public void render(MatrixStack poseStack, VertexConsumerProvider multiBufferSource, int i, AbstractClientPlayerEntity player, float f, float g, float h, float j, float k, float l) { - thisProvider = multiBufferSource; - super.render(poseStack, multiBufferSource, i, player, f, g, h, j, k, l); - } - - // simply defers the parent renderLayers method until ETF has had a chance to change the vertex consumer - @Override - public void renderCustomHelmet(PlayerSettings settings, AbstractClientPlayerEntity abstractClientPlayer, MatrixStack matrixStack, VertexConsumer vertices, int light, int overlay) { - ETFPlayerTexture thisETF = ETFManager.getInstance().getPlayerTexture(abstractClientPlayer, abstractClientPlayer.getSkinTextures().texture()); - if (thisETF != null) { - Identifier skin = thisETF.getBaseTextureIdentifierOrNullForVanilla(abstractClientPlayer); - if (skin != null) { - vertices = thisProvider.getBuffer(RenderLayer.getEntityTranslucentCull(skin)); - } - // mesh may be slightly incorrect if texture has changed significantly - // only minor changes expected, typically to the face for blinking - super.renderCustomHelmet(settings, abstractClientPlayer, matrixStack, vertices, light, overlay); - // further meshes are correct as emissive and enchant are only overlays - Identifier emissiveSkin = thisETF.getBaseTextureEmissiveIdentifierOrNullForNone(); - if (emissiveSkin != null) { - vertices = thisProvider.getBuffer(RenderLayer.getEntityTranslucentCull(emissiveSkin)); - super.renderCustomHelmet(settings, abstractClientPlayer, matrixStack, vertices, ETFClientCommon.EMISSIVE_FEATURE_LIGHT_VALUE, overlay); - } - Identifier enchantSkin = thisETF.getBaseTextureEnchantIdentifierOrNullForNone(); - if (enchantSkin != null) { - vertices = ItemRenderer.getArmorGlintConsumer(thisProvider, RenderLayer.getArmorCutoutNoCull(enchantSkin), false, true); - super.renderCustomHelmet(settings, abstractClientPlayer, matrixStack, vertices, light, overlay); - } - } else { - super.renderCustomHelmet(settings, abstractClientPlayer, matrixStack, vertices, light, overlay); - } - } -} diff --git a/common/src/main/java/traben/entity_texture_features/compat/ETF3DSkinLayersUtil.java b/common/src/main/java/traben/entity_texture_features/compat/ETF3DSkinLayersUtil.java index 7d191aed..f4b2be7e 100644 --- a/common/src/main/java/traben/entity_texture_features/compat/ETF3DSkinLayersUtil.java +++ b/common/src/main/java/traben/entity_texture_features/compat/ETF3DSkinLayersUtil.java @@ -5,52 +5,18 @@ import dev.tr7zw.skinlayers.accessor.PlayerEntityModelAccessor; import dev.tr7zw.skinlayers.accessor.PlayerSettings; import dev.tr7zw.skinlayers.api.Mesh; -import dev.tr7zw.skinlayers.renderlayers.BodyLayerFeatureRenderer; -import dev.tr7zw.skinlayers.renderlayers.HeadLayerFeatureRenderer; import net.minecraft.client.model.ModelPart; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.entity.PlayerEntityRenderer; import net.minecraft.client.render.entity.PlayerModelPart; -import net.minecraft.client.render.entity.feature.FeatureRenderer; -import net.minecraft.client.render.entity.feature.FeatureRendererContext; -import net.minecraft.client.render.entity.model.PlayerEntityModel; import net.minecraft.client.util.math.MatrixStack; import traben.entity_texture_features.utils.ETFUtils2; // compatibility class for the wonderful 3D skin layers mod by @tr9zw to utilise ETF skin features public abstract class ETF3DSkinLayersUtil { - // method is called from MixinLivingEntityRenderer as a super of the playerEntityRenderer - // - // method is handled in this class separately to prevent any loading attempt of 3D skin layer mod classes without the mod being present - // - // this appears to be the easiest way to add to the 3D skin layer mod's featureRenderers while also utilising - // the mods code to do all the setup required for correct rendering - // - // this method is future-proof only with the expectation that the 2 ETF3D featureRenderer's inheritance remains valid - // checks whether the provided featureRenderer is one of the 3D skin layer feature renderers - public static boolean canReplace(FeatureRenderer feature) { - return feature instanceof BodyLayerFeatureRenderer || feature instanceof HeadLayerFeatureRenderer; - } - - // returns a replacement ETF child featureRenderer of the 3D skin layer featureRenderer - public static FeatureRenderer getReplacement(FeatureRenderer feature, FeatureRendererContext context) { - try { - if (feature instanceof HeadLayerFeatureRenderer) { - //noinspection unchecked - return new ETF3DHeadLayerFeatureRenderer((FeatureRendererContext>) context); - } else if (feature instanceof BodyLayerFeatureRenderer) { - //noinspection unchecked - return new ETF3DBodyLayerFeatureRenderer((FeatureRendererContext>) context); - } - } catch (Exception e) { - ETFUtils2.logWarn("Exception with ETF's 3D skin layers mod compatibility: " + e); - } - ETFUtils2.logError("Failed in ETF's 3D skin layers mod compatibility."); - return feature; - } // todo ensure rendering method is kept up to date with how 3D skin layers mod does it // copy of 3D skin layers hand rendering code as ETF needs to be able to render it at will with a custom VertexConsumer @@ -105,12 +71,4 @@ public static void renderHand(PlayerEntityRenderer instance, MatrixStack poseSta } -// initial testing method -// public static void tryRenderWithETFFeatures(FeatureRendererContext> context, FeatureRenderer featureRenderer, AbstractClientPlayerEntity entity, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, float k, float m, float l, float n, float o) { -// if (featureRenderer instanceof HeadLayerFeatureRenderer) { -// new ETF3DHeadLayerFeatureRenderer>(context).render(matrixStack, vertexConsumerProvider, i, entity, o, n, g, l, k, m); -// } else if (featureRenderer instanceof BodyLayerFeatureRenderer) { -// new ETF3DBodyLayerFeatureRenderer(context).render(matrixStack, vertexConsumerProvider, i, entity, o, n, g, l, k, m); -// } -// } } diff --git a/common/src/main/java/traben/entity_texture_features/config/screens/skin/ETFConfigScreenSkinTool.java b/common/src/main/java/traben/entity_texture_features/config/screens/skin/ETFConfigScreenSkinTool.java index 3fb690d7..8056e121 100644 --- a/common/src/main/java/traben/entity_texture_features/config/screens/skin/ETFConfigScreenSkinTool.java +++ b/common/src/main/java/traben/entity_texture_features/config/screens/skin/ETFConfigScreenSkinTool.java @@ -109,7 +109,7 @@ protected void init() { ETFPlayerTexture etfPlayerTexture = new ETFPlayerTexture(); ETFManager.getInstance().PLAYER_TEXTURE_MAP.put(MinecraftClient.getInstance().player.getUuid(), etfPlayerTexture); thisETFPlayerTexture = etfPlayerTexture; - } else { + } else if (thisETFPlayerTexture.etfTextureOfFinalBaseSkin != null){ thisETFPlayerTexture.etfTextureOfFinalBaseSkin.setGUIBlink(); } } diff --git a/common/src/main/java/traben/entity_texture_features/features/ETFRenderContext.java b/common/src/main/java/traben/entity_texture_features/features/ETFRenderContext.java index 7dbd2a6d..e227ea1c 100644 --- a/common/src/main/java/traben/entity_texture_features/features/ETFRenderContext.java +++ b/common/src/main/java/traben/entity_texture_features/features/ETFRenderContext.java @@ -1,25 +1,21 @@ package traben.entity_texture_features.features; import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.SpriteTexturedVertexConsumer; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.util.Identifier; -import traben.entity_texture_features.features.texture_handlers.ETFTexture; import traben.entity_texture_features.utils.ETFEntity; +import traben.entity_texture_features.utils.ETFRenderLayerWithTexture; +import traben.entity_texture_features.utils.ETFVertexConsumer; import java.util.Optional; -import java.util.function.Function; public class ETFRenderContext { -// private static Object currentTopPart = null; public static boolean renderingFeatures = false; - private static VertexConsumerProvider currentProvider = null; + private static boolean allowRenderLayerTextureModify = true; - private static RenderLayer currentRenderLayer = null; - private static ETFTexture currentETFTexture = null; private static ETFEntity currentEntity = null; private static int currentModelPartDepth = 0; @@ -46,121 +42,6 @@ public static void allowRenderLayerTextureModify() { ETFRenderContext.allowRenderLayerTextureModify = true; } - public static ETFTexture getCurrentETFTexture() { - return currentETFTexture; - } - -// public static void setCurrentTopPart(Object currentTopPart) { -// ETFRenderContext.currentTopPart = currentTopPart; -// } - - @SuppressWarnings("unused") - public static void setCurrentETFTexture(ETFTexture currentETFTexture) { - ETFRenderContext.currentETFTexture = currentETFTexture; - } - - public static VertexConsumer processVertexConsumer(VertexConsumerProvider provider, RenderLayer renderLayer) { - - currentETFTexture = null; - ETFRenderContext.currentRenderLayer = renderLayer; - //sprites will give the atlas id if not handled separately, and the only hook in seems to be the consumer - if (renderLayer instanceof RenderLayer.MultiPhase multiPhase) {// - -// RenderLayer.MultiPhaseParameters params = multiPhase.phases; -// RenderPhase.TextureBase base = params.texture; - Optional possibleId = multiPhase.phases.texture.getId(); - // ETFManager.getInstance().getETFTexture(texture,ETFRenderContext.getCurrentEntity(), ETFManager.TextureSource.ENTITY,false); - possibleId.ifPresent(identifier -> currentETFTexture = ETFManager.getInstance().getETFTextureNoVariation(identifier)); - - - //modify render layer if needed - if (!multiPhase.isOutline() && getCurrentEntity() != null && ETFManager.getInstance().ENTITY_TYPE_RENDER_LAYER.containsKey(getCurrentEntity().etf$getType())) { - preventRenderLayerTextureModify(); - switch (ETFManager.getInstance().ENTITY_TYPE_RENDER_LAYER.getInt(getCurrentEntity().etf$getType())) { - case 1 -> { - Identifier newId = currentETFTexture.getTextureIdentifier(getCurrentEntity()); - //noinspection ConstantValue - if(newId != null) - currentRenderLayer = RenderLayer.getEntityTranslucent(newId); - } - case 2 -> { - Identifier newId = currentETFTexture.getTextureIdentifier(getCurrentEntity()); - //noinspection ConstantValue - if (newId != null) - currentRenderLayer = RenderLayer.getEntityTranslucentCull(newId); - } - case 3 -> currentRenderLayer = RenderLayer.getEndGateway(); - case 4 ->{ - Identifier newId = currentETFTexture.getTextureIdentifier(getCurrentEntity()); - //noinspection ConstantValue - if (newId != null) - currentRenderLayer = RenderLayer.getOutline(newId); - } - default -> { - } - } - allowRenderLayerTextureModify(); - } - } else { - System.out.println("failed 3565683856"); - } - return provider.getBuffer(currentRenderLayer); - } - - public static VertexConsumer processSpriteVertexConsumer(Function layerFactory, VertexConsumer consumer) { - currentETFTexture = null; - - //sprites have a special vertex consumer with their atlas texture - //see if we need to break that - //note this will prevent sprite animations, but only if ETF features are found - if (consumer instanceof SpriteTexturedVertexConsumer spriteTexturedVertexConsumer) { - Identifier rawId = spriteTexturedVertexConsumer.sprite.getContents().getId(); - - //infer actual texture - Identifier actualTexture; - if (rawId.toString().endsWith(".png")) { - actualTexture = rawId; - } else { - //todo check all block entities follow this logic? i know chests, shulker boxes, and beds do - actualTexture = new Identifier(rawId.getNamespace(), "textures/" + rawId.getPath() + ".png"); - } - - //System.out.println("raw="+rawId+"\nactual="+actualTexture); - - currentETFTexture = ETFManager.getInstance().getETFTextureVariant(actualTexture, ETFRenderContext.getCurrentEntity()); - - //if texture is emissive or a variant send in as a non sprite vertex consumer - if (currentETFTexture.getVariantNumber() != 0 || currentETFTexture.isEmissive()) { - preventRenderLayerTextureModify(); - currentRenderLayer = layerFactory.apply(currentETFTexture.thisIdentifier); - allowRenderLayerTextureModify(); - return ETFRenderContext.getCurrentProvider().getBuffer(currentRenderLayer); - } - } - return consumer; - } - - public static VertexConsumerProvider getCurrentProvider() { - return currentProvider; - } - -// public static Object getCurrentTopPart() { -// return currentTopPart; -// } - - public static void setCurrentProvider(VertexConsumerProvider currentProvider) { - ETFRenderContext.currentProvider = currentProvider; - } - - public static RenderLayer getCurrentRenderLayer() { - return currentRenderLayer; - } - - @SuppressWarnings("unused") - public static void setCurrentRenderLayer(RenderLayer currentRenderLayer) { - ETFRenderContext.currentRenderLayer = currentRenderLayer; - } - public static ETFEntity getCurrentEntity() { return currentEntity; } @@ -171,10 +52,6 @@ public static void setCurrentEntity(ETFEntity currentEntity) { ETFRenderContext.currentEntity = currentEntity; } - public static boolean isRenderReady() { - return currentRenderLayer != null && currentProvider != null && currentEntity != null && currentETFTexture != null; - } - public static int getCurrentModelPartDepth() { return currentModelPartDepth; } @@ -192,12 +69,7 @@ public static void resetCurrentModelPartDepth() { } public static void reset() { - currentETFTexture = null; - //currentProvider = null; -// currentTopPart = null; currentModelPartDepth = 0; - - currentRenderLayer = null; currentEntity = null; allowedToPatch = false; allowRenderLayerTextureModify = true; @@ -227,4 +99,41 @@ public static void preventTexturePatching() { allowedToPatch = false; } private static boolean allowedToPatch = false; + + public static RenderLayer modifyRenderLayerIfRequired(RenderLayer value) { + + if (isCurrentlyRenderingEntity() + && isAllowedToRenderLayerTextureModify() + && ETFManager.getInstance().ENTITY_TYPE_RENDER_LAYER.containsKey(currentEntity.etf$getType()) + && !value.isOutline() + && value instanceof ETFRenderLayerWithTexture multiphase) { + + Optional texture = multiphase.etf$getId(); + if (texture.isPresent()) { + preventRenderLayerTextureModify(); + RenderLayer forReturn = switch (ETFManager.getInstance().ENTITY_TYPE_RENDER_LAYER.getInt(currentEntity.etf$getType())) { + case 1 -> RenderLayer.getEntityTranslucent(texture.get()); + case 2 -> RenderLayer.getEntityTranslucentCull(texture.get()); + case 3 -> RenderLayer.getEndGateway(); + case 4 -> RenderLayer.getOutline(texture.get()); + default -> value; + }; + allowRenderLayerTextureModify(); + return forReturn; + } + } + return value; + } + + public static void insertETFDataIntoVertexConsumer(VertexConsumerProvider provider, RenderLayer renderLayer, VertexConsumer vertexConsumer){ + if(isCurrentlyRenderingEntity() && vertexConsumer instanceof ETFVertexConsumer etfVertexConsumer) { + //need to store etf texture of consumer and original render layer + //store provider as well for future actions + etfVertexConsumer.etf$initETFVertexConsumer(provider, renderLayer); + } + } + + public static boolean isCurrentlyRenderingEntity(){ + return currentEntity != null; + } } diff --git a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/FloatRangeFromStringArrayProperty.java b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/FloatRangeFromStringArrayProperty.java index 2bcdb404..4bd913ff 100644 --- a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/FloatRangeFromStringArrayProperty.java +++ b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/FloatRangeFromStringArrayProperty.java @@ -15,9 +15,15 @@ protected FloatRangeFromStringArrayProperty(String string) throws RandomProperty try { if (possibleRange.matches("([\\d.]+|-[\\d.]+)-([\\d.]+|-[\\d.]+)")) { String[] str = possibleRange.split("(? value >= small && value <= big; + float left = Float.parseFloat(str[0].replaceAll("[^0-9.-]", "")); + float right = Float.parseFloat(str[1].replaceAll("[^0-9.-]", "")); + if(left == right){ + return (value) -> value == left; + } else if (right > left) { + return (value) -> value >= left && value <= right; + } else { + return (value) -> value >= right && value <= left; + } } else { float single = Float.parseFloat(possibleRange.replaceAll("[^0-9.-]", "")); return (value) -> value == single; diff --git a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/LongRangeFromStringArrayProperty.java b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/LongRangeFromStringArrayProperty.java new file mode 100644 index 00000000..39ad7f25 --- /dev/null +++ b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/LongRangeFromStringArrayProperty.java @@ -0,0 +1,37 @@ +package traben.entity_texture_features.features.property_reading.properties.generic_properties; + +import org.jetbrains.annotations.Nullable; + +public abstract class LongRangeFromStringArrayProperty extends NumberRangeFromStringArrayProperty { + + + protected LongRangeFromStringArrayProperty(String string) throws RandomPropertyException { + super(string); + } + + + @Override + protected @Nullable RangeTester getRangeTesterFromString(String possibleRange) { + try { + if (possibleRange.matches("(\\d+|-\\d+)-(\\d+|-\\d+)")) { + String[] str = possibleRange.split("(? value == left; + } else if (right > left) { + return (value) -> value >= left && value <= right; + } else { + return (value) -> value >= right && value <= left; + } + } else { + long single = Long.parseLong(possibleRange.replaceAll("[^0-9-]", "")); + return (value) -> value == single; + } + } catch (Exception ignored) { + } + return null; + } + + +} diff --git a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/SimpleIntegerArrayProperty.java b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/SimpleIntegerArrayProperty.java index 066447b8..2c7d893e 100644 --- a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/SimpleIntegerArrayProperty.java +++ b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/SimpleIntegerArrayProperty.java @@ -98,7 +98,19 @@ protected String getPrintableRuleInfo() { return String.valueOf(ARRAY); } - public record IntRange(int lower, int higher) { + public static class IntRange { + final int lower; + final int higher; + + public IntRange(int left, int right){ + if(left > right){ + higher = left; + lower = right; + }else{ + higher = right; + lower = left; + } + } public boolean isWithinRange(int value) { return value >= lower && value <= higher; } @@ -109,7 +121,7 @@ public Integer[] getAllWithinRangeAsList() { } ArrayList builder = new ArrayList<>(); - for (int i = Math.min(lower, higher); i <= Math.max(lower, higher); i++) { + for (int i = lower; i <= higher; i++) { builder.add(i); } return builder.toArray(new Integer[0]); diff --git a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/optifine_properties/TimeOfDayProperty.java b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/optifine_properties/TimeOfDayProperty.java index aa9b59eb..954ca465 100644 --- a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/optifine_properties/TimeOfDayProperty.java +++ b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/optifine_properties/TimeOfDayProperty.java @@ -2,14 +2,14 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import traben.entity_texture_features.features.property_reading.properties.generic_properties.NumberRangeFromStringArrayProperty; +import traben.entity_texture_features.features.property_reading.properties.generic_properties.LongRangeFromStringArrayProperty; import traben.entity_texture_features.utils.ETFEntity; import java.util.Properties; import static traben.entity_texture_features.ETFClientCommon.ETFConfigData; -public class TimeOfDayProperty extends NumberRangeFromStringArrayProperty { +public class TimeOfDayProperty extends LongRangeFromStringArrayProperty { protected TimeOfDayProperty(Properties properties, int propertyNum) throws RandomPropertyException { @@ -33,22 +33,6 @@ protected Long getRangeValueFromEntity(ETFEntity entity) { return null; } - @Override - protected @Nullable RangeTester getRangeTesterFromString(String possibleRange) { - try { - if (possibleRange.matches("(\\d+|-\\d+)-(\\d+|-\\d+)")) { - String[] str = possibleRange.split("(? value >= small && value <= big; - } else { - long single = Long.parseLong(possibleRange.replaceAll("[^0-9-]", "")); - return (value) -> value == single; - } - } catch (Exception ignored) { - } - return null; - } @Override diff --git a/common/src/main/java/traben/entity_texture_features/mixin/MixinBufferBuilder.java b/common/src/main/java/traben/entity_texture_features/mixin/MixinBufferBuilder.java new file mode 100644 index 00000000..ed55311b --- /dev/null +++ b/common/src/main/java/traben/entity_texture_features/mixin/MixinBufferBuilder.java @@ -0,0 +1,52 @@ +package traben.entity_texture_features.mixin; + +import net.minecraft.client.render.BufferBuilder; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import traben.entity_texture_features.features.ETFManager; +import traben.entity_texture_features.features.texture_handlers.ETFTexture; +import traben.entity_texture_features.utils.ETFRenderLayerWithTexture; +import traben.entity_texture_features.utils.ETFVertexConsumer; + +import java.util.Optional; + +@Mixin(BufferBuilder.class) +public class MixinBufferBuilder implements ETFVertexConsumer { + + @Unique + VertexConsumerProvider etf$provider = null; + @Unique + RenderLayer etf$renderLayer = null; + @Unique + ETFTexture etf$ETFTexture = null; + @Override + public ETFTexture etf$getETFTexture() { + return etf$ETFTexture; + } + + @Override + public VertexConsumerProvider etf$getProvider() { + return etf$provider; + } + + @Override + public RenderLayer etf$getRenderLayer() { + return etf$renderLayer; + } + + @Override + public void etf$initETFVertexConsumer(VertexConsumerProvider provider, RenderLayer renderLayer) { + etf$provider = provider; + + etf$renderLayer = renderLayer; + + //todo sprites give atlas texture here + if (renderLayer instanceof ETFRenderLayerWithTexture etfRenderLayerWithTexture) { + Optional possibleId = etfRenderLayerWithTexture.etf$getId(); + possibleId.ifPresent(identifier -> etf$ETFTexture = ETFManager.getInstance().getETFTextureNoVariation(identifier)); + } + } +} diff --git a/common/src/main/java/traben/entity_texture_features/mixin/MixinModelPart.java b/common/src/main/java/traben/entity_texture_features/mixin/MixinModelPart.java index dde46d3d..f7074962 100644 --- a/common/src/main/java/traben/entity_texture_features/mixin/MixinModelPart.java +++ b/common/src/main/java/traben/entity_texture_features/mixin/MixinModelPart.java @@ -3,6 +3,7 @@ import net.minecraft.client.model.ModelPart; 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; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; @@ -15,6 +16,9 @@ import traben.entity_texture_features.ETFClientCommon; import traben.entity_texture_features.features.ETFManager; import traben.entity_texture_features.features.ETFRenderContext; +import traben.entity_texture_features.features.texture_handlers.ETFTexture; +import traben.entity_texture_features.mixin.mods.sodium.MixinModelPartSodium; +import traben.entity_texture_features.utils.ETFVertexConsumer; /** * this method figures out if a {@link ModelPart} is the top level of the children tree being rendered, @@ -22,9 +26,9 @@ *

* this is copied in {@link MixinModelPartSodium} for sodium's alternative model part render method. *

- * the priority is required so this method will never mixin before sodium. + * the priority is set so this method will never run before sodium cancels the vanilla rendering code. */ -@Mixin(value = ModelPart.class, priority = 99999999) +@Mixin(value = ModelPart.class, priority = 2000) public abstract class MixinModelPart { @Shadow public abstract void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha); @@ -42,12 +46,27 @@ public abstract class MixinModelPart { if (ETFRenderContext.getCurrentModelPartDepth() != 1) { ETFRenderContext.decrementCurrentModelPartDepth(); } else { - if (ETFRenderContext.isRenderReady()) { - //attempt special renders as eager OR checks - if (etf$renderEmissive(matrices, overlay, red, green, blue, alpha) | - etf$renderEnchanted(matrices, light, overlay, red, green, blue, alpha)) { - //reset render layer stuff behind the scenes if special renders occurred - ETFRenderContext.getCurrentProvider().getBuffer(ETFRenderContext.getCurrentRenderLayer()); + //top level model so try special rendering + if (ETFRenderContext.isCurrentlyRenderingEntity() + && vertices instanceof ETFVertexConsumer etfVertexConsumer) { + ETFTexture texture = etfVertexConsumer.etf$getETFTexture(); + //is etf texture not null and does it special render? + if(texture != null && (texture.isEmissive() || texture.isEnchanted())) { + VertexConsumerProvider provider = etfVertexConsumer.etf$getProvider(); + //very important this is captured before doing the special renders as they can potentially modify + //the same ETFVertexConsumer down stream + RenderLayer layer = etfVertexConsumer.etf$getRenderLayer(); + //are these render required objects valid? + if (provider != null && layer != null) { + //attempt special renders as eager OR checks + if (etf$renderEmissive(texture, provider, matrices, overlay, red, green, blue, alpha) | + etf$renderEnchanted(texture, provider, matrices, light, overlay, red, green, blue, alpha)) { + //reset render layer stuff behind the scenes if special renders occurred + //this will also return ETFVertexConsumer held data to normal if the same ETFVertexConsumer + //was previously affected by a special render + provider.getBuffer(layer); + } + } } } //ensure model count is reset @@ -56,8 +75,8 @@ public abstract class MixinModelPart { } @Unique - private boolean etf$renderEmissive(MatrixStack matrices, int overlay, float red, float green, float blue, float alpha) { - Identifier emissive = ETFRenderContext.getCurrentETFTexture().getEmissiveIdentifierOfCurrentState(); + private boolean etf$renderEmissive(ETFTexture texture, VertexConsumerProvider provider, MatrixStack matrices, int overlay, float red, float green, float blue, float alpha) { + Identifier emissive = texture.getEmissiveIdentifierOfCurrentState(); if (emissive != null) { boolean wasAllowed = ETFRenderContext.isAllowedToRenderLayerTextureModify(); ETFRenderContext.preventRenderLayerTextureModify(); @@ -65,7 +84,7 @@ public abstract class MixinModelPart { boolean textureIsAllowedBrightRender = ETFManager.getEmissiveMode() == ETFManager.EmissiveRenderModes.BRIGHT && ETFRenderContext.getCurrentEntity().etf$canBeBright();// && !ETFRenderContext.getCurrentETFTexture().isPatched_CurrentlyOnlyArmor(); - VertexConsumer emissiveConsumer = ETFRenderContext.getCurrentProvider().getBuffer( + VertexConsumer emissiveConsumer = provider.getBuffer( textureIsAllowedBrightRender ? RenderLayer.getBeaconBeam(emissive, true) : ETFRenderContext.getCurrentEntity().etf$isBlockEntity() ? @@ -83,13 +102,13 @@ public abstract class MixinModelPart { } @Unique - private boolean etf$renderEnchanted(MatrixStack matrices, int light, int overlay, float red, float green, float blue, float alpha) { + private boolean etf$renderEnchanted(ETFTexture texture, VertexConsumerProvider provider, MatrixStack matrices, int light, int overlay, float red, float green, float blue, float alpha) { //attempt enchanted render - Identifier enchanted = ETFRenderContext.getCurrentETFTexture().getEnchantIdentifierOfCurrentState(); + Identifier enchanted = texture.getEnchantIdentifierOfCurrentState(); if (enchanted != null) { boolean wasAllowed = ETFRenderContext.isAllowedToRenderLayerTextureModify(); ETFRenderContext.preventRenderLayerTextureModify(); - VertexConsumer enchantedVertex = ItemRenderer.getArmorGlintConsumer(ETFRenderContext.getCurrentProvider(), RenderLayer.getArmorCutoutNoCull(enchanted), false, true); + VertexConsumer enchantedVertex = ItemRenderer.getArmorGlintConsumer(provider, RenderLayer.getArmorCutoutNoCull(enchanted), false, true); if(wasAllowed) ETFRenderContext.allowRenderLayerTextureModify(); ETFRenderContext.startSpecialRenderOverlayPhase(); diff --git a/common/src/main/java/traben/entity_texture_features/mixin/MixinMultiPhase.java b/common/src/main/java/traben/entity_texture_features/mixin/MixinMultiPhase.java new file mode 100644 index 00000000..328cf4f1 --- /dev/null +++ b/common/src/main/java/traben/entity_texture_features/mixin/MixinMultiPhase.java @@ -0,0 +1,25 @@ +package traben.entity_texture_features.mixin; + +import net.minecraft.client.render.RenderLayer; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Shadow; +import traben.entity_texture_features.utils.ETFRenderLayerWithTexture; + +import java.util.Optional; + + +@Pseudo +@Mixin(value = RenderLayer.MultiPhase.class) +public abstract class MixinMultiPhase implements ETFRenderLayerWithTexture { + + + @Shadow @Final public RenderLayer.MultiPhaseParameters phases; + + @Override + public Optional etf$getId() { + return phases.texture.getId(); + } +} diff --git a/common/src/main/java/traben/entity_texture_features/mixin/MixinSpriteIdentifier.java b/common/src/main/java/traben/entity_texture_features/mixin/MixinSpriteIdentifier.java index 1ae66430..8ad8c33e 100644 --- a/common/src/main/java/traben/entity_texture_features/mixin/MixinSpriteIdentifier.java +++ b/common/src/main/java/traben/entity_texture_features/mixin/MixinSpriteIdentifier.java @@ -1,6 +1,7 @@ package traben.entity_texture_features.mixin; import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.SpriteTexturedVertexConsumer; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.SpriteIdentifier; @@ -9,7 +10,9 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import traben.entity_texture_features.features.ETFManager; import traben.entity_texture_features.features.ETFRenderContext; +import traben.entity_texture_features.features.texture_handlers.ETFTexture; import java.util.function.Function; @@ -18,7 +21,35 @@ public class MixinSpriteIdentifier { @Inject(method = "getVertexConsumer(Lnet/minecraft/client/render/VertexConsumerProvider;Ljava/util/function/Function;)Lnet/minecraft/client/render/VertexConsumer;", at = @At(value = "RETURN"), cancellable = true) private void etf$modifyIfRequired(VertexConsumerProvider vertexConsumers, Function layerFactory, CallbackInfoReturnable cir) { - cir.setReturnValue(ETFRenderContext.processSpriteVertexConsumer(layerFactory, cir.getReturnValue())); + + if (cir.getReturnValue() instanceof SpriteTexturedVertexConsumer spriteTexturedVertexConsumer) { + Identifier rawId = spriteTexturedVertexConsumer.sprite.getContents().getId(); + + //infer actual texture + Identifier actualTexture; + if (rawId.toString().endsWith(".png")) { + actualTexture = rawId; + } else { + //todo check all block entities follow this logic? i know chests, shulker boxes, and beds do + actualTexture = new Identifier(rawId.getNamespace(), "textures/" + rawId.getPath() + ".png"); + } + + + ETFTexture texture = ETFManager.getInstance().getETFTextureVariant(actualTexture, ETFRenderContext.getCurrentEntity()); + + //if texture is emissive or a variant then replace with a non sprite vertex consumer like regular entities + if (texture.getVariantNumber() != 0 || texture.isEmissive() || texture.isEnchanted()) { + ETFRenderContext.preventRenderLayerTextureModify(); + RenderLayer layer = layerFactory.apply(texture.thisIdentifier); + ETFRenderContext.allowRenderLayerTextureModify(); + if(layer != null) { + VertexConsumer consumer = vertexConsumers.getBuffer(layer); + if (consumer != null) { + cir.setReturnValue(consumer); + } + } + } + } } } diff --git a/common/src/main/java/traben/entity_texture_features/mixin/MixinVertexConsumerProvider_Immediate.java b/common/src/main/java/traben/entity_texture_features/mixin/MixinVertexConsumerProvider_Immediate.java new file mode 100644 index 00000000..d774a72c --- /dev/null +++ b/common/src/main/java/traben/entity_texture_features/mixin/MixinVertexConsumerProvider_Immediate.java @@ -0,0 +1,36 @@ +package traben.entity_texture_features.mixin; + +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.VertexConsumerProvider; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import traben.entity_texture_features.features.ETFRenderContext; + +@Mixin(VertexConsumerProvider.Immediate.class) +public class MixinVertexConsumerProvider_Immediate { + + + @ModifyVariable( + method = "getBuffer", + at = @At(value = "HEAD"), + index = 1, argsOnly = true) + private RenderLayer etf$modifyRenderLayer(RenderLayer value) { + return ETFRenderContext.modifyRenderLayerIfRequired(value); + } + + + @Inject( + method = "getBuffer", + at = @At(value = "RETURN")) + private void etf$injectIntoGetBufferReturn(RenderLayer renderLayer, CallbackInfoReturnable cir) { + ETFRenderContext.insertETFDataIntoVertexConsumer( + (VertexConsumerProvider) this, + renderLayer, + cir.getReturnValue()); + } + +} diff --git a/common/src/main/java/traben/entity_texture_features/mixin/entity/block/MixinMobSpawnerBlockEntityRenderer.java b/common/src/main/java/traben/entity_texture_features/mixin/entity/block/MixinMobSpawnerBlockEntityRenderer.java deleted file mode 100644 index 372d1b2f..00000000 --- a/common/src/main/java/traben/entity_texture_features/mixin/entity/block/MixinMobSpawnerBlockEntityRenderer.java +++ /dev/null @@ -1,26 +0,0 @@ -package traben.entity_texture_features.mixin.entity.block; - -import net.minecraft.block.entity.BellBlockEntity; -import net.minecraft.client.render.block.entity.BlockEntityRenderer; -import net.minecraft.client.render.block.entity.MobSpawnerBlockEntityRenderer; -import net.minecraft.entity.Entity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import traben.entity_texture_features.ETFApi; - -@Mixin(MobSpawnerBlockEntityRenderer.class) -public abstract class MixinMobSpawnerBlockEntityRenderer implements BlockEntityRenderer { - - - @ModifyArg(method = "render(FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/Entity;Lnet/minecraft/client/render/entity/EntityRenderDispatcher;DD)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/EntityRenderDispatcher;render(Lnet/minecraft/entity/Entity;DDDFFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V" - ), index = 0) - private static Entity etf$addUUID(Entity entity) { - entity.setUuid(ETFApi.ETF_GENERIC_UUID); - return entity; - - } -} - - diff --git a/common/src/main/java/traben/entity_texture_features/mixin/entity/block/MixinMobSpawnerLogic.java b/common/src/main/java/traben/entity_texture_features/mixin/entity/block/MixinMobSpawnerLogic.java new file mode 100644 index 00000000..769bec07 --- /dev/null +++ b/common/src/main/java/traben/entity_texture_features/mixin/entity/block/MixinMobSpawnerLogic.java @@ -0,0 +1,28 @@ +package traben.entity_texture_features.mixin.entity.block; + +import net.minecraft.block.spawner.MobSpawnerLogic; +import net.minecraft.entity.Entity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.UUID; + +@Mixin(MobSpawnerLogic.class) +public abstract class MixinMobSpawnerLogic { + + + @Inject(method = "getRenderedEntity", + at = @At(value = "RETURN")) + private void etf$stabiliseMobSpawnerUUID(World world, BlockPos pos, CallbackInfoReturnable cir) { + Entity entity = cir.getReturnValue(); + if(entity != null){ + entity.setUuid(new UUID(pos.asLong(), world.hashCode())); + } + } +} + + diff --git a/common/src/main/java/traben/entity_texture_features/mixin/entity/misc/MixinBlockEntityRenderDispatcher.java b/common/src/main/java/traben/entity_texture_features/mixin/entity/misc/MixinBlockEntityRenderDispatcher.java index b5776ecc..b8f4dde6 100644 --- a/common/src/main/java/traben/entity_texture_features/mixin/entity/misc/MixinBlockEntityRenderDispatcher.java +++ b/common/src/main/java/traben/entity_texture_features/mixin/entity/misc/MixinBlockEntityRenderDispatcher.java @@ -1,12 +1,10 @@ package traben.entity_texture_features.mixin.entity.misc; import net.minecraft.block.entity.BlockEntity; -import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import traben.entity_texture_features.features.ETFRenderContext; import traben.entity_texture_features.utils.ETFEntity; @@ -26,23 +24,23 @@ public class MixinBlockEntityRenderDispatcher { ETFRenderContext.reset(); } - @ModifyVariable( - method = "method_23080", - at = @At(value = "HEAD"), - index = 3, - argsOnly = true) - private static VertexConsumerProvider etf$injectIntoGetBuffer(VertexConsumerProvider vertexConsumers) { - ETFRenderContext.setCurrentProvider(vertexConsumers); - return layer -> ETFRenderContext.processVertexConsumer(vertexConsumers, layer); - } - - @ModifyVariable( - method = "method_23081", - at = @At(value = "HEAD"), - index = 4, - argsOnly = true) - private static VertexConsumerProvider etf$injectIntoGetBuffer2(VertexConsumerProvider vertexConsumers) { - ETFRenderContext.setCurrentProvider(vertexConsumers); - return layer -> ETFRenderContext.processVertexConsumer(vertexConsumers, layer); - } +// @ModifyVariable( +// method = "method_23080", +// at = @At(value = "HEAD"), +// index = 3, +// argsOnly = true) +// private static VertexConsumerProvider etf$injectIntoGetBuffer(VertexConsumerProvider vertexConsumers) { +// ETFRenderContext.setCurrentProvider(vertexConsumers); +// return layer -> ETFRenderContext.processVertexConsumer(vertexConsumers, layer); +// } +// +// @ModifyVariable( +// method = "method_23081", +// at = @At(value = "HEAD"), +// index = 4, +// argsOnly = true) +// private static VertexConsumerProvider etf$injectIntoGetBuffer2(VertexConsumerProvider vertexConsumers) { +// ETFRenderContext.setCurrentProvider(vertexConsumers); +// return layer -> ETFRenderContext.processVertexConsumer(vertexConsumers, layer); +// } } diff --git a/common/src/main/java/traben/entity_texture_features/mixin/entity/misc/MixinEntityRenderDispatcher.java b/common/src/main/java/traben/entity_texture_features/mixin/entity/misc/MixinEntityRenderDispatcher.java index 3dd4745a..b283404c 100644 --- a/common/src/main/java/traben/entity_texture_features/mixin/entity/misc/MixinEntityRenderDispatcher.java +++ b/common/src/main/java/traben/entity_texture_features/mixin/entity/misc/MixinEntityRenderDispatcher.java @@ -7,7 +7,6 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import traben.entity_texture_features.features.ETFRenderContext; import traben.entity_texture_features.utils.ETFEntity; @@ -18,7 +17,7 @@ public class MixinEntityRenderDispatcher { at = @At(value = "HEAD")) private void etf$grabContext(E entity, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { ETFRenderContext.setCurrentEntity((ETFEntity) entity); - ETFRenderContext.setCurrentProvider(vertexConsumers); +// ETFRenderContext.setCurrentProvider(vertexConsumers); } @@ -30,12 +29,12 @@ public class MixinEntityRenderDispatcher { } - @ModifyArg( - method = "render", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/EntityRenderer;render(Lnet/minecraft/entity/Entity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"), - index = 4 - ) - private VertexConsumerProvider etf$injectIntoGetBuffer(VertexConsumerProvider vertexConsumers) { - return layer -> ETFRenderContext.processVertexConsumer(vertexConsumers, layer); - } +// @ModifyArg( +// method = "render", +// at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/EntityRenderer;render(Lnet/minecraft/entity/Entity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"), +// index = 4 +// ) +// private VertexConsumerProvider etf$injectIntoGetBuffer(VertexConsumerProvider vertexConsumers) { +// return layer -> ETFRenderContext.processVertexConsumer(vertexConsumers, layer); +// } } diff --git a/common/src/main/java/traben/entity_texture_features/mixin/entity/renderer/MixinLivingEntityRenderer.java b/common/src/main/java/traben/entity_texture_features/mixin/entity/renderer/MixinLivingEntityRenderer.java index bb9ce622..b01f735b 100644 --- a/common/src/main/java/traben/entity_texture_features/mixin/entity/renderer/MixinLivingEntityRenderer.java +++ b/common/src/main/java/traben/entity_texture_features/mixin/entity/renderer/MixinLivingEntityRenderer.java @@ -4,7 +4,6 @@ import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.render.entity.LivingEntityRenderer; -import net.minecraft.client.render.entity.feature.FeatureRenderer; import net.minecraft.client.render.entity.feature.FeatureRendererContext; import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.util.math.MatrixStack; @@ -13,15 +12,9 @@ import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import traben.entity_texture_features.ETFClientCommon; -import traben.entity_texture_features.compat.ETF3DSkinLayersUtil; import traben.entity_texture_features.features.ETFRenderContext; import traben.entity_texture_features.utils.ETFEntity; -import traben.entity_texture_features.utils.ETFUtils2; - -import static traben.entity_texture_features.ETFClientCommon.ETFConfigData; @Mixin(LivingEntityRenderer.class) @@ -59,28 +52,6 @@ protected MixinLivingEntityRenderer(EntityRendererFactory.Context ctx) { ETFRenderContext.setRenderingFeatures(false); } - @ModifyArg(method = "addFeature", at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z"), index = 0) - private Object etf$3dSkinLayerCompat(Object featureRenderer) { - // replace 3d skin layers mod feature renderers with ETF's child versions - - try { - // handler class is only ever accessed if the mod is present - // prevents NoClassDefFoundError - if (ETFClientCommon.SKIN_LAYERS_DETECTED - && ETFConfigData.use3DSkinLayerPatch - && ETF3DSkinLayersUtil.canReplace((FeatureRenderer) featureRenderer)) { - return ETF3DSkinLayersUtil.getReplacement((FeatureRenderer) featureRenderer, this); - } - } catch (Exception e) { - ETFUtils2.logWarn("Exception with ETF's 3D skin layers mod compatibility: " + e); - } catch (NoClassDefFoundError error) { - // Should never be thrown - // unless a significant change in 3d skin layers mod - ETFUtils2.logError("Error with ETF's 3D skin layers mod compatibility: " + error); - } - - return featureRenderer; - } } diff --git a/common/src/main/java/traben/entity_texture_features/mixin/entity/renderer/MixinPlayerEntityRenderer.java b/common/src/main/java/traben/entity_texture_features/mixin/entity/renderer/MixinPlayerEntityRenderer.java index aef2689a..070119a3 100644 --- a/common/src/main/java/traben/entity_texture_features/mixin/entity/renderer/MixinPlayerEntityRenderer.java +++ b/common/src/main/java/traben/entity_texture_features/mixin/entity/renderer/MixinPlayerEntityRenderer.java @@ -21,7 +21,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import traben.entity_texture_features.ETFClientCommon; -import traben.entity_texture_features.ETFVersionDifferenceHandler; import traben.entity_texture_features.compat.ETF3DSkinLayersUtil; import traben.entity_texture_features.features.ETFManager; import traben.entity_texture_features.features.ETFRenderContext; @@ -57,20 +56,20 @@ public MixinPlayerEntityRenderer(EntityRendererFactory.Context ctx, PlayerEntity at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/PlayerEntityModel;setAngles(Lnet/minecraft/entity/LivingEntity;FFFFF)V", shift = At.Shift.AFTER), cancellable = true) private void etf$redirectNicely(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, AbstractClientPlayerEntity player, ModelPart arm, ModelPart sleeve, CallbackInfo ci) { - arm.pitch = 0.0F; - sleeve.pitch = 0.0F; - if (ETFConfigData.skinFeaturesEnabled) { ETFPlayerTexture thisETFPlayerTexture = ETFManager.getInstance().getPlayerTexture(player, player.getSkinTextures().texture()); - if (thisETFPlayerTexture != null) { + if (thisETFPlayerTexture != null && thisETFPlayerTexture.hasFeatures) { Identifier etfTexture = thisETFPlayerTexture.getBaseTextureIdentifierOrNullForVanilla(player); if (etfTexture != null) { ETFRenderContext.preventRenderLayerTextureModify(); + arm.pitch = 0.0F; + sleeve.pitch = 0.0F; + VertexConsumer vc1 = vertexConsumers.getBuffer(RenderLayer.getEntityTranslucent(etfTexture)); arm.render(matrices, vc1, light, OverlayTexture.DEFAULT_UV); sleeve.render(matrices, vc1, light, OverlayTexture.DEFAULT_UV); - if (ETFVersionDifferenceHandler.isThisModLoaded("skinlayers") || ETFVersionDifferenceHandler.isThisModLoaded("skinlayers3d")) { + if (ETFClientCommon.SKIN_LAYERS_DETECTED) { try { // handler class is only ever accessed if the mod is present // prevents NoClassDefFoundError @@ -92,7 +91,7 @@ public MixinPlayerEntityRenderer(EntityRendererFactory.Context ctx, PlayerEntity arm.render(matrices, vc2, ETFClientCommon.EMISSIVE_FEATURE_LIGHT_VALUE, OverlayTexture.DEFAULT_UV); sleeve.render(matrices, vc2, ETFClientCommon.EMISSIVE_FEATURE_LIGHT_VALUE, OverlayTexture.DEFAULT_UV); ETFRenderContext.endSpecialRenderOverlayPhase(); - if (ETFVersionDifferenceHandler.isThisModLoaded("skinlayers") || ETFVersionDifferenceHandler.isThisModLoaded("skinlayers3d")) { + if (ETFClientCommon.SKIN_LAYERS_DETECTED) { try { // handler class is only ever accessed if the mod is present // prevents NoClassDefFoundError @@ -112,7 +111,7 @@ public MixinPlayerEntityRenderer(EntityRendererFactory.Context ctx, PlayerEntity VertexConsumer vc3 = ItemRenderer.getArmorGlintConsumer(vertexConsumers, RenderLayer.getArmorCutoutNoCull(thisETFPlayerTexture.baseEnchantIdentifier), false, true); arm.render(matrices, vc3, light, OverlayTexture.DEFAULT_UV); sleeve.render(matrices, vc3, light, OverlayTexture.DEFAULT_UV); - if (ETFVersionDifferenceHandler.isThisModLoaded("skinlayers") || ETFVersionDifferenceHandler.isThisModLoaded("skinlayers3d")) { + if (ETFClientCommon.SKIN_LAYERS_DETECTED) { try { // handler class is only ever accessed if the mod is present // prevents NoClassDefFoundError diff --git a/common/src/main/java/traben/entity_texture_features/mixin/entity/renderer/feature/MixinShoulderParrotFeatureRenderer.java b/common/src/main/java/traben/entity_texture_features/mixin/entity/renderer/feature/MixinShoulderParrotFeatureRenderer.java index c3f7fc23..087bfd40 100644 --- a/common/src/main/java/traben/entity_texture_features/mixin/entity/renderer/feature/MixinShoulderParrotFeatureRenderer.java +++ b/common/src/main/java/traben/entity_texture_features/mixin/entity/renderer/feature/MixinShoulderParrotFeatureRenderer.java @@ -28,7 +28,7 @@ public abstract class MixinShoulderParrotFeatureRenderer @Unique private NbtCompound entity_texture_features$parrotNBT = null; @Unique - private ETFEntity entity_texture_features$player = null; + private ETFEntity etf$heldEntity = null; @SuppressWarnings("unused") public MixinShoulderParrotFeatureRenderer(FeatureRendererContext> context) { @@ -40,10 +40,10 @@ public MixinShoulderParrotFeatureRenderer(FeatureRendererContext type, CallbackInfo ci) { if (entity_texture_features$parrotNBT != null) { - entity_texture_features$player = ETFRenderContext.getCurrentEntity(); + etf$heldEntity = ETFRenderContext.getCurrentEntity(); - EntityType.getEntityFromNbt(entity_texture_features$parrotNBT, entity_texture_features$player.etf$getWorld()); - Optional optionalEntity = EntityType.getEntityFromNbt(entity_texture_features$parrotNBT, entity_texture_features$player.etf$getWorld()); + EntityType.getEntityFromNbt(entity_texture_features$parrotNBT, playerEntity.getWorld()); + Optional optionalEntity = EntityType.getEntityFromNbt(entity_texture_features$parrotNBT, playerEntity.getWorld()); if (optionalEntity.isPresent() && optionalEntity.get() instanceof ParrotEntity parrot) { ETFRenderContext.setCurrentEntity((ETFEntity) parrot); } @@ -53,9 +53,11 @@ public MixinShoulderParrotFeatureRenderer(FeatureRendererContext type, CallbackInfo ci) { - if (entity_texture_features$parrotNBT != null) { - ETFRenderContext.setCurrentEntity(entity_texture_features$player); + if (entity_texture_features$parrotNBT != null && etf$heldEntity != null) { + ETFRenderContext.setCurrentEntity(etf$heldEntity); } + entity_texture_features$parrotNBT = null; + etf$heldEntity = null; } @Inject(method = "method_17958(Lnet/minecraft/client/util/math/MatrixStack;ZLnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/nbt/NbtCompound;Lnet/minecraft/client/render/VertexConsumerProvider;IFFFFLnet/minecraft/entity/EntityType;)V", diff --git a/common/src/main/java/traben/entity_texture_features/mixin/mods/iris/MixinFullyBufferedMultiBufferSource.java b/common/src/main/java/traben/entity_texture_features/mixin/mods/iris/MixinFullyBufferedMultiBufferSource.java new file mode 100644 index 00000000..896e20c5 --- /dev/null +++ b/common/src/main/java/traben/entity_texture_features/mixin/mods/iris/MixinFullyBufferedMultiBufferSource.java @@ -0,0 +1,45 @@ +package traben.entity_texture_features.mixin.mods.iris; + +import net.coderbot.batchedentityrendering.impl.FullyBufferedMultiBufferSource; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.VertexConsumerProvider; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import traben.entity_texture_features.features.ETFRenderContext; + +/** + * this is a copy of {@link traben.entity_texture_features.mixin.MixinVertexConsumerProvider_Immediate} but for iris's + * custom entity {@link VertexConsumerProvider} + *

+ * this should have no negative impact on iris's render process, other than of course adding more code that needs to run + */ +@Pseudo +@Mixin(FullyBufferedMultiBufferSource.class) +public class MixinFullyBufferedMultiBufferSource { + + + @ModifyVariable( + method = "getBuffer", + at = @At(value = "HEAD"), + index = 1, argsOnly = true) + private RenderLayer etf$modifyRenderLayer(RenderLayer value) { + return ETFRenderContext.modifyRenderLayerIfRequired(value); + } + + + @Inject( + method = "getBuffer", + at = @At(value = "RETURN")) + private void etf$injectIntoGetBufferReturn(RenderLayer renderLayer, CallbackInfoReturnable cir) { + ETFRenderContext.insertETFDataIntoVertexConsumer( + (VertexConsumerProvider) this, + renderLayer, + cir.getReturnValue()); + } + +} diff --git a/common/src/main/java/traben/entity_texture_features/mixin/mods/iris/MixinInnerWrappedRenderType.java b/common/src/main/java/traben/entity_texture_features/mixin/mods/iris/MixinInnerWrappedRenderType.java new file mode 100644 index 00000000..e20a03c9 --- /dev/null +++ b/common/src/main/java/traben/entity_texture_features/mixin/mods/iris/MixinInnerWrappedRenderType.java @@ -0,0 +1,32 @@ +package traben.entity_texture_features.mixin.mods.iris; + +import net.coderbot.iris.layer.InnerWrappedRenderType; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Shadow; +import traben.entity_texture_features.utils.ETFRenderLayerWithTexture; + +import java.util.Optional; + + +/** + * Required in case Iris wraps an instance of {@link ETFRenderLayerWithTexture} + *

+ * This is assumed to be required, whereas I know {@link MixinOuterWrappedRenderType} is required. + */ +@Pseudo +@Mixin(value = InnerWrappedRenderType.class) +public abstract class MixinInnerWrappedRenderType implements ETFRenderLayerWithTexture { + + + @Shadow public abstract RenderLayer unwrap(); + + @Override + public Optional etf$getId() { + if(unwrap() instanceof ETFRenderLayerWithTexture etf) + return etf.etf$getId(); + return Optional.empty(); + } +} diff --git a/common/src/main/java/traben/entity_texture_features/mixin/mods/iris/MixinOuterWrappedRenderType.java b/common/src/main/java/traben/entity_texture_features/mixin/mods/iris/MixinOuterWrappedRenderType.java new file mode 100644 index 00000000..27efb3ff --- /dev/null +++ b/common/src/main/java/traben/entity_texture_features/mixin/mods/iris/MixinOuterWrappedRenderType.java @@ -0,0 +1,30 @@ +package traben.entity_texture_features.mixin.mods.iris; + +import net.coderbot.iris.layer.OuterWrappedRenderType; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Shadow; +import traben.entity_texture_features.utils.ETFRenderLayerWithTexture; + +import java.util.Optional; + + +/** + * Required in case Iris wraps an instance of {@link ETFRenderLayerWithTexture} + */ +@Pseudo +@Mixin(value = OuterWrappedRenderType.class) +public abstract class MixinOuterWrappedRenderType implements ETFRenderLayerWithTexture { + + + @Shadow public abstract RenderLayer unwrap(); + + @Override + public Optional etf$getId() { + if(unwrap() instanceof ETFRenderLayerWithTexture etf) + return etf.etf$getId(); + return Optional.empty(); + } +} diff --git a/common/src/main/java/traben/entity_texture_features/mixin/mods/skin_layers/Mixin3DSkinLayersBody.java b/common/src/main/java/traben/entity_texture_features/mixin/mods/skin_layers/Mixin3DSkinLayersBody.java new file mode 100644 index 00000000..bc5f9544 --- /dev/null +++ b/common/src/main/java/traben/entity_texture_features/mixin/mods/skin_layers/Mixin3DSkinLayersBody.java @@ -0,0 +1,56 @@ +package traben.entity_texture_features.mixin.mods.skin_layers; + +import dev.tr7zw.skinlayers.accessor.PlayerSettings; +import dev.tr7zw.skinlayers.renderlayers.BodyLayerFeatureRenderer; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.entity.LivingEntityRenderer; +import net.minecraft.client.render.item.ItemRenderer; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import traben.entity_texture_features.ETFClientCommon; +import traben.entity_texture_features.features.ETFManager; +import traben.entity_texture_features.features.player.ETFPlayerTexture; + +import static traben.entity_texture_features.ETFClientCommon.ETFConfigData; + +@Pseudo +@Mixin(BodyLayerFeatureRenderer.class) +public abstract class Mixin3DSkinLayersBody { + + + @Shadow public abstract void renderLayers(AbstractClientPlayerEntity abstractClientPlayer, PlayerSettings settings, MatrixStack matrixStack, VertexConsumer vertices, int light, int overlay); + + @Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/network/AbstractClientPlayerEntity;FFFFFF)V", + at = @At(value = "INVOKE", + target = "Ldev/tr7zw/skinlayers/renderlayers/BodyLayerFeatureRenderer;renderLayers(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Ldev/tr7zw/skinlayers/accessor/PlayerSettings;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;II)V", + shift = At.Shift.AFTER)) + private void etf$renderETFHead(MatrixStack poseStack, VertexConsumerProvider multiBufferSource, int i, AbstractClientPlayerEntity player, float f, float g, float h, float j, float k, float l, CallbackInfo ci) { + if (ETFConfigData != null && ETFConfigData.use3DSkinLayerPatch) { + ETFPlayerTexture thisETF = ETFManager.getInstance().getPlayerTexture(player, player.getSkinTextures().texture()); + if (thisETF != null && thisETF.hasFeatures) { + int overlay = LivingEntityRenderer.getOverlay(player, 0.0F); + Identifier emissiveSkin = thisETF.getBaseTextureEmissiveIdentifierOrNullForNone(); + if (emissiveSkin != null) { + VertexConsumer emissive = multiBufferSource.getBuffer(RenderLayer.getEntityTranslucentCull(emissiveSkin)); + renderLayers(player, (PlayerSettings) player, poseStack, emissive, ETFClientCommon.EMISSIVE_FEATURE_LIGHT_VALUE, overlay); + } + Identifier enchantSkin = thisETF.getBaseTextureEnchantIdentifierOrNullForNone(); + if (enchantSkin != null) { + VertexConsumer enchanted = ItemRenderer.getArmorGlintConsumer(multiBufferSource, RenderLayer.getArmorCutoutNoCull(enchantSkin), false, true); + renderLayers(player, (PlayerSettings) player, poseStack, enchanted, i, overlay); + } + } + } + } +} + + diff --git a/common/src/main/java/traben/entity_texture_features/mixin/mods/skin_layers/Mixin3DSkinLayersHead.java b/common/src/main/java/traben/entity_texture_features/mixin/mods/skin_layers/Mixin3DSkinLayersHead.java new file mode 100644 index 00000000..fed78cfa --- /dev/null +++ b/common/src/main/java/traben/entity_texture_features/mixin/mods/skin_layers/Mixin3DSkinLayersHead.java @@ -0,0 +1,56 @@ +package traben.entity_texture_features.mixin.mods.skin_layers; + +import dev.tr7zw.skinlayers.accessor.PlayerSettings; +import dev.tr7zw.skinlayers.renderlayers.HeadLayerFeatureRenderer; +import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.entity.LivingEntityRenderer; +import net.minecraft.client.render.item.ItemRenderer; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import traben.entity_texture_features.ETFClientCommon; +import traben.entity_texture_features.features.ETFManager; +import traben.entity_texture_features.features.player.ETFPlayerTexture; + +import static traben.entity_texture_features.ETFClientCommon.ETFConfigData; + +@Pseudo +@Mixin(HeadLayerFeatureRenderer.class) +public abstract class Mixin3DSkinLayersHead { + + @Shadow + public abstract void renderCustomHelmet(PlayerSettings settings, AbstractClientPlayerEntity abstractClientPlayer, MatrixStack matrixStack, VertexConsumer vertices, int light, int overlay); + + @Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/network/AbstractClientPlayerEntity;FFFFFF)V", + at = @At(value = "INVOKE", + target = "Ldev/tr7zw/skinlayers/renderlayers/HeadLayerFeatureRenderer;renderCustomHelmet(Ldev/tr7zw/skinlayers/accessor/PlayerSettings;Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;II)V", + shift = At.Shift.AFTER)) + private void etf$renderETFHead(MatrixStack poseStack, VertexConsumerProvider multiBufferSource, int i, AbstractClientPlayerEntity player, float f, float g, float h, float j, float k, float l, CallbackInfo ci) { + if (ETFConfigData != null && ETFConfigData.use3DSkinLayerPatch) { + ETFPlayerTexture thisETF = ETFManager.getInstance().getPlayerTexture(player, player.getSkinTextures().texture()); + if (thisETF != null && thisETF.hasFeatures) { + int overlay = LivingEntityRenderer.getOverlay(player, 0.0F); + Identifier emissiveSkin = thisETF.getBaseTextureEmissiveIdentifierOrNullForNone(); + if (emissiveSkin != null) { + VertexConsumer emissive = multiBufferSource.getBuffer(RenderLayer.getEntityTranslucentCull(emissiveSkin)); + renderCustomHelmet((PlayerSettings) player, player, poseStack, emissive, ETFClientCommon.EMISSIVE_FEATURE_LIGHT_VALUE, overlay); + } + Identifier enchantSkin = thisETF.getBaseTextureEnchantIdentifierOrNullForNone(); + if (enchantSkin != null) { + VertexConsumer enchanted = ItemRenderer.getArmorGlintConsumer(multiBufferSource, RenderLayer.getArmorCutoutNoCull(enchantSkin), false, true); + renderCustomHelmet((PlayerSettings) player, player, poseStack, enchanted, i, overlay); + } + } + } + } +} + + diff --git a/common/src/main/java/traben/entity_texture_features/mixin/MixinModelPartSodium.java b/common/src/main/java/traben/entity_texture_features/mixin/mods/sodium/MixinModelPartSodium.java similarity index 70% rename from common/src/main/java/traben/entity_texture_features/mixin/MixinModelPartSodium.java rename to common/src/main/java/traben/entity_texture_features/mixin/mods/sodium/MixinModelPartSodium.java index b3b013c1..1304b2a9 100644 --- a/common/src/main/java/traben/entity_texture_features/mixin/MixinModelPartSodium.java +++ b/common/src/main/java/traben/entity_texture_features/mixin/mods/sodium/MixinModelPartSodium.java @@ -1,4 +1,4 @@ -package traben.entity_texture_features.mixin; +package traben.entity_texture_features.mixin.mods.sodium; import me.jellysquid.mods.sodium.client.render.immediate.model.EntityRenderer; import me.jellysquid.mods.sodium.client.render.vertex.VertexConsumerUtils; @@ -6,6 +6,7 @@ import net.minecraft.client.model.ModelPart; 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; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; @@ -19,6 +20,9 @@ import traben.entity_texture_features.ETFClientCommon; import traben.entity_texture_features.features.ETFManager; import traben.entity_texture_features.features.ETFRenderContext; +import traben.entity_texture_features.features.texture_handlers.ETFTexture; +import traben.entity_texture_features.mixin.MixinModelPart; +import traben.entity_texture_features.utils.ETFVertexConsumer; /** * this is a copy of {@link MixinModelPart} but for sodium's alternative model part render method @@ -46,12 +50,20 @@ public static void render(MatrixStack matrixStack, VertexBufferWriter writer, Mo if (ETFRenderContext.getCurrentModelPartDepth() != 1) { ETFRenderContext.decrementCurrentModelPartDepth(); } else { - if (ETFRenderContext.isRenderReady()) { - //attempt special renders as eager OR checks - if (etf$renderEmissive(matrixStack, part, overlay, color) | - etf$renderEnchanted(matrixStack, part, light, overlay, color)) { - //reset render layer stuff behind the scenes if special renders occurred - ETFRenderContext.getCurrentProvider().getBuffer(ETFRenderContext.getCurrentRenderLayer()); + if (ETFRenderContext.isCurrentlyRenderingEntity() + && writer instanceof ETFVertexConsumer etfVertexConsumer) { + ETFTexture texture = etfVertexConsumer.etf$getETFTexture(); + if(texture != null && (texture.isEmissive() || texture.isEnchanted())) { + VertexConsumerProvider provider = etfVertexConsumer.etf$getProvider(); + RenderLayer layer = etfVertexConsumer.etf$getRenderLayer(); + if (provider != null && layer != null) { + //attempt special renders as eager OR checks + if (etf$renderEmissive(texture, provider, matrixStack, part, overlay, color) | + etf$renderEnchanted(texture, provider, matrixStack, part, light, overlay, color)) { + //reset render layer stuff behind the scenes if special renders occurred + provider.getBuffer(layer); + } + } } } //ensure model count is reset @@ -60,8 +72,8 @@ public static void render(MatrixStack matrixStack, VertexBufferWriter writer, Mo } @Unique - private static boolean etf$renderEmissive(MatrixStack matrices, ModelPart part, int overlay, int color) { - Identifier emissive = ETFRenderContext.getCurrentETFTexture().getEmissiveIdentifierOfCurrentState(); + private static boolean etf$renderEmissive(ETFTexture texture, VertexConsumerProvider provider, MatrixStack matrices, ModelPart part, int overlay, int color) { + Identifier emissive = texture.getEmissiveIdentifierOfCurrentState(); if (emissive != null) { boolean wasAllowed = ETFRenderContext.isAllowedToRenderLayerTextureModify(); ETFRenderContext.preventRenderLayerTextureModify(); @@ -69,7 +81,7 @@ public static void render(MatrixStack matrixStack, VertexBufferWriter writer, Mo boolean textureIsAllowedBrightRender = ETFManager.getEmissiveMode() == ETFManager.EmissiveRenderModes.BRIGHT && ETFRenderContext.getCurrentEntity().etf$canBeBright();// && !ETFRenderContext.getCurrentETFTexture().isPatched_CurrentlyOnlyArmor(); - VertexConsumer emissiveConsumer = ETFRenderContext.getCurrentProvider().getBuffer( + VertexConsumer emissiveConsumer = provider.getBuffer( textureIsAllowedBrightRender ? RenderLayer.getBeaconBeam(emissive, true) : ETFRenderContext.getCurrentEntity().etf$isBlockEntity() ? @@ -95,13 +107,13 @@ public static void render(MatrixStack matrixStack, VertexBufferWriter writer, Mo } @Unique - private static boolean etf$renderEnchanted(MatrixStack matrices, ModelPart part, int light, int overlay, int color) { + private static boolean etf$renderEnchanted(ETFTexture texture, VertexConsumerProvider provider, MatrixStack matrices, ModelPart part, int light, int overlay, int color) { //attempt enchanted render - Identifier enchanted = ETFRenderContext.getCurrentETFTexture().getEnchantIdentifierOfCurrentState(); + Identifier enchanted = texture.getEnchantIdentifierOfCurrentState(); if (enchanted != null) { boolean wasAllowed = ETFRenderContext.isAllowedToRenderLayerTextureModify(); ETFRenderContext.preventRenderLayerTextureModify(); - VertexConsumer enchantedVertex = ItemRenderer.getArmorGlintConsumer(ETFRenderContext.getCurrentProvider(), RenderLayer.getArmorCutoutNoCull(enchanted), false, true); + VertexConsumer enchantedVertex = ItemRenderer.getArmorGlintConsumer(provider, RenderLayer.getArmorCutoutNoCull(enchanted), false, true); if(wasAllowed) ETFRenderContext.allowRenderLayerTextureModify(); //sodium diff --git a/common/src/main/java/traben/entity_texture_features/utils/ETFRenderLayerWithTexture.java b/common/src/main/java/traben/entity_texture_features/utils/ETFRenderLayerWithTexture.java new file mode 100644 index 00000000..78d76967 --- /dev/null +++ b/common/src/main/java/traben/entity_texture_features/utils/ETFRenderLayerWithTexture.java @@ -0,0 +1,10 @@ +package traben.entity_texture_features.utils; + +import net.minecraft.util.Identifier; + +import java.util.Optional; + +public interface ETFRenderLayerWithTexture { + + Optional etf$getId(); +} diff --git a/common/src/main/java/traben/entity_texture_features/utils/ETFUtils2.java b/common/src/main/java/traben/entity_texture_features/utils/ETFUtils2.java index 20ece275..9a434cfe 100644 --- a/common/src/main/java/traben/entity_texture_features/utils/ETFUtils2.java +++ b/common/src/main/java/traben/entity_texture_features/utils/ETFUtils2.java @@ -36,6 +36,8 @@ public abstract class ETFUtils2 { + + @NotNull public static Identifier addVariantNumberSuffix(Identifier identifier, int variant) { return new Identifier(addVariantNumberSuffix(identifier.toString(), variant)); diff --git a/common/src/main/java/traben/entity_texture_features/utils/ETFVertexConsumer.java b/common/src/main/java/traben/entity_texture_features/utils/ETFVertexConsumer.java new file mode 100644 index 00000000..23720089 --- /dev/null +++ b/common/src/main/java/traben/entity_texture_features/utils/ETFVertexConsumer.java @@ -0,0 +1,18 @@ +package traben.entity_texture_features.utils; + +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.VertexConsumerProvider; +import org.jetbrains.annotations.Nullable; +import traben.entity_texture_features.features.texture_handlers.ETFTexture; + +public interface ETFVertexConsumer { + + @Nullable + ETFTexture etf$getETFTexture(); + @Nullable + VertexConsumerProvider etf$getProvider(); + @Nullable + RenderLayer etf$getRenderLayer(); + + void etf$initETFVertexConsumer(VertexConsumerProvider provider, RenderLayer renderLayer); +} diff --git a/common/src/main/resources/entity_texture_features-common.mixins.json b/common/src/main/resources/entity_texture_features-common.mixins.json index 0abf1839..8248e7ce 100644 --- a/common/src/main/resources/entity_texture_features-common.mixins.json +++ b/common/src/main/resources/entity_texture_features-common.mixins.json @@ -4,16 +4,19 @@ "compatibilityLevel": "JAVA_17", "minVersion": "0.8", "client": [ + "MixinBufferBuilder", "MixinIdentifier", "MixinModelPart", + "MixinMultiPhase", "MixinPackScreen", "MixinRenderLayer", "MixinSpriteIdentifier", + "MixinVertexConsumerProvider_Immediate", "accessor.FileCacheAccessor", "accessor.PlayerSkinProviderAccessor", "accessor.PlayerSkinTextureAccessor", "accessor.TooltipAccessor", - "entity.block.MixinMobSpawnerBlockEntityRenderer", + "entity.block.MixinMobSpawnerLogic", "entity.block.MixinSkullBlockEntityRenderer", "entity.misc.MixinBlazeEntity", "entity.misc.MixinBlockEntity", @@ -32,9 +35,14 @@ "entity.renderer.feature.MixinMooshroomMushroomFeatureRenderer", "entity.renderer.feature.MixinShoulderParrotFeatureRenderer", "entity.renderer.feature.MixinWardenFeatureRenderer", + "mods.iris.MixinFullyBufferedMultiBufferSource", + "mods.iris.MixinInnerWrappedRenderType", + "mods.iris.MixinOuterWrappedRenderType", + "mods.skin_layers.Mixin3DSkinLayersBody", + "mods.skin_layers.Mixin3DSkinLayersHead", + "mods.sodium.MixinModelPartSodium", "reloading.MixinMinecraftClient", - "reloading.MixinResourceReload", - "MixinModelPartSodium" + "reloading.MixinResourceReload" ], "mixins": [ ], diff --git a/fabric/build.gradle b/fabric/build.gradle index 14749642..52e39af2 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -2,7 +2,7 @@ plugins { id "com.github.johnrengelman.shadow" version "8.1.1" } -archivesBaseName = rootProject.archives_base_name + "_fabric_1.20.3" +archivesBaseName = rootProject.archives_base_name + "_fabric_1.20.4" architectury { platformSetupLoomIde() diff --git a/fabric/src/main/java/traben/entity_texture_features/fabric/mixin/MixinArmorFeatureRenderer.java b/fabric/src/main/java/traben/entity_texture_features/fabric/mixin/MixinArmorFeatureRenderer.java index 494bafdd..93fa31d7 100644 --- a/fabric/src/main/java/traben/entity_texture_features/fabric/mixin/MixinArmorFeatureRenderer.java +++ b/fabric/src/main/java/traben/entity_texture_features/fabric/mixin/MixinArmorFeatureRenderer.java @@ -26,6 +26,7 @@ import traben.entity_texture_features.features.ETFManager; import traben.entity_texture_features.features.ETFRenderContext; import traben.entity_texture_features.features.texture_handlers.ETFTexture; +import traben.entity_texture_features.utils.ETFVertexConsumer; import static traben.entity_texture_features.ETFClientCommon.ETFConfigData; @@ -127,14 +128,16 @@ public MixinArmorFeatureRenderer(FeatureRendererContext context) { index = 1) private VertexConsumer etf$changeTrim(VertexConsumer par2) { //allow a specified override trim texture if you dont want to be confined by a pallette - if(thisETFTrimTexture!= null){ + if(thisETFTrimTexture!= null + && par2 instanceof ETFVertexConsumer etfVertexConsumer + && etfVertexConsumer.etf$getProvider() != null){ if(thisETFTrimTexture.exists()){ - return ETFRenderContext.getCurrentProvider().getBuffer(RenderLayer.getArmorCutoutNoCull(thisETFTrimTexture.getTextureIdentifier(null))); + return etfVertexConsumer.etf$getProvider().getBuffer(RenderLayer.getArmorCutoutNoCull(thisETFTrimTexture.getTextureIdentifier(null))); }else if (thisETFTrimTexture.isEmissive() && ETFConfigData.enableEmissiveTextures && ETFClientCommon.IRIS_DETECTED){ //iris is weird and will always render the armor trim atlas over everything else // if for some reason no trim texture is present then just dont render it at all // this is to favour packs with fully emissive trims :/ - return ETFRenderContext.getCurrentProvider().getBuffer(RenderLayer.getArmorCutoutNoCull(ETFManager.getErrorETFTexture().thisIdentifier)); + return etfVertexConsumer.etf$getProvider().getBuffer(RenderLayer.getArmorCutoutNoCull(ETFManager.getErrorETFTexture().thisIdentifier)); } } return par2; diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 8b275242..c11a8c4b 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -36,7 +36,7 @@ "entity_texture_features-fabric.mixins.json", "entity_texture_features-common.mixins.json" ], - "accessWidener": "entity_texture_features.accesswidener", + "depends": { "fabricloader": ">=0.14.0", "minecraft": ">=1.20.3 " diff --git a/forge/build.gradle b/forge/build.gradle index 80d6a396..da05bf43 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -2,7 +2,7 @@ plugins { id "com.github.johnrengelman.shadow" version "8.1.1" } -archivesBaseName = rootProject.archives_base_name + "_forge_1.20.3" +archivesBaseName = rootProject.archives_base_name + "_forge_1.20.4" architectury { platformSetupLoomIde() @@ -35,7 +35,8 @@ dependencies { // Remove the next line if you don't want to depend on the API //modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" +// mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } diff --git a/forge/src/main/java/traben/entity_texture_features/neoforge/ETFClientForge.java b/forge/src/main/java/traben/entity_texture_features/forge/ETFClientForge.java similarity index 97% rename from forge/src/main/java/traben/entity_texture_features/neoforge/ETFClientForge.java rename to forge/src/main/java/traben/entity_texture_features/forge/ETFClientForge.java index d49f5d41..b352a93c 100644 --- a/forge/src/main/java/traben/entity_texture_features/neoforge/ETFClientForge.java +++ b/forge/src/main/java/traben/entity_texture_features/forge/ETFClientForge.java @@ -1,4 +1,4 @@ -package traben.entity_texture_features.neoforge; +package traben.entity_texture_features.forge; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.ConfigScreenHandler; diff --git a/forge/src/main/java/traben/entity_texture_features/neoforge/ETFVersionDifferenceHandlerImpl.java b/forge/src/main/java/traben/entity_texture_features/forge/ETFVersionDifferenceHandlerImpl.java similarity index 96% rename from forge/src/main/java/traben/entity_texture_features/neoforge/ETFVersionDifferenceHandlerImpl.java rename to forge/src/main/java/traben/entity_texture_features/forge/ETFVersionDifferenceHandlerImpl.java index cf9930e5..1be82cf5 100644 --- a/forge/src/main/java/traben/entity_texture_features/neoforge/ETFVersionDifferenceHandlerImpl.java +++ b/forge/src/main/java/traben/entity_texture_features/forge/ETFVersionDifferenceHandlerImpl.java @@ -1,4 +1,4 @@ -package traben.entity_texture_features.neoforge; +package traben.entity_texture_features.forge; import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; diff --git a/forge/src/main/java/traben/entity_texture_features/neoforge/mixin/MixinArmorFeatureRenderer.java b/forge/src/main/java/traben/entity_texture_features/forge/mixin/MixinArmorFeatureRenderer.java similarity index 94% rename from forge/src/main/java/traben/entity_texture_features/neoforge/mixin/MixinArmorFeatureRenderer.java rename to forge/src/main/java/traben/entity_texture_features/forge/mixin/MixinArmorFeatureRenderer.java index c2beb3ea..4dafb725 100644 --- a/forge/src/main/java/traben/entity_texture_features/neoforge/mixin/MixinArmorFeatureRenderer.java +++ b/forge/src/main/java/traben/entity_texture_features/forge/mixin/MixinArmorFeatureRenderer.java @@ -1,4 +1,4 @@ -package traben.entity_texture_features.neoforge.mixin; +package traben.entity_texture_features.forge.mixin; import net.minecraft.client.MinecraftClient; import net.minecraft.client.model.Model; @@ -27,6 +27,7 @@ import traben.entity_texture_features.features.ETFManager; import traben.entity_texture_features.features.ETFRenderContext; import traben.entity_texture_features.features.texture_handlers.ETFTexture; +import traben.entity_texture_features.utils.ETFVertexConsumer; import static traben.entity_texture_features.ETFClientCommon.ETFConfigData; @@ -131,14 +132,16 @@ public MixinArmorFeatureRenderer(FeatureRendererContext context) { index = 1) private VertexConsumer etf$changeTrim(VertexConsumer par2) { //allow a specified override trim texture if you dont want to be confined by a pallette - if(thisETF$TrimTexture!= null){ + if(thisETF$TrimTexture!= null + && par2 instanceof ETFVertexConsumer etfVertexConsumer + && etfVertexConsumer.etf$getProvider() != null){ if(thisETF$TrimTexture.exists()){ - return ETFRenderContext.getCurrentProvider().getBuffer(RenderLayer.getArmorCutoutNoCull(thisETF$TrimTexture.getTextureIdentifier(null))); + return etfVertexConsumer.etf$getProvider().getBuffer(RenderLayer.getArmorCutoutNoCull(thisETF$TrimTexture.getTextureIdentifier(null))); }else if (ETFConfigData.enableEmissiveTextures && thisETF$TrimTexture.isEmissive() && ETFClientCommon.IRIS_DETECTED){ //iris is weird and will always render the armor trim atlas over everything else // if for some reason no trim texture is present then just dont render it at all // this is to favour packs with fully emissive trims :/ - return ETFRenderContext.getCurrentProvider().getBuffer(RenderLayer.getArmorCutoutNoCull(ETFManager.getErrorETFTexture().thisIdentifier)); + return etfVertexConsumer.etf$getProvider().getBuffer(RenderLayer.getArmorCutoutNoCull(ETFManager.getErrorETFTexture().thisIdentifier)); } } return par2; diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index a9058cf6..c2e51ac5 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader = "javafml" -loaderVersion = "[48,)" +loaderVersion = "[49,)" issueTrackerURL = "https://github.com/Traben-0/EmissiveMod/issues" license = "LGPL-3.0" showAsResourcePack = false @@ -23,7 +23,7 @@ logoFile = "icon.png" [[dependencies.entity_texture_features]] modId = "forge" mandatory = true -versionRange = "[48,)" +versionRange = "[49,)" ordering = "NONE" side = "CLIENT" diff --git a/forge/src/main/resources/entity_texture_features-forge.mixins.json b/forge/src/main/resources/entity_texture_features-forge.mixins.json index 4ed5de6a..70bb2787 100644 --- a/forge/src/main/resources/entity_texture_features-forge.mixins.json +++ b/forge/src/main/resources/entity_texture_features-forge.mixins.json @@ -1,6 +1,6 @@ { "required": true, - "package": "traben.entity_texture_features.neoforge.mixin", + "package": "traben.entity_texture_features.forge.mixin", "compatibilityLevel": "JAVA_17", "minVersion": "0.8", "client": [ diff --git a/gradle.properties b/gradle.properties index a8f010ba..0060504d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,16 +1,17 @@ org.gradle.jvmargs=-Xmx4096M -enabled_platforms=fabric +enabled_platforms=fabric,neoforge,forge archives_base_name=entity_texture_features -mod_version=5.0 +mod_version=5.1 maven_group=traben.entity_texture_features architectury_version=5.6.22 fabric_loader_version=0.15.0 -fabric_api_version=0.91.1+1.20.3 -modmenu_version=TwfjidT5 -forge_version=1.20.2-48.0.33 -neoforge_version=20.3.1-beta -minecraft_version=1.20.3 -yarn_mappings=1.20.3+build.1 +fabric_api_version=0.91.1+1.20.4 +modmenu_version=sjtVVlsA +forge_version=1.20.4-49.0.12 +neoforge_version=20.4.63-beta +minecraft_version=1.20.4 +yarn_mappings=1.20.4+build.1 skinlayers_version=q77puo5I skinlayers_version_forge=42BoJdTc -sodium_version=zPwAvKCF \ No newline at end of file +sodium_version=InGKdfel +iris_version=Xl7oywRL \ No newline at end of file diff --git a/neoforge/build.gradle b/neoforge/build.gradle index e77a0025..9f7a9d14 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -2,7 +2,7 @@ plugins { id "com.github.johnrengelman.shadow" version "8.1.1" } -archivesBaseName = rootProject.archives_base_name + "_neoforge_1.20.3" +archivesBaseName = rootProject.archives_base_name + "_neoforge_1.20.4" architectury { platformSetupLoomIde() diff --git a/neoforge/src/main/java/traben/entity_texture_features/neoforge/mixin/MixinArmorFeatureRenderer.java b/neoforge/src/main/java/traben/entity_texture_features/neoforge/mixin/MixinArmorFeatureRenderer.java index c2beb3ea..687e795f 100644 --- a/neoforge/src/main/java/traben/entity_texture_features/neoforge/mixin/MixinArmorFeatureRenderer.java +++ b/neoforge/src/main/java/traben/entity_texture_features/neoforge/mixin/MixinArmorFeatureRenderer.java @@ -27,6 +27,7 @@ import traben.entity_texture_features.features.ETFManager; import traben.entity_texture_features.features.ETFRenderContext; import traben.entity_texture_features.features.texture_handlers.ETFTexture; +import traben.entity_texture_features.utils.ETFVertexConsumer; import static traben.entity_texture_features.ETFClientCommon.ETFConfigData; @@ -131,14 +132,16 @@ public MixinArmorFeatureRenderer(FeatureRendererContext context) { index = 1) private VertexConsumer etf$changeTrim(VertexConsumer par2) { //allow a specified override trim texture if you dont want to be confined by a pallette - if(thisETF$TrimTexture!= null){ + if(thisETF$TrimTexture!= null + && par2 instanceof ETFVertexConsumer etfVertexConsumer + && etfVertexConsumer.etf$getProvider() != null){ if(thisETF$TrimTexture.exists()){ - return ETFRenderContext.getCurrentProvider().getBuffer(RenderLayer.getArmorCutoutNoCull(thisETF$TrimTexture.getTextureIdentifier(null))); + return etfVertexConsumer.etf$getProvider().getBuffer(RenderLayer.getArmorCutoutNoCull(thisETF$TrimTexture.getTextureIdentifier(null))); }else if (ETFConfigData.enableEmissiveTextures && thisETF$TrimTexture.isEmissive() && ETFClientCommon.IRIS_DETECTED){ //iris is weird and will always render the armor trim atlas over everything else // if for some reason no trim texture is present then just dont render it at all // this is to favour packs with fully emissive trims :/ - return ETFRenderContext.getCurrentProvider().getBuffer(RenderLayer.getArmorCutoutNoCull(ETFManager.getErrorETFTexture().thisIdentifier)); + return etfVertexConsumer.etf$getProvider().getBuffer(RenderLayer.getArmorCutoutNoCull(ETFManager.getErrorETFTexture().thisIdentifier)); } } return par2; diff --git a/settings.gradle b/settings.gradle index 88dc9d67..6fa8b817 100644 --- a/settings.gradle +++ b/settings.gradle @@ -9,7 +9,7 @@ pluginManagement { include("common") include("fabric") -//include("forge") -//include("neoforge") +include("forge") +include("neoforge") rootProject.name = "entity-texture-features"