From e44892389c16c34fa9cc5826820db60b9d4cbee9 Mon Sep 17 00:00:00 2001 From: "petrak@" Date: Fri, 17 Feb 2023 20:56:39 -0600 Subject: [PATCH] this isn't working --- .../client/PatternShapeMatcher.java | 4 -- .../BlockEntityAkashicBookshelfRenderer.java | 4 +- .../client/be/BlockEntitySlateRenderer.java | 4 +- .../client/entity/WallScrollRenderer.java | 12 ++--- .../hexcasting/client/gui/GuiSpellcasting.kt | 10 +++-- .../client/gui/PatternTooltipComponent.java | 4 +- .../{ => render}/HexAdditionalRenderers.java | 3 +- .../client/render/PatternShapeMatcher.java | 4 ++ .../client/{ => render}/RenderLib.kt | 3 +- .../{ => render}/shader/FakeBufferSource.java | 7 +-- .../{ => render}/shader/HexRenderTypes.java | 24 +++++----- .../{ => render}/shader/HexShaders.java | 9 ++-- .../common/entities/EntityWallScroll.java | 2 +- .../patchouli/AbstractPatternComponent.java | 2 +- .../interop/utils/PatternDrawingUtil.java | 8 ++-- .../mixin/client/MixinElytraLayer.java | 41 ++++++++++++++++++ .../hexcasting/textures/misc/altiora.png | Bin 0 -> 419 bytes Common/src/main/resources/hexplat.mixins.json | 3 +- .../fabric/FabricHexClientInitializer.kt | 2 +- .../fabric/cc/HexCardinalComponents.java | 3 +- .../interop/emi/BrainsweepeeEmiStack.java | 2 +- .../mixin/client/FabricMixinElytraLayer.java | 35 +++++++++++++++ .../mixin/client/FabricMixinGameRenderer.java | 22 +++++----- .../main/resources/fabricasting.mixins.json | 1 + .../forge/ForgeHexClientInitializer.java | 4 +- .../hexcasting/forge/cap/CapSyncers.java | 1 + .../interop/jei/BrainsweepRecipeCategory.java | 2 +- .../mixin/client/ForgeMixinElytraLayer.java | 30 +++++++++++++ .../forge/xplat/ForgeXplatImpl.java | 7 +-- .../resources/hexcasting_forge.mixins.json | 12 +++-- 30 files changed, 191 insertions(+), 74 deletions(-) delete mode 100644 Common/src/main/java/at/petrak/hexcasting/client/PatternShapeMatcher.java rename Common/src/main/java/at/petrak/hexcasting/client/{ => render}/HexAdditionalRenderers.java (98%) create mode 100644 Common/src/main/java/at/petrak/hexcasting/client/render/PatternShapeMatcher.java rename Common/src/main/java/at/petrak/hexcasting/client/{ => render}/RenderLib.kt (99%) rename Common/src/main/java/at/petrak/hexcasting/client/{ => render}/shader/FakeBufferSource.java (82%) rename Common/src/main/java/at/petrak/hexcasting/client/{ => render}/shader/HexRenderTypes.java (65%) rename Common/src/main/java/at/petrak/hexcasting/client/{ => render}/shader/HexShaders.java (68%) create mode 100644 Common/src/main/java/at/petrak/hexcasting/mixin/client/MixinElytraLayer.java create mode 100644 Common/src/main/resources/assets/hexcasting/textures/misc/altiora.png create mode 100644 Fabric/src/main/java/at/petrak/hexcasting/fabric/mixin/client/FabricMixinElytraLayer.java create mode 100644 Forge/src/main/java/at/petrak/hexcasting/forge/mixin/client/ForgeMixinElytraLayer.java diff --git a/Common/src/main/java/at/petrak/hexcasting/client/PatternShapeMatcher.java b/Common/src/main/java/at/petrak/hexcasting/client/PatternShapeMatcher.java deleted file mode 100644 index dbe366ce..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/client/PatternShapeMatcher.java +++ /dev/null @@ -1,4 +0,0 @@ -package at.petrak.hexcasting.client; - -public class PatternShapeMatcher { -} diff --git a/Common/src/main/java/at/petrak/hexcasting/client/be/BlockEntityAkashicBookshelfRenderer.java b/Common/src/main/java/at/petrak/hexcasting/client/be/BlockEntityAkashicBookshelfRenderer.java index 8c3ab958..f50ffa98 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/be/BlockEntityAkashicBookshelfRenderer.java +++ b/Common/src/main/java/at/petrak/hexcasting/client/be/BlockEntityAkashicBookshelfRenderer.java @@ -1,7 +1,7 @@ package at.petrak.hexcasting.client.be; import at.petrak.hexcasting.api.casting.math.HexPattern; -import at.petrak.hexcasting.client.RenderLib; +import at.petrak.hexcasting.client.render.RenderLib; import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicBookshelf; import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicBookshelf; import com.mojang.blaze3d.systems.RenderSystem; @@ -22,7 +22,7 @@ public class BlockEntityAkashicBookshelfRenderer implements BlockEntityRenderer< @Override public void render(BlockEntityAkashicBookshelf tile, float pPartialTick, PoseStack ps, - MultiBufferSource buffer, int light, int overlay) { + MultiBufferSource buffer, int light, int overlay) { HexPattern pattern = tile.getPattern(); if (pattern == null) { return; diff --git a/Common/src/main/java/at/petrak/hexcasting/client/be/BlockEntitySlateRenderer.java b/Common/src/main/java/at/petrak/hexcasting/client/be/BlockEntitySlateRenderer.java index 5713ed8d..441c6af9 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/be/BlockEntitySlateRenderer.java +++ b/Common/src/main/java/at/petrak/hexcasting/client/be/BlockEntitySlateRenderer.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.client.be; -import at.petrak.hexcasting.client.RenderLib; +import at.petrak.hexcasting.client.render.RenderLib; import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate; import at.petrak.hexcasting.common.blocks.circles.BlockSlate; import com.mojang.blaze3d.systems.RenderSystem; @@ -22,7 +22,7 @@ public class BlockEntitySlateRenderer implements BlockEntityRenderer { // I do as the PaintingRenderer guides @Override public void render(EntityWallScroll wallScroll, float yaw, float partialTicks, PoseStack ps, - MultiBufferSource bufSource, int packedLight) { + MultiBufferSource bufSource, int packedLight) { RenderSystem.setShader(GameRenderer::getPositionTexShader); @@ -158,8 +158,8 @@ public class WallScrollRenderer extends EntityRenderer { } private static void vertex(Matrix4f mat, Matrix3f normal, int light, VertexConsumer verts, float x, float y, - float z, float u, - float v, float nx, float ny, float nz) { + float z, float u, + float v, float nx, float ny, float nz) { verts.vertex(mat, x, y, z) .color(0xffffffff) .uv(u, v).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light) @@ -176,7 +176,7 @@ public class WallScrollRenderer extends EntityRenderer { } private static void theCoolerDrawLineSeq(Matrix4f mat, Matrix3f normalMat, int light, VertexConsumer verts, - List points, float width, int color + List points, float width, int color ) { if (points.size() <= 1) { return; @@ -285,7 +285,7 @@ public class WallScrollRenderer extends EntityRenderer { } private static void theCoolerDrawSpot(Matrix4f mat, Matrix3f normal, int light, VertexConsumer verts, - Vec2 point, float radius, int color) { + Vec2 point, float radius, int color) { var fracOfCircle = 6; for (int i = 0; i < fracOfCircle; i++) { // We do need rects, irritatingly diff --git a/Common/src/main/java/at/petrak/hexcasting/client/gui/GuiSpellcasting.kt b/Common/src/main/java/at/petrak/hexcasting/client/gui/GuiSpellcasting.kt index c4a934bd..337728a3 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/gui/GuiSpellcasting.kt +++ b/Common/src/main/java/at/petrak/hexcasting/client/gui/GuiSpellcasting.kt @@ -1,8 +1,5 @@ package at.petrak.hexcasting.client.gui -import at.petrak.hexcasting.api.misc.DiscoveryHandlers -import at.petrak.hexcasting.api.mod.HexConfig -import at.petrak.hexcasting.api.mod.HexTags import at.petrak.hexcasting.api.casting.eval.ControllerInfo import at.petrak.hexcasting.api.casting.eval.ResolvedPattern import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType @@ -10,9 +7,14 @@ import at.petrak.hexcasting.api.casting.math.HexAngle import at.petrak.hexcasting.api.casting.math.HexCoord import at.petrak.hexcasting.api.casting.math.HexDir import at.petrak.hexcasting.api.casting.math.HexPattern +import at.petrak.hexcasting.api.misc.DiscoveryHandlers +import at.petrak.hexcasting.api.mod.HexConfig +import at.petrak.hexcasting.api.mod.HexTags import at.petrak.hexcasting.api.utils.asTranslatedComponent -import at.petrak.hexcasting.client.* +import at.petrak.hexcasting.client.ClientTickCounter +import at.petrak.hexcasting.client.ShiftScrollListener import at.petrak.hexcasting.client.ktxt.accumulatedScroll +import at.petrak.hexcasting.client.render.* import at.petrak.hexcasting.client.sound.GridSoundInstance import at.petrak.hexcasting.common.lib.HexSounds import at.petrak.hexcasting.common.lib.hex.HexIotaTypes diff --git a/Common/src/main/java/at/petrak/hexcasting/client/gui/PatternTooltipComponent.java b/Common/src/main/java/at/petrak/hexcasting/client/gui/PatternTooltipComponent.java index 0d7a6e12..3e0801e9 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/gui/PatternTooltipComponent.java +++ b/Common/src/main/java/at/petrak/hexcasting/client/gui/PatternTooltipComponent.java @@ -1,7 +1,7 @@ package at.petrak.hexcasting.client.gui; import at.petrak.hexcasting.api.casting.math.HexPattern; -import at.petrak.hexcasting.client.RenderLib; +import at.petrak.hexcasting.client.render.RenderLib; import at.petrak.hexcasting.common.misc.PatternTooltip; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; @@ -64,7 +64,7 @@ public class PatternTooltipComponent implements ClientTooltipComponent { @Override public void renderImage(Font font, int mouseX, int mouseY, PoseStack ps, ItemRenderer pItemRenderer, - int pBlitOffset) { + int pBlitOffset) { var width = this.getWidth(font); var height = this.getHeight(); diff --git a/Common/src/main/java/at/petrak/hexcasting/client/HexAdditionalRenderers.java b/Common/src/main/java/at/petrak/hexcasting/client/render/HexAdditionalRenderers.java similarity index 98% rename from Common/src/main/java/at/petrak/hexcasting/client/HexAdditionalRenderers.java rename to Common/src/main/java/at/petrak/hexcasting/client/render/HexAdditionalRenderers.java index 7817e966..2c29c70a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/HexAdditionalRenderers.java +++ b/Common/src/main/java/at/petrak/hexcasting/client/render/HexAdditionalRenderers.java @@ -1,8 +1,9 @@ -package at.petrak.hexcasting.client; +package at.petrak.hexcasting.client.render; import at.petrak.hexcasting.api.client.ScryingLensOverlayRegistry; import at.petrak.hexcasting.api.misc.DiscoveryHandlers; import at.petrak.hexcasting.api.player.Sentinel; +import at.petrak.hexcasting.client.ClientTickCounter; import at.petrak.hexcasting.xplat.IXplatAbstractions; import com.google.common.collect.Lists; import com.mojang.blaze3d.platform.GlStateManager; diff --git a/Common/src/main/java/at/petrak/hexcasting/client/render/PatternShapeMatcher.java b/Common/src/main/java/at/petrak/hexcasting/client/render/PatternShapeMatcher.java new file mode 100644 index 00000000..b8f71c5a --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/client/render/PatternShapeMatcher.java @@ -0,0 +1,4 @@ +package at.petrak.hexcasting.client.render; + +public class PatternShapeMatcher { +} diff --git a/Common/src/main/java/at/petrak/hexcasting/client/RenderLib.kt b/Common/src/main/java/at/petrak/hexcasting/client/render/RenderLib.kt similarity index 99% rename from Common/src/main/java/at/petrak/hexcasting/client/RenderLib.kt rename to Common/src/main/java/at/petrak/hexcasting/client/render/RenderLib.kt index 7bf6923a..e6827be3 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/RenderLib.kt +++ b/Common/src/main/java/at/petrak/hexcasting/client/render/RenderLib.kt @@ -1,10 +1,11 @@ @file:JvmName("RenderLib") -package at.petrak.hexcasting.client +package at.petrak.hexcasting.client.render import at.petrak.hexcasting.api.casting.math.HexPattern import at.petrak.hexcasting.api.mod.HexConfig import at.petrak.hexcasting.api.utils.TAU +import at.petrak.hexcasting.client.ClientTickCounter import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack diff --git a/Common/src/main/java/at/petrak/hexcasting/client/shader/FakeBufferSource.java b/Common/src/main/java/at/petrak/hexcasting/client/render/shader/FakeBufferSource.java similarity index 82% rename from Common/src/main/java/at/petrak/hexcasting/client/shader/FakeBufferSource.java rename to Common/src/main/java/at/petrak/hexcasting/client/render/shader/FakeBufferSource.java index 2a5443bd..78d7d160 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/shader/FakeBufferSource.java +++ b/Common/src/main/java/at/petrak/hexcasting/client/render/shader/FakeBufferSource.java @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.client.shader; +package at.petrak.hexcasting.client.render.shader; import at.petrak.hexcasting.mixin.accessor.client.AccessorCompositeRenderType; import at.petrak.hexcasting.mixin.accessor.client.AccessorEmptyTextureStateShard; @@ -13,13 +13,14 @@ import org.jetbrains.annotations.NotNull; import java.util.Optional; import java.util.function.Function; -public record FakeBufferSource(MultiBufferSource parent, Function mapper) implements MultiBufferSource { +public record FakeBufferSource(MultiBufferSource parent, + Function mapper) implements MultiBufferSource { @Override @SuppressWarnings("ConstantConditions") public @NotNull VertexConsumer getBuffer(@NotNull RenderType renderType) { if (((AccessorRenderStateShard) renderType).hex$name().equals("entity_cutout_no_cull") - && renderType instanceof RenderType.CompositeRenderType) { + && renderType instanceof RenderType.CompositeRenderType) { RenderType.CompositeState state = ((AccessorCompositeRenderType) renderType).hex$state(); RenderStateShard.EmptyTextureStateShard shard = state.textureState; Optional texture = ((AccessorEmptyTextureStateShard) shard).hex$cutoutTexture(); diff --git a/Common/src/main/java/at/petrak/hexcasting/client/shader/HexRenderTypes.java b/Common/src/main/java/at/petrak/hexcasting/client/render/shader/HexRenderTypes.java similarity index 65% rename from Common/src/main/java/at/petrak/hexcasting/client/shader/HexRenderTypes.java rename to Common/src/main/java/at/petrak/hexcasting/client/render/shader/HexRenderTypes.java index 57244037..ff9e549a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/shader/HexRenderTypes.java +++ b/Common/src/main/java/at/petrak/hexcasting/client/render/shader/HexRenderTypes.java @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.client.shader; +package at.petrak.hexcasting.client.render.shader; import at.petrak.hexcasting.api.HexAPI; import at.petrak.hexcasting.mixin.accessor.client.AccessorRenderType; @@ -13,27 +13,29 @@ import java.util.function.Function; // https://github.com/VazkiiMods/Botania/blob/3a43accc2fbc439c9f2f00a698f8f8ad017503db/Common/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java public final class HexRenderTypes extends RenderType { - private HexRenderTypes(String string, VertexFormat vertexFormat, VertexFormat.Mode mode, int i, boolean bl, boolean bl2, Runnable runnable, Runnable runnable2) { + private HexRenderTypes(String string, VertexFormat vertexFormat, VertexFormat.Mode mode, int i, boolean bl, + boolean bl2, Runnable runnable, Runnable runnable2) { super(string, vertexFormat, mode, i, bl, bl2, runnable, runnable2); throw new UnsupportedOperationException("Should not be instantiated"); } private static RenderType makeLayer(String name, VertexFormat format, VertexFormat.Mode mode, - int bufSize, boolean hasCrumbling, boolean sortOnUpload, RenderType.CompositeState glState) { + int bufSize, boolean hasCrumbling, boolean sortOnUpload, RenderType.CompositeState glState) { return AccessorRenderType.hex$create(name, format, mode, bufSize, hasCrumbling, sortOnUpload, glState); } private static final Function GRAYSCALE_PROVIDER = Util.memoize(texture -> { CompositeState glState = RenderType.CompositeState.builder() - .setShaderState(new ShaderStateShard(HexShaders::grayscale)) - .setTextureState(new TextureStateShard(texture, false, false)) - .setTransparencyState(NO_TRANSPARENCY) - .setCullState(NO_CULL) - .setLightmapState(LIGHTMAP) - .setOverlayState(OVERLAY) - .createCompositeState(true); + .setShaderState(new ShaderStateShard(HexShaders::grayscale)) + .setTextureState(new TextureStateShard(texture, false, false)) + .setTransparencyState(NO_TRANSPARENCY) + .setCullState(NO_CULL) + .setLightmapState(LIGHTMAP) + .setOverlayState(OVERLAY) + .createCompositeState(true); - return makeLayer(HexAPI.MOD_ID + ":grayscale", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, glState); + return makeLayer(HexAPI.MOD_ID + ":grayscale", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, + true, false, glState); }); public static RenderType getGrayscaleLayer(ResourceLocation texture) { diff --git a/Common/src/main/java/at/petrak/hexcasting/client/shader/HexShaders.java b/Common/src/main/java/at/petrak/hexcasting/client/render/shader/HexShaders.java similarity index 68% rename from Common/src/main/java/at/petrak/hexcasting/client/shader/HexShaders.java rename to Common/src/main/java/at/petrak/hexcasting/client/render/shader/HexShaders.java index e0f3f39d..4e41ce94 100644 --- a/Common/src/main/java/at/petrak/hexcasting/client/shader/HexShaders.java +++ b/Common/src/main/java/at/petrak/hexcasting/client/render/shader/HexShaders.java @@ -1,4 +1,4 @@ -package at.petrak.hexcasting.client.shader; +package at.petrak.hexcasting.client.render.shader; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.datafixers.util.Pair; @@ -11,11 +11,12 @@ import java.util.function.Consumer; // https://github.com/VazkiiMods/Botania/blob/3a43accc2fbc439c9f2f00a698f8f8ad017503db/Common/src/main/java/vazkii/botania/client/core/helper/CoreShaders.java public class HexShaders { private static ShaderInstance grayscale; + public static void init(ResourceManager resourceManager, - Consumer>> registrations) throws IOException { + Consumer>> registrations) throws IOException { registrations.accept(Pair.of( - new ShaderInstance(resourceManager, "hexcasting__grayscale", DefaultVertexFormat.NEW_ENTITY), - inst -> grayscale = inst) + new ShaderInstance(resourceManager, "hexcasting__grayscale", DefaultVertexFormat.NEW_ENTITY), + inst -> grayscale = inst) ); } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/entities/EntityWallScroll.java b/Common/src/main/java/at/petrak/hexcasting/common/entities/EntityWallScroll.java index aa78c9b0..ed285a97 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/entities/EntityWallScroll.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/entities/EntityWallScroll.java @@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.entities; import at.petrak.hexcasting.api.casting.math.HexPattern; import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.api.utils.NBTHelper; -import at.petrak.hexcasting.client.RenderLib; +import at.petrak.hexcasting.client.render.RenderLib; import at.petrak.hexcasting.common.items.storage.ItemScroll; import at.petrak.hexcasting.common.lib.HexItems; import at.petrak.hexcasting.common.lib.HexSounds; diff --git a/Common/src/main/java/at/petrak/hexcasting/interop/patchouli/AbstractPatternComponent.java b/Common/src/main/java/at/petrak/hexcasting/interop/patchouli/AbstractPatternComponent.java index 47c36f18..928a90b2 100644 --- a/Common/src/main/java/at/petrak/hexcasting/interop/patchouli/AbstractPatternComponent.java +++ b/Common/src/main/java/at/petrak/hexcasting/interop/patchouli/AbstractPatternComponent.java @@ -2,7 +2,7 @@ package at.petrak.hexcasting.interop.patchouli; import at.petrak.hexcasting.api.casting.math.HexCoord; import at.petrak.hexcasting.api.casting.math.HexPattern; -import at.petrak.hexcasting.client.RenderLib; +import at.petrak.hexcasting.client.render.RenderLib; import at.petrak.hexcasting.interop.utils.PatternDrawingUtil; import at.petrak.hexcasting.interop.utils.PatternEntry; import com.mojang.blaze3d.vertex.PoseStack; diff --git a/Common/src/main/java/at/petrak/hexcasting/interop/utils/PatternDrawingUtil.java b/Common/src/main/java/at/petrak/hexcasting/interop/utils/PatternDrawingUtil.java index 382b0a07..dd770c4c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/interop/utils/PatternDrawingUtil.java +++ b/Common/src/main/java/at/petrak/hexcasting/interop/utils/PatternDrawingUtil.java @@ -3,7 +3,7 @@ package at.petrak.hexcasting.interop.utils; import at.petrak.hexcasting.api.casting.math.HexCoord; import at.petrak.hexcasting.api.casting.math.HexPattern; import at.petrak.hexcasting.api.utils.HexUtils; -import at.petrak.hexcasting.client.RenderLib; +import at.petrak.hexcasting.client.render.RenderLib; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; @@ -19,8 +19,8 @@ import java.util.List; public final class PatternDrawingUtil { public static void drawPattern(PoseStack poseStack, int x, int y, List patterns, List dots, - boolean strokeOrder, int outer, int innerLight, int innerDark, - int dotColor) { + boolean strokeOrder, int outer, int innerLight, int innerDark, + int dotColor) { poseStack.pushPose(); poseStack.translate(x, y, 1); var mat = poseStack.last().pose(); @@ -61,7 +61,7 @@ public final class PatternDrawingUtil { } public static PatternRenderingData loadPatterns(List> patterns, - float readabilityOffset, float lastLineLenProp) { + float readabilityOffset, float lastLineLenProp) { var patternEntries = new ArrayList(patterns.size()); var fakeScale = 1; diff --git a/Common/src/main/java/at/petrak/hexcasting/mixin/client/MixinElytraLayer.java b/Common/src/main/java/at/petrak/hexcasting/mixin/client/MixinElytraLayer.java new file mode 100644 index 00000000..8d1cf48e --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/mixin/client/MixinElytraLayer.java @@ -0,0 +1,41 @@ +package at.petrak.hexcasting.mixin.client; + +import at.petrak.hexcasting.xplat.IXplatAbstractions; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.entity.layers.ElytraLayer; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +import static at.petrak.hexcasting.api.HexAPI.modLoc; + +// Do this with a mixin instead of a model like you're supposed to because +// 1. cause it's easier +// 2. players wearing normal elytra and altiora won't get z fighting +@Mixin(ElytraLayer.class) +public class MixinElytraLayer { + private static final ResourceLocation ALTIORA_LOC = modLoc("textures/misc/altiora.png"); + + // The "do i draw" check is one of the thing forge clobbers, so we do that in side-specific mixins + + @ModifyVariable( + method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;" + + "ILnet/minecraft/world/entity/LivingEntity;FFFFFF)V", + at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;pushPose()V", ordinal = 0), + ordinal = 0 + ) + private ResourceLocation injectAltioraLocation(ResourceLocation texLoc, PoseStack ps, MultiBufferSource mbs, + int packedLight, LivingEntity e) { + if (e instanceof Player player) { + if (IXplatAbstractions.INSTANCE.getAltiora(player) != null) { + return ALTIORA_LOC; + } + } + + return texLoc; + } +} diff --git a/Common/src/main/resources/assets/hexcasting/textures/misc/altiora.png b/Common/src/main/resources/assets/hexcasting/textures/misc/altiora.png new file mode 100644 index 0000000000000000000000000000000000000000..fd1455407520c2b686e18b39966110679e2efb59 GIT binary patch literal 419 zcmV;U0bKrxP)PhsOJY`lgDT3ZU1f{l0u8yCEQrC8W5h?S8a_%MWRHUrs>8DR(uZZh-o z=g&Gf;O}zY`^UWrF`KM>R}7e5o}&Q)k>|7mP9c!nuJw%5rmY7MTLMKNx61&bDgdAN z%OjwK@AVl1N~i`xtN=g&fW`DsM;p)suu2cWgebtm^eM&)SkIeq`v6cy8%Pge@sNKt zJ^<%Oa0<`^@LWY3um$2Nz^_DolZ||bSOIJU0{D9$kP1NWGvq`V`5o%gixof*s0M&k zfcz5V6!?21j1_>wV;?92LaJFw1+Z}V08J2U>fXBM?D=+Tl2QSlmJjPp0Ot*OA(qwv;c56i|tx9x!Jo$ zzz7%tBVYuKfDtePM!>lryvh`V!dLOm0000EWmrjOO-%qQ00008000000002eQ _programsToClose, - List>> shadersToLoad) - throws IOException { + List _programsToClose, + List>> shadersToLoad) + throws IOException { HexShaders.init(resourceManager, shadersToLoad::add); } } diff --git a/Fabric/src/main/resources/fabricasting.mixins.json b/Fabric/src/main/resources/fabricasting.mixins.json index aef62875..e10f33f8 100644 --- a/Fabric/src/main/resources/fabricasting.mixins.json +++ b/Fabric/src/main/resources/fabricasting.mixins.json @@ -17,6 +17,7 @@ "client": [ "client.FabricAbstractTextureMixin", "client.FabricLevelRendererMixin", + "client.FabricMixinElytraLayer", "client.FabricMixinGameRenderer", "client.FabricModelManagerMixin", "client.FabricMouseHandlerMixin", diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexClientInitializer.java b/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexClientInitializer.java index 24b3b769..e683dd31 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexClientInitializer.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexClientInitializer.java @@ -1,11 +1,11 @@ package at.petrak.hexcasting.forge; import at.petrak.hexcasting.client.ClientTickCounter; -import at.petrak.hexcasting.client.HexAdditionalRenderers; import at.petrak.hexcasting.client.RegisterClientStuff; import at.petrak.hexcasting.client.ShiftScrollListener; import at.petrak.hexcasting.client.gui.PatternTooltipComponent; -import at.petrak.hexcasting.client.shader.HexShaders; +import at.petrak.hexcasting.client.render.HexAdditionalRenderers; +import at.petrak.hexcasting.client.render.shader.HexShaders; import at.petrak.hexcasting.common.casting.PatternRegistryManifest; import at.petrak.hexcasting.common.lib.HexParticles; import at.petrak.hexcasting.common.misc.PatternTooltip; diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/cap/CapSyncers.java b/Forge/src/main/java/at/petrak/hexcasting/forge/cap/CapSyncers.java index 0f9ea2be..58e4bd95 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/cap/CapSyncers.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/cap/CapSyncers.java @@ -25,6 +25,7 @@ public class CapSyncers { // Copy data from this to new player var x = IXplatAbstractions.INSTANCE; x.setFlight(player, x.getFlight(proto)); + x.setAltiora(player, x.getAltiora(proto)); x.setSentinel(player, x.getSentinel(proto)); x.setColorizer(player, x.getColorizer(proto)); x.setHarness(player, x.getHarness(proto, InteractionHand.MAIN_HAND)); diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/interop/jei/BrainsweepRecipeCategory.java b/Forge/src/main/java/at/petrak/hexcasting/forge/interop/jei/BrainsweepRecipeCategory.java index 20276bd5..eb0415ed 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/interop/jei/BrainsweepRecipeCategory.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/interop/jei/BrainsweepRecipeCategory.java @@ -26,7 +26,7 @@ import java.util.Collections; import java.util.List; import static at.petrak.hexcasting.api.HexAPI.modLoc; -import static at.petrak.hexcasting.client.RenderLib.renderEntity; +import static at.petrak.hexcasting.client.render.RenderLib.renderEntity; public class BrainsweepRecipeCategory implements IRecipeCategory { public static final ResourceLocation UID = modLoc("brainsweep"); diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/mixin/client/ForgeMixinElytraLayer.java b/Forge/src/main/java/at/petrak/hexcasting/forge/mixin/client/ForgeMixinElytraLayer.java new file mode 100644 index 00000000..9e7cd27b --- /dev/null +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/mixin/client/ForgeMixinElytraLayer.java @@ -0,0 +1,30 @@ +package at.petrak.hexcasting.forge.mixin.client; + +import at.petrak.hexcasting.api.HexAPI; +import at.petrak.hexcasting.xplat.IXplatAbstractions; +import net.minecraft.client.renderer.entity.layers.ElytraLayer; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +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; + +@Mixin(ElytraLayer.class) +public class ForgeMixinElytraLayer { + @Inject( + method = "shouldRender", at = @At("RETURN"), + cancellable = true, + remap = false + ) + private void renderIfAltiora(ItemStack stack, LivingEntity entity, CallbackInfoReturnable cir) { + if (entity instanceof Player player) { + var altiora = IXplatAbstractions.INSTANCE.getAltiora(player); + HexAPI.LOGGER.warn(altiora); + if (altiora != null) { + cir.setReturnValue(true); + } + } + } +} diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/xplat/ForgeXplatImpl.java b/Forge/src/main/java/at/petrak/hexcasting/forge/xplat/ForgeXplatImpl.java index 1d008567..86c7b2f8 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/xplat/ForgeXplatImpl.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/xplat/ForgeXplatImpl.java @@ -244,12 +244,7 @@ public class ForgeXplatImpl implements IXplatAbstractions { } @Override - public AltioraAbility getAltiora(Player anyPlayer) { - if (!(anyPlayer instanceof ServerPlayer player)) { - // the check only needs to happen client-side on fabric - // which is great, cause it's not even synced on forge - return null; - } + public AltioraAbility getAltiora(Player player) { CompoundTag tag = player.getPersistentData(); boolean allowed = tag.getBoolean(TAG_ALTIORA_ALLOWED); if (allowed) { diff --git a/Forge/src/main/resources/hexcasting_forge.mixins.json b/Forge/src/main/resources/hexcasting_forge.mixins.json index 5ee31c8a..9272dacf 100644 --- a/Forge/src/main/resources/hexcasting_forge.mixins.json +++ b/Forge/src/main/resources/hexcasting_forge.mixins.json @@ -4,7 +4,13 @@ "compatibilityLevel": "JAVA_17", "refmap": "hexcasting.mixins.refmap.json", "package": "at.petrak.hexcasting.forge.mixin", - "mixins": ["ForgeAccessorRegistry", "ForgeMixinCursedRecipeSerializerBase"], "client": [ - "ForgeMixinBlockColors", "ForgeMixinItemColors" -] + "mixins": [ + "ForgeAccessorRegistry", + "ForgeMixinCursedRecipeSerializerBase" + ], + "client": [ + "ForgeMixinBlockColors", + "ForgeMixinItemColors", + "client.ForgeMixinElytraLayer" + ] }