From 2d97cbfc117c433836e1e8c18d09397469fa3474 Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Sun, 29 Dec 2024 22:09:17 +0700 Subject: [PATCH] 1.20.1 --- .github/workflows/build.yml | 10 ++-- build.gradle | 6 +-- gradle.properties | 13 ++--- .../java/autumnvn/autumn/AutumnClient.java | 5 +- .../autumnvn/autumn/ButtonListWidget.java | 4 +- src/client/java/autumnvn/autumn/FreeCam.java | 39 +++++---------- .../java/autumnvn/autumn/SettingsScreen.java | 2 +- src/client/java/autumnvn/autumn/Utils.java | 5 +- .../mixin/client/BackgroundRendererMixin.java | 12 ++--- .../autumn/mixin/client/CameraMixin.java | 4 +- .../autumn/mixin/client/ChatHudMixin.java | 11 ++--- .../client/ClientPlayNetworkHandlerMixin.java | 2 +- .../mixin/client/EntityRenderStateMixin.java | 24 ---------- .../mixin/client/EntityRendererMixin.java | 47 ++++--------------- .../FishingBobberEntityRendererMixin.java | 10 ++-- .../mixin/client/GameRendererMixin.java | 2 +- .../autumn/mixin/client/InGameHudMixin.java | 45 ++++++++---------- .../autumn/mixin/client/TitleScreenMixin.java | 6 ++- .../mixin/client/ToastManagerMixin.java | 5 +- .../mixin/client/WorldRendererMixin.java | 18 +++---- .../resources/autumn.client.mixins.json | 3 +- src/main/resources/autumn.mixins.json | 2 +- src/main/resources/fabric.mod.json | 4 +- 23 files changed, 96 insertions(+), 183 deletions(-) delete mode 100644 src/client/java/autumnvn/autumn/mixin/client/EntityRenderStateMixin.java diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3b0ab8a..0f29cd1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,9 @@ name: Build on: - push: - branches: - - main + push: + branches: + - 1.20.1 permissions: contents: write @@ -18,7 +18,7 @@ jobs: - uses: actions/setup-java@v4 with: - java-version: 21 + java-version: 17 distribution: 'temurin' - name: Build @@ -26,6 +26,6 @@ jobs: - name: Release run: | - gh release upload release --clobber build/libs/autumn-1.21.4.jar + gh release upload release --clobber build/libs/autumn-1.20.1.jar env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle b/build.gradle index cc1dba0..7c15a85 100644 --- a/build.gradle +++ b/build.gradle @@ -45,14 +45,14 @@ processResources { } tasks.withType(JavaCompile).configureEach { - it.options.release = 21 + it.options.release = 17 } java { withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } jar { diff --git a/gradle.properties b/gradle.properties index a929073..47de57a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,18 +1,15 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G org.gradle.parallel=true - # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.21.4 -yarn_mappings=1.21.4+build.2 +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.10 loader_version=0.16.9 - # Mod Properties -mod_version=1.21.4 +mod_version=1.20.1 maven_group=autumnvn.autumn archives_base_name=autumn - # Dependencies -fabric_version=0.112.2+1.21.4 -modmenu_version=12.0.0 +fabric_version=0.92.2+1.20.1 +modmenu_version=7.2.2 diff --git a/src/client/java/autumnvn/autumn/AutumnClient.java b/src/client/java/autumnvn/autumn/AutumnClient.java index 14c5557..d660f7b 100644 --- a/src/client/java/autumnvn/autumn/AutumnClient.java +++ b/src/client/java/autumnvn/autumn/AutumnClient.java @@ -22,7 +22,6 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import net.minecraft.util.PlayerInput; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.HitResult.Type; import net.minecraft.util.math.BlockPos; @@ -48,7 +47,7 @@ public void onInitializeClient() { settingKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("Open Autumn Settings", GLFW.GLFW_KEY_BACKSLASH, "Autumn")); zoomKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("Zoom", GLFW.GLFW_KEY_LEFT_ALT, "Autumn")); - FabricLoader.getInstance().getModContainer("autumn").ifPresent(container -> ResourceManagerHelper.registerBuiltinResourcePack(Identifier.of("autumn", "autumn"), container, ResourcePackActivationType.DEFAULT_ENABLED)); + FabricLoader.getInstance().getModContainer("autumn").ifPresent(container -> ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("autumn", "autumn"), container, ResourcePackActivationType.DEFAULT_ENABLED)); BlockRenderLayerMap.INSTANCE.putBlock(Blocks.BARRIER, RenderLayer.getTranslucent()); ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> { @@ -74,7 +73,7 @@ public void onInitializeClient() { // FreeCam if (AutumnClient.options.freeCam.getValue() && client.player.input instanceof KeyboardInput) { Input input = new Input(); - input.playerInput = new PlayerInput(false, false, false, false, false, client.player.input.playerInput.sneak(), false); + input.sneaking = client.player.input.sneaking; client.player.input = input; } else if (!AutumnClient.options.freeCam.getValue() && !(client.player.input instanceof KeyboardInput)) { client.player.input = new KeyboardInput(client.options); diff --git a/src/client/java/autumnvn/autumn/ButtonListWidget.java b/src/client/java/autumnvn/autumn/ButtonListWidget.java index ff789b2..88b1136 100644 --- a/src/client/java/autumnvn/autumn/ButtonListWidget.java +++ b/src/client/java/autumnvn/autumn/ButtonListWidget.java @@ -14,8 +14,8 @@ import java.util.Map; public class ButtonListWidget extends ElementListWidget { - public ButtonListWidget(MinecraftClient client, int width, int height, int y, int itemHeight) { - super(client, width, height, y, itemHeight); + public ButtonListWidget(MinecraftClient client, int width, int height, int top, int bottom, int itemHeight) { + super(client, width, height, top, bottom, itemHeight); } void addOptionEntry(SimpleOption options) { diff --git a/src/client/java/autumnvn/autumn/FreeCam.java b/src/client/java/autumnvn/autumn/FreeCam.java index 5e1bc50..965d43a 100644 --- a/src/client/java/autumnvn/autumn/FreeCam.java +++ b/src/client/java/autumnvn/autumn/FreeCam.java @@ -3,16 +3,13 @@ import com.mojang.authlib.GameProfile; import net.minecraft.block.piston.PistonBehavior; import net.minecraft.client.input.KeyboardInput; -import net.minecraft.client.network.ClientConnectionState; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.Entity; import net.minecraft.network.packet.Packet; -import net.minecraft.server.ServerLinks; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import java.util.Collections; import java.util.Objects; import java.util.UUID; @@ -20,20 +17,11 @@ public class FreeCam extends ClientPlayerEntity { static final ClientPlayNetworkHandler networkHandler = new ClientPlayNetworkHandler( AutumnClient.client, + AutumnClient.client.currentScreen, Objects.requireNonNull(AutumnClient.client.getNetworkHandler()).getConnection(), - new ClientConnectionState( - new GameProfile(UUID.randomUUID(), "FreeCam"), - AutumnClient.client.getTelemetryManager().createWorldSession(false, null, null), - AutumnClient.client.getNetworkHandler().getRegistryManager(), - AutumnClient.client.getNetworkHandler().getEnabledFeatures(), - AutumnClient.client.getNetworkHandler().getBrand(), - AutumnClient.client.getCurrentServerEntry(), - AutumnClient.client.currentScreen, - Collections.emptyMap(), - AutumnClient.client.inGameHud.getChatHud().toChatState(), - Collections.emptyMap(), - ServerLinks.EMPTY - ) + AutumnClient.client.getCurrentServerEntry(), + new GameProfile(UUID.randomUUID(), "FreeCam"), + AutumnClient.client.getTelemetryManager().createWorldSession(false, null, null) ) { @Override @@ -52,7 +40,6 @@ public FreeCam() { false ); setId(-1); - setLoaded(true); getAbilities().flying = true; input = new KeyboardInput(AutumnClient.client.options); refreshPositionAndAngles( @@ -66,7 +53,7 @@ public FreeCam() { public void spawn() { if (clientWorld != null) { - clientWorld.addEntity(this); + clientWorld.addEntity(getId(), this); } } @@ -111,27 +98,27 @@ public void tickMovement() { Vec3d forward = Vec3d.fromPolar(0, getYaw()); Vec3d side = Vec3d.fromPolar(0, getYaw() + 90); - input.tick(); + input.tick(false, 0); - if (input.playerInput.forward() || input.playerInput.backward()) { - double direction = input.playerInput.forward() ? 1 : -1; + if (input.pressingForward || input.pressingBack) { + double direction = input.pressingForward ? 1 : -1; x += forward.x * horizontalSpeed * direction; z += forward.z * horizontalSpeed * direction; } - if (input.playerInput.right() || input.playerInput.left()) { - double direction = input.playerInput.right() ? 1 : -1; + if (input.pressingRight || input.pressingLeft) { + double direction = input.pressingRight ? 1 : -1; z += side.z * horizontalSpeed * direction; x += side.x * horizontalSpeed * direction; } - if ((input.playerInput.forward() || input.playerInput.backward()) && (input.playerInput.right() || input.playerInput.left())) { + if ((input.pressingForward || input.pressingBack) && (input.pressingRight || input.pressingLeft)) { x *= sin45; z *= sin45; } - if (input.playerInput.jump()) y += verticalSpeed; - if (input.playerInput.sneak()) y -= verticalSpeed; + if (input.jumping) y += verticalSpeed; + if (input.sneaking) y -= verticalSpeed; setVelocity(x, y, z); super.tickMovement(); diff --git a/src/client/java/autumnvn/autumn/SettingsScreen.java b/src/client/java/autumnvn/autumn/SettingsScreen.java index abd49bd..ae355f0 100644 --- a/src/client/java/autumnvn/autumn/SettingsScreen.java +++ b/src/client/java/autumnvn/autumn/SettingsScreen.java @@ -42,7 +42,7 @@ public SettingsScreen(Screen parent) { @Override protected void init() { - this.list = new ButtonListWidget(this.client, this.width, this.height - 64, 32, 25); + this.list = new ButtonListWidget(this.client, this.width, this.height - 64, 32, this.height - 32, 25); for (int i = 0; i < options.length; i += 2) { if (i + 1 < options.length) { this.list.addOptionEntry(options[i], options[i + 1]); diff --git a/src/client/java/autumnvn/autumn/Utils.java b/src/client/java/autumnvn/autumn/Utils.java index edc6db3..d44ecec 100644 --- a/src/client/java/autumnvn/autumn/Utils.java +++ b/src/client/java/autumnvn/autumn/Utils.java @@ -4,7 +4,6 @@ import net.minecraft.entity.passive.TameableEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.ProjectileUtil; -import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; @@ -30,11 +29,11 @@ public static Entity getTargetedEntity() { if (cameraEntity == null) return null; double maxDistance = 128; - float tickDelta = AutumnClient.client.getRenderTickCounter().getTickDelta(true); + float tickDelta = AutumnClient.client.getTickDelta(); Vec3d vec3d = cameraEntity.getEyePos(); Vec3d vec3d2 = cameraEntity.getRotationVec(tickDelta).multiply(maxDistance); Box box = cameraEntity.getBoundingBox().stretch(vec3d2).expand(1.0); - EntityHitResult entityHitResult = ProjectileUtil.raycast(cameraEntity, vec3d, vec3d.add(vec3d2), box, EntityPredicates.CAN_HIT, maxDistance * maxDistance); + EntityHitResult entityHitResult = ProjectileUtil.raycast(cameraEntity, vec3d, vec3d.add(vec3d2), box, Entity::canHit, maxDistance * maxDistance); if (entityHitResult != null) { recentTargetedEntity = new TimedEntity(entityHitResult.getEntity()); diff --git a/src/client/java/autumnvn/autumn/mixin/client/BackgroundRendererMixin.java b/src/client/java/autumnvn/autumn/mixin/client/BackgroundRendererMixin.java index 107b8ac..01b734c 100644 --- a/src/client/java/autumnvn/autumn/mixin/client/BackgroundRendererMixin.java +++ b/src/client/java/autumnvn/autumn/mixin/client/BackgroundRendererMixin.java @@ -1,24 +1,24 @@ package autumnvn.autumn.mixin.client; import autumnvn.autumn.AutumnClient; +import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.render.BackgroundRenderer; import net.minecraft.client.render.BackgroundRenderer.FogType; import net.minecraft.client.render.Camera; -import net.minecraft.client.render.Fog; -import org.joml.Vector4f; 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 org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(BackgroundRenderer.class) public class BackgroundRendererMixin { // NoFog - @Inject(method = "applyFog", at = @At("TAIL"), cancellable = true) - private static void applyFog(Camera camera, FogType fogType, Vector4f color, float viewDistance, boolean thickenFog, float tickDelta, CallbackInfoReturnable cir) { + @Inject(method = "applyFog", at = @At("TAIL")) + private static void applyFog(Camera camera, FogType fogType, float viewDistance, boolean thickFog, float tickDelta, CallbackInfo ci) { if (AutumnClient.options.noFog.getValue() && fogType == FogType.FOG_TERRAIN) { - cir.setReturnValue(Fog.DUMMY); + RenderSystem.setShaderFogStart(Float.MAX_VALUE); + RenderSystem.setShaderFogEnd(Float.MAX_VALUE); } } } diff --git a/src/client/java/autumnvn/autumn/mixin/client/CameraMixin.java b/src/client/java/autumnvn/autumn/mixin/client/CameraMixin.java index 4202032..8d5ade8 100644 --- a/src/client/java/autumnvn/autumn/mixin/client/CameraMixin.java +++ b/src/client/java/autumnvn/autumn/mixin/client/CameraMixin.java @@ -15,9 +15,9 @@ public class CameraMixin { // ThirdPersonNoClip @Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true) - private void clipToSpace(float f, CallbackInfoReturnable cir) { + private void clipToSpace(double desiredCameraDistance, CallbackInfoReturnable cir) { if (AutumnClient.options.thirdPersonNoClip.getValue()) { - cir.setReturnValue(f); + cir.setReturnValue(desiredCameraDistance); } } diff --git a/src/client/java/autumnvn/autumn/mixin/client/ChatHudMixin.java b/src/client/java/autumnvn/autumn/mixin/client/ChatHudMixin.java index a2fecb6..b64522e 100644 --- a/src/client/java/autumnvn/autumn/mixin/client/ChatHudMixin.java +++ b/src/client/java/autumnvn/autumn/mixin/client/ChatHudMixin.java @@ -11,14 +11,9 @@ public class ChatHudMixin { // BetterChat - @ModifyConstant(method = "addVisibleMessage", constant = @Constant(intValue = 100)) - private int maxVisibleChatLength(int original) { - return AutumnClient.options.betterChat.getValue() ? 65536 : original; - } - - @ModifyConstant(method = "addMessage(Lnet/minecraft/client/gui/hud/ChatHudLine;)V", constant = @Constant(intValue = 100)) - private int maxChatLength(int original) { - return AutumnClient.options.betterChat.getValue() ? 65536 : original; + @ModifyConstant(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", constant = @Constant(intValue = 100)) + private int addMessage(int original) { + return AutumnClient.options.betterChat.getValue() ? 65535 : original; } @Inject(method = "clear", at = @At("HEAD"), cancellable = true) diff --git a/src/client/java/autumnvn/autumn/mixin/client/ClientPlayNetworkHandlerMixin.java b/src/client/java/autumnvn/autumn/mixin/client/ClientPlayNetworkHandlerMixin.java index c7d7818..1d97d1b 100644 --- a/src/client/java/autumnvn/autumn/mixin/client/ClientPlayNetworkHandlerMixin.java +++ b/src/client/java/autumnvn/autumn/mixin/client/ClientPlayNetworkHandlerMixin.java @@ -20,7 +20,7 @@ public class ClientPlayNetworkHandlerMixin { // TPS @Inject(method = "onWorldTimeUpdate", at = @At("HEAD")) private void onWorldTimeUpdate(WorldTimeUpdateS2CPacket packet, CallbackInfo ci) { - long tick = packet.time(); + long tick = packet.getTime(); long time = System.nanoTime(); if (lastTick != 0 && lastTime != 0) { long passedTick = tick - lastTick; diff --git a/src/client/java/autumnvn/autumn/mixin/client/EntityRenderStateMixin.java b/src/client/java/autumnvn/autumn/mixin/client/EntityRenderStateMixin.java deleted file mode 100644 index ed2a384..0000000 --- a/src/client/java/autumnvn/autumn/mixin/client/EntityRenderStateMixin.java +++ /dev/null @@ -1,24 +0,0 @@ -package autumnvn.autumn.mixin.client; - -import autumnvn.autumn.interfaces.EntityRenderState2; -import net.minecraft.client.render.entity.state.EntityRenderState; -import net.minecraft.entity.Entity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; - -@Mixin(EntityRenderState.class) -public class EntityRenderStateMixin implements EntityRenderState2 { - - @Unique - private Entity entity; - - @Unique - public Entity autumn$getEntity() { - return entity; - } - - @Unique - public void autumn$setEntity(Entity entity) { - this.entity = entity; - } -} diff --git a/src/client/java/autumnvn/autumn/mixin/client/EntityRendererMixin.java b/src/client/java/autumnvn/autumn/mixin/client/EntityRendererMixin.java index 3cd4540..b5a2e99 100644 --- a/src/client/java/autumnvn/autumn/mixin/client/EntityRendererMixin.java +++ b/src/client/java/autumnvn/autumn/mixin/client/EntityRendererMixin.java @@ -2,53 +2,36 @@ import autumnvn.autumn.AutumnClient; import autumnvn.autumn.Utils; -import autumnvn.autumn.interfaces.EntityRenderState2; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRenderer; -import net.minecraft.client.render.entity.state.EntityRenderState; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityAttachmentType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.Text; -import net.minecraft.util.math.Vec3d; import org.spongepowered.asm.mixin.Mixin; 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.ModifyArgs; -import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; import java.util.Objects; @Mixin(EntityRenderer.class) -public class EntityRendererMixin { +public class EntityRendererMixin { @Shadow - private static void renderLeash(MatrixStack matrices, VertexConsumerProvider vertexConsumers, EntityRenderState.LeashData leashData) { - } - - @Shadow - protected void renderLabelIfPresent(S state, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) { + protected void renderLabelIfPresent(T entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) { } // BetterNametag @Inject(method = "render", at = @At("HEAD"), cancellable = true) - private void render(S state, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - Entity entity = ((EntityRenderState2) state).autumn$getEntity(); + private void render(T entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { if (AutumnClient.options.betterNametag.getValue() && entity instanceof LivingEntity livingEntity && (livingEntity instanceof PlayerEntity || livingEntity == Utils.getTargetedEntity())) { - EntityRenderState.LeashData leashData = state.leashData; - if (leashData != null) { - renderLeash(matrices, vertexConsumers, leashData); - } - float health = livingEntity.getHealth() + livingEntity.getAbsorptionAmount(); String ownerName = Utils.getOwnerName(livingEntity); - renderLabelIfPresent(state, + renderLabelIfPresent(entity, Text.of( String.format("%s%s %s%.0f§c❤%s", ownerName != null ? ownerName + (ownerName.endsWith("s") ? "' " : "'s ") : "", @@ -62,16 +45,9 @@ private void render(S state, MatrixStack matrices, VertexConsumerProvider vertex } } - @ModifyVariable(method = "renderLabelIfPresent", at = @At("STORE")) - private Vec3d labelNamePos(Vec3d original, S state) { - if (AutumnClient.options.betterNametag.getValue() && original == null) { - Entity entity = ((EntityRenderState2) state).autumn$getEntity(); - if (entity instanceof LivingEntity livingEntity && (livingEntity instanceof PlayerEntity || livingEntity == Utils.getTargetedEntity())) { - return entity.getAttachments().getPointNullable(EntityAttachmentType.NAME_TAG, 0, entity.getLerpedYaw(AutumnClient.client.getRenderTickCounter().getTickDelta(true))); - } - } - - return original; + @ModifyConstant(method = "renderLabelIfPresent", constant = @Constant(doubleValue = 4096.0)) + private double maxSquaredDistance(double original) { + return AutumnClient.options.betterNametag.getValue() ? 128 * 128 : original; } @ModifyArgs(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Lnet/minecraft/text/Text;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)I", ordinal = 0)) @@ -81,11 +57,4 @@ private void draw(Args args) { args.set(7, TextRenderer.TextLayerType.SEE_THROUGH); } } - - @Inject(method = "updateRenderState", at = @At("HEAD")) - private void updateRenderState(T entity, S state, float tickDelta, CallbackInfo ci) { - if (AutumnClient.options.betterNametag.getValue()) { - ((EntityRenderState2) state).autumn$setEntity(entity); - } - } } diff --git a/src/client/java/autumnvn/autumn/mixin/client/FishingBobberEntityRendererMixin.java b/src/client/java/autumnvn/autumn/mixin/client/FishingBobberEntityRendererMixin.java index 06f8deb..6c8335f 100644 --- a/src/client/java/autumnvn/autumn/mixin/client/FishingBobberEntityRendererMixin.java +++ b/src/client/java/autumnvn/autumn/mixin/client/FishingBobberEntityRendererMixin.java @@ -1,12 +1,9 @@ package autumnvn.autumn.mixin.client; import autumnvn.autumn.AutumnClient; -import autumnvn.autumn.interfaces.EntityRenderState2; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.FishingBobberEntityRenderer; -import net.minecraft.client.render.entity.state.FishingBobberEntityState; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.Entity; import net.minecraft.entity.projectile.FishingBobberEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -17,10 +14,9 @@ public class FishingBobberEntityRendererMixin { // NoFishingBobber - @Inject(method = "render(Lnet/minecraft/client/render/entity/state/FishingBobberEntityState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"), cancellable = true) - private void render(FishingBobberEntityState fishingBobberEntityState, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { - Entity entity = ((EntityRenderState2) fishingBobberEntityState).autumn$getEntity(); - if (AutumnClient.options.noFishingBobber.getValue() && ((FishingBobberEntity) entity).getHookedEntity() == AutumnClient.client.player) { + @Inject(method = "render(Lnet/minecraft/entity/projectile/FishingBobberEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"), cancellable = true) + private void render(FishingBobberEntity fishingBobberEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { + if (AutumnClient.options.noFishingBobber.getValue() && (fishingBobberEntity.getHookedEntity() == AutumnClient.client.player)) { ci.cancel(); } } diff --git a/src/client/java/autumnvn/autumn/mixin/client/GameRendererMixin.java b/src/client/java/autumnvn/autumn/mixin/client/GameRendererMixin.java index 538623e..b4f4524 100644 --- a/src/client/java/autumnvn/autumn/mixin/client/GameRendererMixin.java +++ b/src/client/java/autumnvn/autumn/mixin/client/GameRendererMixin.java @@ -18,7 +18,7 @@ public class GameRendererMixin { @Final @Shadow - private MinecraftClient client; + MinecraftClient client; @Unique private Double defaultMouseSen; diff --git a/src/client/java/autumnvn/autumn/mixin/client/InGameHudMixin.java b/src/client/java/autumnvn/autumn/mixin/client/InGameHudMixin.java index f03a2a4..101d67c 100644 --- a/src/client/java/autumnvn/autumn/mixin/client/InGameHudMixin.java +++ b/src/client/java/autumnvn/autumn/mixin/client/InGameHudMixin.java @@ -6,8 +6,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.RenderTickCounter; +import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.resource.language.I18n; import net.minecraft.entity.JumpingMount; import net.minecraft.entity.LivingEntity; @@ -24,6 +23,7 @@ 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -54,13 +54,13 @@ private int getHeartRows(int heartCount) { } @Shadow - private void renderHotbarItem(DrawContext context, int x, int y, RenderTickCounter tickCounter, PlayerEntity player, ItemStack stack, int seed) { + private void renderHotbarItem(DrawContext context, int x, int y, float f, PlayerEntity player, ItemStack stack, int seed) { } // InfoHud @Inject(method = "render", at = @At("HEAD")) - private void render(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { - if (AutumnClient.options.infoHud.getValue() && !client.options.hudHidden && !client.getDebugHud().shouldShowDebugHud() && client.player != null) { + private void render(DrawContext context, float tickDelta, CallbackInfo ci) { + if (AutumnClient.options.infoHud.getValue() && !client.options.hudHidden && !client.options.debugEnabled && client.player != null) { String[] direction = new String[]{"+Z", "-X+Z", "-X", "-X-Z", "-Z", "+X-Z", "+X", "+X+Z"}; ArrayList lines = new ArrayList<>(); @@ -90,13 +90,13 @@ private void render(DrawContext context, RenderTickCounter tickCounter, Callback lines.add(healthLine); int x = 2 + client.textRenderer.getWidth(healthLine) + 2; int y = 2 + (client.textRenderer.fontHeight + 2) * (lines.size() - 1); - context.drawGuiTexture(RenderLayer::getGuiTextured, Identifier.ofVanilla("hud/heart/container"), x, y, 9, 9); - context.drawGuiTexture(RenderLayer::getGuiTextured, Identifier.ofVanilla("hud/heart/full"), x, y, 9, 9); + context.drawTexture(new Identifier("hud/heart/container"), x, y, 0, 0, 9, 9); + context.drawTexture(new Identifier("hud/heart/full"), x, y, 0, 0, 9, 9); } if (Utils.getTargetedEntity() instanceof AbstractHorseEntity abstractHorseEntity) { - double speed = abstractHorseEntity.getAttributeValue(EntityAttributes.MOVEMENT_SPEED) * 42.157787584d; - double jump = abstractHorseEntity.getAttributeValue(EntityAttributes.JUMP_STRENGTH); + double speed = abstractHorseEntity.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED) * 42.157787584d; + double jump = abstractHorseEntity.getAttributeValue(EntityAttributes.HORSE_JUMP_STRENGTH); double jumpHeight = -0.1817584952d * jump * jump * jump + 3.689713992d * jump * jump + 2.128599134d * jump - 0.343930367d; lines.add( String.format("Speed %s%.1fm/s §rJump %s%.1fm", @@ -121,7 +121,7 @@ private void render(DrawContext context, RenderTickCounter tickCounter, Callback y -= getHeartRows(getHeartCount(getRiddenEntity())) * 10; } for (int i = 0, x = 63; i < 4; i++, x -= 15) { - renderHotbarItem(context, context.getScaledWindowWidth() / 2 + x, y, tickCounter, client.player, client.player.getInventory().getArmorStack(i), 1); + renderHotbarItem(context, context.getScaledWindowWidth() / 2 + x, y, tickDelta, client.player, client.player.getInventory().getArmorStack(i), 1); } } } @@ -132,31 +132,24 @@ private int k(int original) { return AutumnClient.options.infoHud.getValue() && client.interactionManager != null && client.interactionManager.hasStatusBars() ? original - 10 : original; } - @ModifyVariable(method = "renderStatusBars", at = @At("STORE"), ordinal = 10) - private int t(int original) { + @ModifyVariable(method = "renderStatusBars", at = @At("STORE"), ordinal = 13) + private int xx(int original) { return AutumnClient.options.infoHud.getValue() ? 0 : original; } - @ModifyVariable(method = "getAirBubbleY", at = @At("HEAD"), ordinal = 0, argsOnly = true) - private int heartCount(int original) { - return AutumnClient.options.infoHud.getValue() && getRiddenEntity() != null ? getHeartCount(getRiddenEntity()) : original; - } - - @ModifyVariable(method = "renderMainHud", at = @At("STORE")) - private JumpingMount jumpingMount(JumpingMount original) { - return AutumnClient.options.infoHud.getValue() && client.player != null && client.interactionManager != null && (!client.interactionManager.hasExperienceBar() || client.options.jumpKey.isPressed() || client.player.getMountJumpStrength() > 0) ? original : null; + @ModifyVariable(method = "renderStatusBars", at = @At("STORE"), ordinal = 10) + private int t(int original) { + return original - (AutumnClient.options.infoHud.getValue() && getRiddenEntity() != null ? getHeartRows(getHeartCount(getRiddenEntity())) * 10 : 0); } - @Inject(method = "shouldRenderExperience", at = @At("HEAD"), cancellable = true) - private void shouldRenderExperience(CallbackInfoReturnable cir) { - if (AutumnClient.options.infoHud.getValue() && client.player != null && client.interactionManager != null && client.interactionManager.hasExperienceBar() && !client.options.jumpKey.isPressed() && client.player.getMountJumpStrength() <= 0) { - cir.setReturnValue(true); - } + @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getJumpingMount()Lnet/minecraft/entity/JumpingMount;")) + private JumpingMount getJumpingMount(ClientPlayerEntity player) { + return AutumnClient.options.infoHud.getValue() && AutumnClient.client.interactionManager != null && (!AutumnClient.client.interactionManager.hasExperienceBar() || AutumnClient.client.options.jumpKey.isPressed() || player.getMountJumpStrength() > 0) ? player.getJumpingMount() : null; } // EffectHud @Inject(method = "renderStatusEffectOverlay", at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z")) - private void renderStatusEffectOverlay(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci, @Local List list, @Local StatusEffectInstance statusEffectInstance, @Local(ordinal = 4) int x, @Local(ordinal = 3) int y) { + private void renderStatusEffectOverlay(DrawContext context, CallbackInfo ci, @Local List list, @Local StatusEffectInstance statusEffectInstance, @Local(ordinal = 4) int x, @Local(ordinal = 3) int y) { if (AutumnClient.options.infoHud.getValue()) { list.add(() -> { String duration = durationString(statusEffectInstance); diff --git a/src/client/java/autumnvn/autumn/mixin/client/TitleScreenMixin.java b/src/client/java/autumnvn/autumn/mixin/client/TitleScreenMixin.java index 73b5ccc..71f76cc 100644 --- a/src/client/java/autumnvn/autumn/mixin/client/TitleScreenMixin.java +++ b/src/client/java/autumnvn/autumn/mixin/client/TitleScreenMixin.java @@ -1,17 +1,19 @@ package autumnvn.autumn.mixin.client; +import autumnvn.autumn.AutumnClient; +import net.minecraft.client.gui.screen.TitleScreen; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; 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 autumnvn.autumn.AutumnClient; -import net.minecraft.client.gui.screen.TitleScreen; @Mixin(TitleScreen.class) public class TitleScreenMixin { + @Final @Shadow @Mutable private boolean doBackgroundFade; diff --git a/src/client/java/autumnvn/autumn/mixin/client/ToastManagerMixin.java b/src/client/java/autumnvn/autumn/mixin/client/ToastManagerMixin.java index ce0f518..73ab281 100644 --- a/src/client/java/autumnvn/autumn/mixin/client/ToastManagerMixin.java +++ b/src/client/java/autumnvn/autumn/mixin/client/ToastManagerMixin.java @@ -7,6 +7,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ToastManager.class) public class ToastManagerMixin { @@ -29,9 +30,9 @@ public void add(CallbackInfo ci) { @Mixin(targets = "net.minecraft.client.toast.ToastManager$Entry") static class Entry { @Inject(method = "draw", at = @At("HEAD"), cancellable = true) - public void draw(DrawContext context, int scaledWindowWidth, CallbackInfo ci) { + public void draw(int x, DrawContext context, CallbackInfoReturnable cir) { if (AutumnClient.options.noToast.getValue()) { - ci.cancel(); + cir.setReturnValue(true); } } } diff --git a/src/client/java/autumnvn/autumn/mixin/client/WorldRendererMixin.java b/src/client/java/autumnvn/autumn/mixin/client/WorldRendererMixin.java index 6da719d..9340580 100644 --- a/src/client/java/autumnvn/autumn/mixin/client/WorldRendererMixin.java +++ b/src/client/java/autumnvn/autumn/mixin/client/WorldRendererMixin.java @@ -2,12 +2,10 @@ import autumnvn.autumn.AutumnClient; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.RenderTickCounter; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.render.*; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; +import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -15,8 +13,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.List; - @Mixin(WorldRenderer.class) public class WorldRendererMixin { @@ -24,11 +20,15 @@ public class WorldRendererMixin { @Shadow private MinecraftClient client; + @Shadow + private void renderEntity(Entity entity, double cameraX, double cameraY, double cameraZ, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers) { + } + // FreeCam - @Inject(method = "renderEntities", at = @At("HEAD")) - private void renderEntities(MatrixStack matrices, VertexConsumerProvider.Immediate immediate, Camera camera, RenderTickCounter tickCounter, List entities, CallbackInfo ci) { + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;checkEmpty(Lnet/minecraft/client/util/math/MatrixStack;)V", ordinal = 0)) + private void onRender(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f projectionMatrix, CallbackInfo ci) { if (AutumnClient.options.freeCam.getValue()) { - entities.add(client.player); + renderEntity(client.player, camera.getPos().x, camera.getPos().y, camera.getPos().z, tickDelta, matrices, client.getBufferBuilders().getEntityVertexConsumers()); } } } diff --git a/src/client/resources/autumn.client.mixins.json b/src/client/resources/autumn.client.mixins.json index d9f4379..863170b 100644 --- a/src/client/resources/autumn.client.mixins.json +++ b/src/client/resources/autumn.client.mixins.json @@ -1,7 +1,7 @@ { "required": true, "package": "autumnvn.autumn.mixin.client", - "compatibilityLevel": "JAVA_21", + "compatibilityLevel": "JAVA_17", "client": [ "AbstractBlockStateMixin", "BackgroundRendererMixin", @@ -13,7 +13,6 @@ "DeathScreenMixin", "EntityMixin", "EntityRendererMixin", - "EntityRenderStateMixin", "FishingBobberEntityRendererMixin", "GameRendererMixin", "InGameHudMixin", diff --git a/src/main/resources/autumn.mixins.json b/src/main/resources/autumn.mixins.json index cd0ada1..5376439 100644 --- a/src/main/resources/autumn.mixins.json +++ b/src/main/resources/autumn.mixins.json @@ -1,7 +1,7 @@ { "required": true, "package": "autumnvn.autumn.mixin", - "compatibilityLevel": "JAVA_21", + "compatibilityLevel": "JAVA_17", "mixins": [], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index e5e783c..6c58f95 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -34,8 +34,8 @@ ], "depends": { "fabricloader": ">=0.16.9", - "minecraft": ">=1.21.4", - "java": ">=21", + "minecraft": ">=1.20.1", + "java": ">=17", "fabric-api": "*" } }