From a23e8b8975436b5400665fb07a0120353728221d Mon Sep 17 00:00:00 2001 From: Martin Prokoph Date: Thu, 14 Nov 2024 21:43:19 +0100 Subject: [PATCH] Initial port to 1.21.3 - Still waiting for SpruceUI to update, only use the advanced config in the meantime --- .../client/MidnightReacharound.java | 2 +- .../client/controller/InputHandlers.java | 15 ++++---- .../client/controller/MovementHandler.java | 11 +++--- .../client/gui/MidnightControlsRenderer.java | 36 +++++++++---------- .../gui/MidnightControlsSettingsScreen.java | 2 +- .../client/mixin/ClientPlayerEntityMixin.java | 4 +-- .../client/mixin/DrawContextAccessor.java | 21 +++++++++++ .../client/mixin/GameOptionsScreenMixin.java | 2 +- .../client/mixin/MinecraftClientMixin.java | 4 +-- .../client/mixin/MouseMixin.java | 2 +- .../mixin/RecipeBookScreenAccessor.java | 21 +++++++++++ .../mixin/RecipeBookWidgetAccessor.java | 3 -- .../client/mixin/WorldRendererMixin.java | 33 ++++++----------- .../client/touch/TouchInput.java | 4 +-- .../client/touch/TouchUtils.java | 2 +- .../client/touch/gui/ItemUseButtonWidget.java | 2 +- .../client/touch/gui/TouchscreenOverlay.java | 2 +- .../resources/midnightcontrols.mixins.json | 20 ++++++----- fabric/build.gradle | 2 +- gradle.properties | 14 ++++---- 20 files changed, 115 insertions(+), 87 deletions(-) create mode 100644 common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/DrawContextAccessor.java create mode 100644 common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/RecipeBookScreenAccessor.java diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/MidnightReacharound.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/MidnightReacharound.java index c4360c7..fad46bd 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/MidnightReacharound.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/MidnightReacharound.java @@ -77,7 +77,7 @@ public boolean isReacharoundAvailable() { } public static float getPlayerRange(@NotNull MinecraftClient client) { - return client.player != null ? Double.valueOf(client.player.getAttributeValue(EntityAttributes.PLAYER_BLOCK_INTERACTION_RANGE)).floatValue() : 0.f; + return client.player != null ? Double.valueOf(client.player.getAttributeValue(EntityAttributes.BLOCK_INTERACTION_RANGE)).floatValue() : 0.f; } /** diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/controller/InputHandlers.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/controller/InputHandlers.java index d9ae12e..2e81b4c 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/controller/InputHandlers.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/controller/InputHandlers.java @@ -60,10 +60,11 @@ public static PressAction handleHotbar(boolean next) { // When in-game if (client.currentScreen == null && client.player != null) { if (!client.player.isSpectator()) { + var inv = client.player.getInventory(); if (next) - client.player.getInventory().scrollInHotbar(-1.0); + inv.setSelectedSlot(inv.selectedSlot < 8 ? inv.selectedSlot + 1 : inv.selectedSlot - 8); else - client.player.getInventory().scrollInHotbar(1.0); + inv.setSelectedSlot(inv.selectedSlot > 0 ? inv.selectedSlot - 1 : inv.selectedSlot + 8); } else { if (client.inGameHud.getSpectatorHud().isOpen()) { @@ -79,11 +80,9 @@ public static PressAction handleHotbar(boolean next) { } else if (client.currentScreen instanceof CreativeInventoryScreenAccessor inventory) { inventory.midnightcontrols$setSelectedTab(ItemGroupUtil.cycleTab(next, client)); return true; - } else if (client.currentScreen instanceof InventoryScreen || client.currentScreen instanceof CraftingScreen || client.currentScreen instanceof AbstractFurnaceScreen) { - RecipeBookWidget recipeBook; - if (client.currentScreen instanceof InventoryScreen inventoryScreen) recipeBook = inventoryScreen.getRecipeBookWidget(); - else if (client.currentScreen instanceof CraftingScreen craftingScreen) recipeBook = craftingScreen.getRecipeBookWidget(); - else recipeBook = ((AbstractFurnaceScreen)client.currentScreen).getRecipeBookWidget(); + } else if (client.currentScreen instanceof RecipeBookScreen recipeBookScreen) { + RecipeBookWidget recipeBook = ((RecipeBookScreenAccessor) recipeBookScreen).getRecipeBook(); + var recipeBookAccessor = (RecipeBookWidgetAccessor) recipeBook; var tabs = recipeBookAccessor.getTabButtons(); var currentTab = recipeBookAccessor.getCurrentTab(); @@ -98,7 +97,7 @@ else if (nextTab >= tabs.size()) currentTab.setToggled(false); recipeBookAccessor.setCurrentTab(currentTab = tabs.get(nextTab)); currentTab.setToggled(true); - recipeBookAccessor.midnightcontrols$refreshResults(true); + recipeBookScreen.refreshRecipeBook(); return true; } else if (client.currentScreen instanceof AdvancementsScreenAccessor screen) { var tabs = screen.getTabs().values().stream().distinct().toList(); diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/controller/MovementHandler.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/controller/MovementHandler.java index da5fd99..ec3ac47 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/controller/MovementHandler.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/controller/MovementHandler.java @@ -48,10 +48,11 @@ private MovementHandler() { public void applyMovement(@NotNull ClientPlayerEntity player) { if (!this.shouldOverrideMovement) return; - player.input.pressingForward = this.pressingForward; - player.input.pressingBack = this.pressingBack; - player.input.pressingLeft = this.pressingLeft; - player.input.pressingRight = this.pressingRight; + // TODO +// player.input.playerInput.pressingForward = this.pressingForward; +// player.input.pressingBack = this.pressingBack; +// player.input.pressingLeft = this.pressingLeft; +// player.input.pressingRight = this.pressingRight; polarUtil.calculate(this.movementSideways, this.movementForward, this.slowdownFactor); player.input.movementForward = polarUtil.polarY; @@ -81,7 +82,7 @@ else if (button == ButtonBinding.BACK || button == ButtonBinding.RIGHT) } this.slowdownFactor = client.player.shouldSlowDown() ? (MathHelper.clamp( - 0.3F + (float) client.player.getAttributeValue(EntityAttributes.PLAYER_SNEAKING_SPEED), + 0.3F + (float) client.player.getAttributeValue(EntityAttributes.SNEAKING_SPEED), 0.0F, 1.0F )) : 1.f; diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/gui/MidnightControlsRenderer.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/gui/MidnightControlsRenderer.java index 2886a12..9cb5a96 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/gui/MidnightControlsRenderer.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/gui/MidnightControlsRenderer.java @@ -18,24 +18,23 @@ import eu.midnightdust.midnightcontrols.client.compat.MidnightControlsCompat; import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding; import eu.midnightdust.midnightcontrols.client.enums.VirtualMouseSkin; +import eu.midnightdust.midnightcontrols.client.mixin.DrawContextAccessor; import eu.midnightdust.midnightcontrols.client.util.HandledScreenAccessor; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.BufferBuilder; -import net.minecraft.client.render.BufferRenderer; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.render.Tessellator; -import net.minecraft.client.render.VertexFormat; -import net.minecraft.client.render.VertexFormats; +import net.minecraft.client.render.*; import net.minecraft.client.resource.language.I18n; import net.minecraft.client.texture.Sprite; import net.minecraft.screen.slot.Slot; import net.minecraft.util.Identifier; +import net.minecraft.util.math.ColorHelper; import org.jetbrains.annotations.NotNull; import org.joml.Matrix4f; import org.lwjgl.glfw.GLFW; +import java.util.function.Function; + import static eu.midnightdust.midnightcontrols.MidnightControls.id; /** @@ -175,7 +174,7 @@ else if (button >= 500) { int assetSize = axis || (button >= 15 && button <= 18) ? AXIS_SIZE : BUTTON_SIZE; RenderSystem.setShaderColor(1.f, second ? 0.f : 1.f, 1.f, 1.f); - context.drawTexture(axis ? MidnightControlsClient.CONTROLLER_AXIS : button >= 15 && button <= 19 ? MidnightControlsClient.CONTROLLER_EXPANDED :MidnightControlsClient.CONTROLLER_BUTTONS + context.drawTexture(RenderLayer::getGuiTextured, axis ? MidnightControlsClient.CONTROLLER_AXIS : button >= 15 && button <= 19 ? MidnightControlsClient.CONTROLLER_EXPANDED :MidnightControlsClient.CONTROLLER_BUTTONS , x + (ICON_SIZE / 2 - assetSize / 2), y + (ICON_SIZE / 2 - assetSize / 2), (float) buttonOffset, (float) (controllerType * assetSize), assetSize, assetSize, @@ -216,7 +215,7 @@ public static void renderWaylandCursor(@NotNull DrawContext context, @NotNull Mi if (MidnightControlsConfig.virtualMouseSkin == VirtualMouseSkin.DEFAULT_DARK || MidnightControlsConfig.virtualMouseSkin == VirtualMouseSkin.SECOND_DARK) spritePath = MidnightControlsClient.WAYLAND_CURSOR_TEXTURE_DARK; Sprite sprite = client.getGuiAtlasManager().getSprite(spritePath); - drawUnalignedTexturedQuad(sprite.getAtlasId(), context, mouseX, mouseX + 8, mouseY, mouseY + 8, 999, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV()); + drawUnalignedTexturedQuad(RenderLayer::getGuiTextured, sprite.getAtlasId(), context, mouseX, mouseX + 8, mouseY, mouseY + 8, 999, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV()); } catch (IllegalStateException ignored) {} } @@ -260,19 +259,20 @@ public static void renderVirtualCursor(@NotNull DrawContext context, @NotNull Mi try { Sprite sprite = client.getGuiAtlasManager().getSprite(id(MidnightControlsConfig.virtualMouseSkin.getSpritePath() + (hoverSlot ? "_slot" : ""))); - drawUnalignedTexturedQuad(sprite.getAtlasId(), context, mouseX, mouseX + 16, mouseY, mouseY + 16, 999, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV()); + drawUnalignedTexturedQuad(RenderLayer::getGuiTextured, sprite.getAtlasId(), context, mouseX, mouseX + 16, mouseY, mouseY + 16, 999, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV()); } catch (IllegalStateException ignored) {} } - private static void drawUnalignedTexturedQuad(Identifier texture, DrawContext context, float x1, float x2, float y1, float y2, float z, float u1, float u2, float v1, float v2) { - RenderSystem.setShaderTexture(0, texture); - RenderSystem.setShader(GameRenderer::getPositionTexProgram); + private static void drawUnalignedTexturedQuad(Function renderLayers, Identifier texture, DrawContext context, float x1, float x2, float y1, float y2, float z, float u1, float u2, float v1, float v2) { + RenderLayer renderLayer = renderLayers.apply(texture); + //RenderSystem.setShaderTexture(0, texture); Matrix4f matrix4f = context.getMatrices().peek().getPositionMatrix(); - BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE); - bufferBuilder.vertex(matrix4f, x1, y1, z).texture(u1, v1); - bufferBuilder.vertex(matrix4f, x1, y2, z).texture(u1, v2); - bufferBuilder.vertex(matrix4f, x2, y2, z).texture(u2, v2); - bufferBuilder.vertex(matrix4f, x2, y1, z).texture(u2, v1); - BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); + //BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE); + VertexConsumer vertexConsumer = ((DrawContextAccessor)context).getVertexConsumers().getBuffer(renderLayer); + vertexConsumer.vertex(matrix4f, x1, y1, z).texture(u1, v1).color(ColorHelper.getWhite(1.0f)); + vertexConsumer.vertex(matrix4f, x1, y2, z).texture(u1, v2).color(ColorHelper.getWhite(1.0f)); + vertexConsumer.vertex(matrix4f, x2, y2, z).texture(u2, v2).color(ColorHelper.getWhite(1.0f)); + vertexConsumer.vertex(matrix4f, x2, y1, z).texture(u2, v1).color(ColorHelper.getWhite(1.0f)); + context.draw(); } public record ButtonSize(int length, int height) { diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/gui/MidnightControlsSettingsScreen.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/gui/MidnightControlsSettingsScreen.java index d817ada..b763e31 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/gui/MidnightControlsSettingsScreen.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/gui/MidnightControlsSettingsScreen.java @@ -514,7 +514,7 @@ private static void fill(MatrixStack matrixStack, int x2, int y2, int x1, int y1 BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); - RenderSystem.setShader(GameRenderer::getPositionColorProgram); + //RenderSystem.setShader(GameRenderer::getPositionColorProgram); bufferBuilder.vertex(matrix, (float)x1, (float)y2, 0.0F).color(r, g, b, t); bufferBuilder.vertex(matrix, (float)x2, (float)y2, 0.0F).color(r, g, b, t); bufferBuilder.vertex(matrix, (float)x2, (float)y1, 0.0F).color(r, g, b, t); diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/ClientPlayerEntityMixin.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/ClientPlayerEntityMixin.java index 68faa96..affc1e4 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/ClientPlayerEntityMixin.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/ClientPlayerEntityMixin.java @@ -88,11 +88,11 @@ public void onTickMovement(CallbackInfo ci) { if (MidnightControlsConfig.verticalFlyDrifting || !MidnightControls.isExtrasLoaded) return; int moving = 0; - if (this.input.sneaking) { + if (this.input.playerInput.sneak()) { --moving; } - if (this.input.jumping) { + if (this.input.playerInput.jump()) { ++moving; } diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/DrawContextAccessor.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/DrawContextAccessor.java new file mode 100644 index 0000000..62dfe9e --- /dev/null +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/DrawContextAccessor.java @@ -0,0 +1,21 @@ +/* + * Copyright © 2021 LambdAurora + * + * This file is part of midnightcontrols. + * + * Licensed under the MIT license. For more information, + * see the LICENSE file. + */ + +package eu.midnightdust.midnightcontrols.client.mixin; + +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.VertexConsumerProvider; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(DrawContext.class) +public interface DrawContextAccessor { + @Accessor("vertexConsumers") + VertexConsumerProvider.Immediate getVertexConsumers(); +} diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/GameOptionsScreenMixin.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/GameOptionsScreenMixin.java index 31b7aa8..a7192aa 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/GameOptionsScreenMixin.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/GameOptionsScreenMixin.java @@ -48,7 +48,7 @@ protected GameOptionsScreenMixin(Text title) { } } - @Inject(method = "initTabNavigation", at = @At("TAIL")) + @Inject(method = "refreshWidgetPositions", at = @At("TAIL")) public void midnightcontrols$onResize(CallbackInfo ci) { this.midnightcontrols$setButtonPos(); } diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/MinecraftClientMixin.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/MinecraftClientMixin.java index d4313bf..10e21a6 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/MinecraftClientMixin.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/MinecraftClientMixin.java @@ -127,12 +127,12 @@ private void onItemUse(CallbackInfo ci, @Local Hand hand, @Local ItemStack stack int previousStackCount = stackInHand.getCount(); var result = this.interactionManager.interactBlock(this.player, hand, hitResult); if (result.isAccepted()) { - if (result.shouldSwingHand()) { + //if (result.shouldSwingHand()) { this.player.swingHand(hand); if (!stackInHand.isEmpty() && (stackInHand.getCount() != previousStackCount || this.interactionManager.hasCreativeInventory())) { this.gameRenderer.firstPersonRenderer.resetEquipProgress(hand); } - } + //} ci.cancel(); } diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/MouseMixin.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/MouseMixin.java index e85c577..3c47ef5 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/MouseMixin.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/MouseMixin.java @@ -20,7 +20,7 @@ import net.minecraft.client.util.GlfwUtil; import net.minecraft.item.ItemStack; import net.minecraft.item.ThrowablePotionItem; -import net.minecraft.util.UseAction; +import net.minecraft.item.consume.UseAction; import net.minecraft.util.math.Smoother; import org.lwjgl.glfw.GLFW; import org.spongepowered.asm.mixin.Final; diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/RecipeBookScreenAccessor.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/RecipeBookScreenAccessor.java new file mode 100644 index 0000000..eed3dae --- /dev/null +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/RecipeBookScreenAccessor.java @@ -0,0 +1,21 @@ +/* + * Copyright © 2021 LambdAurora + * + * This file is part of midnightcontrols. + * + * Licensed under the MIT license. For more information, + * see the LICENSE file. + */ + +package eu.midnightdust.midnightcontrols.client.mixin; + +import net.minecraft.client.gui.screen.ingame.RecipeBookScreen; +import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(RecipeBookScreen.class) +public interface RecipeBookScreenAccessor { + @Accessor("recipeBook") + RecipeBookWidget getRecipeBook(); +} diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/RecipeBookWidgetAccessor.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/RecipeBookWidgetAccessor.java index 71424a0..e0e55df 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/RecipeBookWidgetAccessor.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/RecipeBookWidgetAccessor.java @@ -27,7 +27,4 @@ public interface RecipeBookWidgetAccessor { @Accessor("currentTab") void setCurrentTab(RecipeGroupButtonWidget currentTab); - - @Invoker("refreshResults") - void midnightcontrols$refreshResults(boolean resetCurrentPage); } diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/WorldRendererMixin.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/WorldRendererMixin.java index ad6344a..ce1ab19 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/WorldRendererMixin.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/mixin/WorldRendererMixin.java @@ -9,10 +9,8 @@ package eu.midnightdust.midnightcontrols.client.mixin; -import com.llamalad7.mixinextras.sugar.Local; import eu.midnightdust.lib.util.MidnightColorUtil; import eu.midnightdust.midnightcontrols.ControlsMode; -import eu.midnightdust.midnightcontrols.client.MidnightControlsClient; import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig; import eu.midnightdust.midnightcontrols.client.touch.TouchInput; import eu.midnightdust.midnightcontrols.client.enums.TouchMode; @@ -28,8 +26,7 @@ import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.HitResult; -import net.minecraft.util.shape.VoxelShape; -import org.joml.Matrix4f; +import net.minecraft.util.math.ColorHelper; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -61,12 +58,8 @@ public abstract class WorldRendererMixin { @Final private BufferBuilderStorage bufferBuilders; - @Shadow - private static void drawCuboidShapeOutline(MatrixStack matrices, VertexConsumer vertexConsumer, VoxelShape shape, double offsetX, double offsetY, double offsetZ, float red, float green, float blue, float alpha) { - } - - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/hit/HitResult;getType()Lnet/minecraft/util/hit/HitResult$Type;")) - private HitResult.Type dontRenderOutline(HitResult instance) { + @Redirect(method = "renderTargetBlockOutline", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/hit/BlockHitResult;getType()Lnet/minecraft/util/hit/HitResult$Type;")) + private HitResult.Type dontRenderOutline(BlockHitResult instance) { if (MidnightControlsConfig.controlsMode == ControlsMode.TOUCHSCREEN && MidnightControlsConfig.touchMode == TouchMode.FINGER_POS) { return HitResult.Type.MISS; } @@ -74,15 +67,10 @@ private HitResult.Type dontRenderOutline(HitResult instance) { } @Inject( - method = "render", - at = @At( - value = "FIELD", - target = "Lnet/minecraft/client/MinecraftClient;crosshairTarget:Lnet/minecraft/util/hit/HitResult;", - ordinal = 1, - shift = At.Shift.AFTER - ) + method = "renderTargetBlockOutline", + at = @At("TAIL") ) - private void onOutlineRender(RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci, @Local MatrixStack matrices) { + private void onOutlineRender(Camera camera, VertexConsumerProvider.Immediate vertexConsumers, MatrixStack matrices, boolean translucent, CallbackInfo ci) { if (((MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && MidnightControlsConfig.touchInControllerMode) || MidnightControlsConfig.controlsMode == ControlsMode.TOUCHSCREEN) && MidnightControlsConfig.touchMode == TouchMode.FINGER_POS) { this.midnightcontrols$renderFingerOutline(matrices, camera); @@ -102,8 +90,8 @@ private void onOutlineRender(RenderTickCounter tickCounter, boolean renderBlockO var pos = camera.getPos(); matrices.push(); var vertexConsumer = this.bufferBuilders.getEntityVertexConsumers().getBuffer(RenderLayer.getLines()); - drawCuboidShapeOutline(matrices, vertexConsumer, outlineShape, blockPos.getX() - pos.getX(), blockPos.getY() - pos.getY(), blockPos.getZ() - pos.getZ(), - rgb.getRed() / 255.f, rgb.getGreen() / 255.f, rgb.getBlue() / 255.f, MidnightControlsConfig.touchOutlineColorAlpha / 255.f); + VertexRendering.drawOutline(matrices, vertexConsumer, outlineShape, blockPos.getX() - pos.getX(), blockPos.getY() - pos.getY(), blockPos.getZ() - pos.getZ(), + ColorHelper.withAlpha(MidnightControlsConfig.touchOutlineColorAlpha, rgb.getRGB())); matrices.pop(); } } @@ -134,9 +122,8 @@ private void onOutlineRender(RenderTickCounter tickCounter, boolean renderBlockO if (MidnightControlsConfig.reacharoundOutlineColorHex.isEmpty()) rgb = RainbowColor.radialRainbow(1,1); matrices.push(); var vertexConsumer = this.bufferBuilders.getEntityVertexConsumers().getBuffer(RenderLayer.getLines()); - drawCuboidShapeOutline(matrices, vertexConsumer, outlineShape, - (double) blockPos.getX() - pos.getX(), (double) blockPos.getY() - pos.getY(), (double) blockPos.getZ() - pos.getZ(), - rgb.getRed() / 255.f, rgb.getGreen() / 255.f, rgb.getBlue() / 255.f, MidnightControlsConfig.reacharoundOutlineColorAlpha / 255.f); + VertexRendering.drawOutline(matrices, vertexConsumer, outlineShape, blockPos.getX() - pos.getX(), blockPos.getY() - pos.getY(), blockPos.getZ() - pos.getZ(), + ColorHelper.withAlpha(MidnightControlsConfig.touchOutlineColorAlpha, rgb.getRGB())); matrices.pop(); } } diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/TouchInput.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/TouchInput.java index 975a8e2..8022745 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/TouchInput.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/TouchInput.java @@ -85,12 +85,12 @@ public static boolean mouseReleased(double mouseX, double mouseY, int button) { int previousStackCount = stackInHand.getCount(); var interaction = client.interactionManager.interactBlock(client.player, client.player.getActiveHand(), blockHit); if (interaction.isAccepted()) { - if (interaction.shouldSwingHand()) { + //if (interaction.shouldSwingHand()) { client.player.swingHand(client.player.preferredHand); if (!stackInHand.isEmpty() && (stackInHand.getCount() != previousStackCount || client.interactionManager.hasCreativeInventory())) { client.gameRenderer.firstPersonRenderer.resetEquipProgress(client.player.preferredHand); } - } + //} return true; } } diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/TouchUtils.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/TouchUtils.java index aae6bfe..403e7df 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/TouchUtils.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/TouchUtils.java @@ -7,7 +7,7 @@ import net.minecraft.client.render.Camera; import net.minecraft.entity.projectile.ProjectileUtil; import net.minecraft.item.ItemStack; -import net.minecraft.util.UseAction; +import net.minecraft.item.consume.UseAction; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.hit.HitResult; diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/gui/ItemUseButtonWidget.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/gui/ItemUseButtonWidget.java index 8b7af9f..9909be5 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/gui/ItemUseButtonWidget.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/gui/ItemUseButtonWidget.java @@ -1,12 +1,12 @@ package eu.midnightdust.midnightcontrols.client.touch.gui; +import net.minecraft.item.consume.UseAction; import org.thinkingstudio.obsidianui.Position; import org.thinkingstudio.obsidianui.widget.SpruceButtonWidget; import eu.midnightdust.midnightcontrols.MidnightControlsConstants; import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig; import net.minecraft.item.ArmorItem; import net.minecraft.text.Text; -import net.minecraft.util.UseAction; public class ItemUseButtonWidget extends SpruceButtonWidget { diff --git a/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/gui/TouchscreenOverlay.java b/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/gui/TouchscreenOverlay.java index b26407a..d658534 100644 --- a/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/gui/TouchscreenOverlay.java +++ b/common/src/main/java/eu/midnightdust/midnightcontrols/client/touch/gui/TouchscreenOverlay.java @@ -15,10 +15,10 @@ import net.minecraft.client.gui.screen.GameMenuScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.item.ArmorItem; +import net.minecraft.item.consume.UseAction; import net.minecraft.util.Arm; import net.minecraft.util.Hand; import net.minecraft.util.Identifier; -import net.minecraft.util.UseAction; import org.thinkingstudio.obsidianui.Position; import org.thinkingstudio.obsidianui.widget.SpruceButtonWidget; import eu.midnightdust.lib.util.PlatformFunctions; diff --git a/common/src/main/resources/midnightcontrols.mixins.json b/common/src/main/resources/midnightcontrols.mixins.json index 9a0ce5c..8a47266 100644 --- a/common/src/main/resources/midnightcontrols.mixins.json +++ b/common/src/main/resources/midnightcontrols.mixins.json @@ -3,25 +3,27 @@ "package": "eu.midnightdust.midnightcontrols.client.mixin", "compatibilityLevel": "JAVA_16", "client": [ - "ClickableWidgetAccessor", "AdvancementsScreenAccessor", + "ChatScreenMixin", + "ClickableWidgetAccessor", "ClientPlayerEntityMixin", - "GameOptionsScreenMixin", "CreativeInventoryScreenAccessor", + "DrawContextAccessor", + "GameOptionsScreenMixin", "GameRendererMixin", "HandledScreenMixin", - "KeyBindingMixin", "InputUtilMixin", + "KeyBindingIDAccessor", + "KeyBindingMixin", + "KeyboardMixin", "MinecraftClientMixin", - "MouseMixin", "MouseAccessor", - "ChatScreenMixin", + "MouseMixin", + "RecipeBookScreenAccessor", "RecipeBookWidgetAccessor", - "WorldRendererMixin", - "KeyBindingIDAccessor", - "TabNavigationWidgetAccessor", "ScreenMixin", - "KeyboardMixin" + "TabNavigationWidgetAccessor", + "WorldRendererMixin" ], "injectors": { "defaultRequire": 1 diff --git a/fabric/build.gradle b/fabric/build.gradle index 7b7059f..d937d6f 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -26,7 +26,7 @@ dependencies { modImplementation include ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric") modImplementation include ("maven.modrinth:obsidianui:${rootProject.obsidianui_version}-fabric") {} include 'org.aperlambda:lambdajcommon:1.8.1' - modImplementation "maven.modrinth:emi:${project.emi_version}" + modCompileOnly "maven.modrinth:emi:${project.emi_version}" common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } diff --git a/gradle.properties b/gradle.properties index 16753e8..467ba19 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,9 +2,9 @@ org.gradle.parallel=true org.gradle.jvmargs=-Xmx2048M -minecraft_version=1.21 -supported_versions=1.21.1 -yarn_mappings=1.21+build.2 +minecraft_version=1.21.3 +supported_versions=1.21.2 +yarn_mappings=1.21.3+build.2 enabled_platforms=fabric,neoforge archives_base_name=midnightcontrols @@ -15,12 +15,12 @@ modrinth_id = bXX9h73M curseforge_id = 621768 # Configure the IDs here after creating the projects on the websites -midnightlib_version=1.6.3 +midnightlib_version=1.6.4 -fabric_loader_version=0.15.11 -fabric_api_version=0.100.1+1.21 +fabric_loader_version=0.16.9 +fabric_api_version=0.107.3+1.21.3 -neoforge_version=21.0.14-beta +neoforge_version=21.3.28-beta yarn_mappings_patch_neoforge_version = 1.21+build.4 quilt_loader_version=0.19.0-beta.18