diff --git a/src/main/java/io/github/solclient/client/mixin/client/ClientPlayerInteractionManagerAccessor.java b/src/main/java/io/github/solclient/client/mixin/client/ClientPlayerInteractionManagerAccessor.java new file mode 100644 index 00000000..cebecfbb --- /dev/null +++ b/src/main/java/io/github/solclient/client/mixin/client/ClientPlayerInteractionManagerAccessor.java @@ -0,0 +1,30 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package io.github.solclient.client.mixin.client; + +import net.minecraft.client.network.ClientPlayerInteractionManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(ClientPlayerInteractionManager.class) +public interface ClientPlayerInteractionManagerAccessor { + + @Accessor("breakingBlock") + void setHitting(boolean value); +} diff --git a/src/main/java/io/github/solclient/client/mixin/mod/V1_7VisualsModMixins.java b/src/main/java/io/github/solclient/client/mixin/mod/V1_7VisualsModMixins.java index 2ead2c49..117f6318 100644 --- a/src/main/java/io/github/solclient/client/mixin/mod/V1_7VisualsModMixins.java +++ b/src/main/java/io/github/solclient/client/mixin/mod/V1_7VisualsModMixins.java @@ -18,26 +18,92 @@ package io.github.solclient.client.mixin.mod; -import org.spongepowered.asm.mixin.*; -import org.spongepowered.asm.mixin.injection.*; -import org.spongepowered.asm.mixin.injection.callback.*; - -import io.github.solclient.client.mod.impl.V1_7VisualsMod; +import com.mojang.blaze3d.platform.GlStateManager; +import io.github.solclient.client.mixin.client.ClientPlayerInteractionManagerAccessor; +import io.github.solclient.client.mod.impl.v1_7visuals.*; import io.github.solclient.client.util.MinecraftUtils; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.hud.DebugHud; import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.network.ClientPlayerInteractionManager; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer; +import net.minecraft.client.render.entity.model.BiPedModel; import net.minecraft.client.render.item.HeldItemRenderer; +import net.minecraft.client.render.item.ItemRenderer; +import net.minecraft.client.render.model.BakedModel; +import net.minecraft.client.render.model.json.ModelTransformation; +import net.minecraft.client.util.Window; import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BlockItem; +import net.minecraft.item.BucketItem; import net.minecraft.item.ItemStack; +import net.minecraft.util.UseAction; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.world.LightType; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public abstract class V1_7VisualsModMixins { - @Mixin(HeldItemRenderer.class) + @Mixin(ItemRenderer.class) public static abstract class ItemRendererMixin { + @Unique + private LivingEntity lastEntityToRenderFor = null; + + @Final + private final MinecraftClient mc = MinecraftClient.getInstance(); + + @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;)V", at = @At("HEAD")) + public void renderItemModelForEntity(ItemStack stack, LivingEntity entity, ModelTransformation.Mode mode, + CallbackInfo ci) { + lastEntityToRenderFor = entity; + } + + @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/ItemRenderer;renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/BakedModel;)V")) + public void renderItemModelForEntity_renderItem(ItemStack stack, BakedModel model, + ModelTransformation.Mode transformation, CallbackInfo ci) { + if (V1_7VisualsMod.enabled && V1_7VisualsMod.instance.useAndMine + && transformation == ModelTransformation.Mode.THIRD_PERSON + && lastEntityToRenderFor instanceof PlayerEntity && mc.player.getStackInHand() != null + && mc.player.getItemUseTicks() > 0 + && mc.player.getStackInHand().getUseAction() == UseAction.BLOCK) { + GlStateManager.translate(-0.041, -0.095f, 0.212f); + GlStateManager.rotate(80, 1.0f, 0.0f, 0.0f); + GlStateManager.rotate(20, 0.0f, 1.0f, 0.0f); + if (MinecraftClient.getInstance().player.isSneaking()) { + GlStateManager.translate(-0.045, -0.0135f, 0.03); + } + } + } + + } + + @Mixin(HeldItemRenderer.class) + public static abstract class HeldItemRendererMixin { + + @Shadow + protected abstract void applyEquipAndSwingOffset(float equipProgress, float swingProgress); + + @Shadow + private @Final MinecraftClient client; + + @Shadow + private ItemStack mainHand; + @Redirect(method = "renderArmHoldingItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyEquipAndSwingOffset(FF)V")) public void allowUseAndSwing(HeldItemRenderer instance, float equipProgress, float swingProgress) { applyEquipAndSwingOffset(equipProgress, @@ -49,7 +115,8 @@ public void allowUseAndSwing(HeldItemRenderer instance, float equipProgress, flo @Inject(method = "applySwordBlockTransformation", at = @At("RETURN")) public void oldBlocking(CallbackInfo callback) { if (V1_7VisualsMod.enabled && V1_7VisualsMod.instance.blocking) { - V1_7VisualsMod.oldBlocking(); + GlStateManager.scale(0.83F, 0.88F, 0.85F); + GlStateManager.translate(-0.3F, 0.10F, -0.01F); } } @@ -60,54 +127,34 @@ public void oldDrinking(AbstractClientPlayerEntity clientPlayer, float partialTi V1_7VisualsMod.oldDrinking(mainHand, clientPlayer, partialTicks); } } - - @Shadow - protected abstract void applyEquipAndSwingOffset(float equipProgress, float swingProgress); - - @Shadow - private @Final MinecraftClient client; - - @Shadow - private ItemStack mainHand; - } @Mixin(GameRenderer.class) public static abstract class GameRendererMixin { - private float eyeHeightSubtractor; - private long lastEyeHeightUpdate; + private float lastEyeHeight; + @Shadow + private /* why you not final :( */ MinecraftClient client; // this code makes me long for spaghetti + // edit: i've eaten it up, yum @Redirect(method = "transformCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getEyeHeight()F")) - public float smoothSneaking(Entity entity) { - if (V1_7VisualsMod.enabled && V1_7VisualsMod.instance.sneaking && entity instanceof PlayerEntity) { - PlayerEntity player = (PlayerEntity) entity; - float height = player.getEyeHeight(); - if (player.isSneaking()) { - height += 0.08F; - } - float actualEyeHeightSubtractor = player.isSneaking() ? 0.08F : 0; - long sinceLastUpdate = System.currentTimeMillis() - lastEyeHeightUpdate; - lastEyeHeightUpdate = System.currentTimeMillis(); - if (actualEyeHeightSubtractor > eyeHeightSubtractor) { - eyeHeightSubtractor += sinceLastUpdate / 500f; - if (actualEyeHeightSubtractor < eyeHeightSubtractor) { - eyeHeightSubtractor = actualEyeHeightSubtractor; - } - } else if (actualEyeHeightSubtractor < eyeHeightSubtractor) { - eyeHeightSubtractor -= sinceLastUpdate / 500f; - if (actualEyeHeightSubtractor > eyeHeightSubtractor) { - eyeHeightSubtractor = actualEyeHeightSubtractor; - } - } - return height - eyeHeightSubtractor; - } - return entity.getEyeHeight(); + public float smoothSneaking(Entity entity, float tickDelta) { + if (!(V1_7VisualsMod.enabled && V1_7VisualsMod.instance.sneaking)) + return entity.getEyeHeight(); + + return lastEyeHeight + (((Sneaky) entity).get1_7InternalEyeHeight() - lastEyeHeight) * tickDelta; } - @Shadow - private /* why you not final :( */ MinecraftClient client; + @Redirect(method = "renderDebugCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getEyeHeight()F")) + public float smoothDebugSneaking(Entity entity, float tickDelta) { + return smoothSneaking(entity, tickDelta); + } + + @Inject(method = "tick", at = @At("HEAD")) + public void swap(CallbackInfo callback) { + lastEyeHeight = ((Sneaky) client.getCameraEntity()).get1_7InternalEyeHeight(); + } } @@ -119,6 +166,207 @@ public void oldArmour(CallbackInfoReturnable callback) { if (V1_7VisualsMod.enabled && V1_7VisualsMod.instance.armourDamage) callback.setReturnValue(true); } + } + + @Mixin(BiPedModel.class) + public static class BiPedModelMixin { + + @ModifyConstant(method = "setAngles", constant = @Constant(floatValue = -0.5235988F)) + private float cancelRotation(float value) { + return (V1_7VisualsMod.enabled && V1_7VisualsMod.instance.blocking) ? 0.0F : value; + } + } + + @Mixin(MinecraftClient.class) + public static class MinecraftClientMixin { + + @Unique + private boolean isHittingBlock = false; + + @Inject(method = "doUse", at = @At("HEAD")) + public void punchDuringUsagePart1(CallbackInfo ci) { + if (V1_7VisualsMod.enabled && V1_7VisualsMod.instance.useAndMine + && MinecraftClient.getInstance().player.abilities.allowModifyWorld + && MinecraftClient.getInstance().player.getStackInHand() != null + && MinecraftClient.getInstance().result.type == BlockHitResult.Type.BLOCK && + !(MinecraftClient.getInstance().player.getStackInHand().getItem() instanceof BlockItem)) { + isHittingBlock = MinecraftClient.getInstance().interactionManager.isBreakingBlock(); + MinecraftClient.getInstance().interactionManager.cancelBlockBreaking(); + ((ClientPlayerInteractionManagerAccessor) MinecraftClient.getInstance().interactionManager).setHitting(false); + } + } + + @Inject(method = "doUse", at = @At("RETURN")) + public void punchDuringUsagePart2(CallbackInfo ci) { + if (V1_7VisualsMod.enabled && V1_7VisualsMod.instance.useAndMine + && !MinecraftClient.getInstance().interactionManager.isBreakingBlock() + && MinecraftClient.getInstance().player.abilities.allowModifyWorld + && MinecraftClient.getInstance().player.getStackInHand() != null + && MinecraftClient.getInstance().result.type == BlockHitResult.Type.BLOCK && + !(MinecraftClient.getInstance().player.getStackInHand().getItem() instanceof BlockItem)) { + MinecraftClient.getInstance().interactionManager.cancelBlockBreaking(); + ((ClientPlayerInteractionManagerAccessor) MinecraftClient.getInstance().interactionManager).setHitting(isHittingBlock); + } + } + } + + @Mixin(ClientPlayerInteractionManager.class) + public static class ClientPlayerInteractionManagerMixin { + @Shadow + private @Final MinecraftClient client; + + @Inject(method = "isBreakingBlock", at = @At("HEAD"), cancellable = true) + private void punchingAndUseBlocks(CallbackInfoReturnable cir) { + if (V1_7VisualsMod.enabled && V1_7VisualsMod.instance.useAndMine && + client.player.abilities.allowModifyWorld && client.player.getStackInHand() != null && + client.player.getStackInHand().getItem() instanceof BlockItem) { + cir.setReturnValue(false); + } + } + } + + @Mixin(DebugHud.class) + public static class DebugHudMixin { + + @Inject(method = "renderLeftText", at = @At("HEAD"), cancellable = true) + public void render(CallbackInfo callback) { + if (!active()) + return; + + callback.cancel(); + + TextRenderer text = client.textRenderer; + + String debug = client.fpsDebugString; + debug = debug.substring(0, client.fpsDebugString.indexOf(") ") + 1); + debug = debug.replace(" (", ", "); + debug = '(' + debug; + // *really* + debug = debug.replace("update)", "updates)"); + debug = "Minecraft 1.8.9 " + debug; + text.drawWithShadow(debug, 2, 2, -1); + + String chunksDebug = client.worldRenderer.getChunksDebugString(); + text.drawWithShadow(chunksDebug, 2, 12, -1); + + text.drawWithShadow(client.worldRenderer.getEntitiesDebugString(), 2, 22, -1); + text.drawWithShadow(String.format("P: %s T: %s", client.particleManager.getDebugString(), + client.world.addDetailsToCrashReport()), 2, 32, -1); + text.drawWithShadow(client.world.getDebugString(), 2, 42, -1); + + PlayerEntity player = client.player; + World world = client.world; + + double x = player.x; + double y = player.y; + double z = player.z; + + int xFloor = MathHelper.floor(x); + int yFloor = MathHelper.floor(y); + int zFloor = MathHelper.floor(z); + + text.drawWithShadow(String.format("x: %.5f (%d) // c: %d (%d)", x, xFloor, xFloor >> 4, xFloor & 15), 2, 64, + 0xE0E0E0); + text.drawWithShadow(String.format("y: %.3f (feet pos, %.3f eyes pos)", y, + y + ((Sneaky) player).get1_7InternalEyeHeight()), 2, 72, 0xE0E0E0); + text.drawWithShadow(String.format("z: %.5f (%d) // c: %d (%d)", z, zFloor, zFloor >> 4, zFloor & 15), 2, 80, + 0xE0E0E0); + + int f = MathHelper.floor(player.yaw * 4F / 360F + 0.5) & 3; + text.drawWithShadow( + String.format("f: %d (%s) / %.5f", f, DIRECTIONS[f], MathHelper.wrapDegrees(client.player.yaw)), 2, + 88, 0xE0E0E0); + + BlockPos absPos = new BlockPos(xFloor, yFloor, zFloor); + if (world != null && world.blockExists(absPos)) { + Chunk chunk = world.getChunk(absPos); + BlockPos relativePos = new BlockPos(xFloor & 15, yFloor, zFloor & 15); + text.drawWithShadow( + String.format("lc: %d b: %s bl: %d sl %d rl: %d", chunk.getHighestNonEmptySectionYOffset() + 15, + chunk.getBiomeAt(absPos, world.getBiomeSource()).name, + chunk.getLightAtPos(LightType.BLOCK, relativePos), + chunk.getLightAtPos(LightType.SKY, relativePos), chunk.getLightLevel(relativePos, 0)), + 2, 96, 0xE0E0E0); + } + + text.drawWithShadow(String.format("ws: %.3f, fs: %.3f, g: %b, fl: %d", player.abilities.getWalkSpeed(), + player.abilities.getFlySpeed(), player.onGround, + MinecraftUtils.getHeightValue(world, xFloor, zFloor)), 2, 104, 0xE0E0E0); + + if (client.gameRenderer.areShadersSupported() && client.gameRenderer.getShader() != null) + text.drawWithShadow(String.format("shader: %s", client.gameRenderer.getShader().getName()), 2, 112, + 0xE0E0E0); + } + + @Inject(method = "renderRightText", at = @At("HEAD"), cancellable = true) + public void render(Window window, CallbackInfo callback) { + if (!active()) + return; + + callback.cancel(); + + TextRenderer text = client.textRenderer; + long max = Runtime.getRuntime().maxMemory(); + long total = Runtime.getRuntime().totalMemory(); + long free = Runtime.getRuntime().freeMemory(); + long used = total - free; + + String usedString = String.format("Used memory: %d%% (%dMB) of %dMB", used * 100 / max, used / 1024 / 1024, + max / 1024 / 1024); + text.drawWithShadow(usedString, window.getWidth() - text.getStringWidth(usedString), 2, 0xE0E0E0); + + String allocatedString = String.format("Allocated memory: %d%% (%dMB)", total * 100 / max, + total / 1024 / 1024); + text.drawWithShadow(allocatedString, window.getWidth() - text.getStringWidth(allocatedString), 12, + 0xE0E0E0); + } + + @Shadow + private @Final MinecraftClient client; + + private static final String[] DIRECTIONS = { "SOUTH", "WEST", "NORTH", "EAST" }; + + private static boolean active() { + return V1_7VisualsMod.enabled && V1_7VisualsMod.instance.debug; + } + + } + + @Mixin(Entity.class) + public static abstract class EntityMixin implements Sneaky { + + private float internalEyeHeight = Float.NaN; + + private boolean active() { + return world.isClient && V1_7VisualsMod.enabled && V1_7VisualsMod.instance.sneaking && (Object) this == MinecraftClient.getInstance().getCameraEntity(); + } + + @Override + public float get1_7InternalEyeHeight() { + if (!active()) + return getEyeHeight(); + + return internalEyeHeight; + } + + @Inject(method = "tick", at = @At("HEAD")) + public void tick(CallbackInfo callback) { + if (!active()) + return; + + float realEyeHeight = getEyeHeight(); + // if we're aiming for a lower value, go straight there... for some reason + if (realEyeHeight < internalEyeHeight || internalEyeHeight != internalEyeHeight) + internalEyeHeight = getEyeHeight(); + else + internalEyeHeight += (realEyeHeight - internalEyeHeight) * 0.6F; + } + + @Shadow + public abstract float getEyeHeight(); + + @Shadow + public World world; } diff --git a/src/main/java/io/github/solclient/client/mod/ModManager.java b/src/main/java/io/github/solclient/client/mod/ModManager.java index 05df7732..d4f04ff6 100644 --- a/src/main/java/io/github/solclient/client/mod/ModManager.java +++ b/src/main/java/io/github/solclient/client/mod/ModManager.java @@ -48,6 +48,7 @@ import io.github.solclient.client.mod.impl.replay.SCReplayMod; import io.github.solclient.client.mod.impl.toggles.TogglesMod; import io.github.solclient.client.mod.impl.tweaks.TweaksMod; +import io.github.solclient.client.mod.impl.v1_7visuals.V1_7VisualsMod; public final class ModManager implements Iterable { diff --git a/src/main/java/io/github/solclient/client/mod/impl/v1_7visuals/Sneaky.java b/src/main/java/io/github/solclient/client/mod/impl/v1_7visuals/Sneaky.java new file mode 100644 index 00000000..02795130 --- /dev/null +++ b/src/main/java/io/github/solclient/client/mod/impl/v1_7visuals/Sneaky.java @@ -0,0 +1,29 @@ +/* + * Sol Client - an open source Minecraft client + * Copyright (C) 2021-2023 TheKodeToad and Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package io.github.solclient.client.mod.impl.v1_7visuals; + +/** + * Used to simulate the internal eye height in 1.7 before it's processed by the camera. + * This is what gives it the interesting look. + */ +public interface Sneaky { + + float get1_7InternalEyeHeight(); + +} diff --git a/src/main/java/io/github/solclient/client/mod/impl/V1_7VisualsMod.java b/src/main/java/io/github/solclient/client/mod/impl/v1_7visuals/V1_7VisualsMod.java similarity index 75% rename from src/main/java/io/github/solclient/client/mod/impl/V1_7VisualsMod.java rename to src/main/java/io/github/solclient/client/mod/impl/v1_7visuals/V1_7VisualsMod.java index 6cb397b8..fb61313c 100644 --- a/src/main/java/io/github/solclient/client/mod/impl/V1_7VisualsMod.java +++ b/src/main/java/io/github/solclient/client/mod/impl/v1_7visuals/V1_7VisualsMod.java @@ -16,18 +16,22 @@ * along with this program. If not, see . */ -package io.github.solclient.client.mod.impl; +package io.github.solclient.client.mod.impl.v1_7visuals; import com.google.gson.annotations.Expose; import com.mojang.blaze3d.platform.GlStateManager; - import io.github.solclient.client.event.EventHandler; -import io.github.solclient.client.event.impl.*; +import io.github.solclient.client.event.impl.PreTickEvent; +import io.github.solclient.client.event.impl.TransformFirstPersonItemEvent; import io.github.solclient.client.mixin.client.LivingEntityAccessor; -import io.github.solclient.client.mod.*; +import io.github.solclient.client.mod.ModCategory; +import io.github.solclient.client.mod.impl.SolClientMod; import io.github.solclient.client.mod.option.annotation.Option; import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.item.*; +import net.minecraft.entity.Entity; +import net.minecraft.item.BowItem; +import net.minecraft.item.FishingRodItem; +import net.minecraft.item.ItemStack; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.MathHelper; @@ -40,25 +44,29 @@ public class V1_7VisualsMod extends SolClientMod { public boolean useAndMine = true; @Expose @Option - private boolean particles = true; + private final boolean bow = true; @Expose @Option - public boolean blocking = true; + private final boolean rod = true; @Expose @Option - public boolean eatingAndDrinking = true; + private final boolean particles = true; @Expose @Option - private boolean bow = true; + public boolean blocking = true; @Expose @Option - private boolean rod = true; + public boolean eatingAndDrinking = true; + @Expose @Option public boolean armourDamage = true; @Expose @Option public boolean sneaking = true; + @Expose + @Option + public boolean debug = true; public static V1_7VisualsMod instance; public static boolean enabled; @@ -98,17 +106,14 @@ public boolean isEnabledByDefault() { @EventHandler public void onTick(PreTickEvent event) { - if (mc.player != null && mc.player.abilities.allowModifyWorld && isEnabled() && useAndMine && mc.result != null - && mc.result.type == BlockHitResult.Type.BLOCK && mc.player != null && mc.options.attackKey.isPressed() - && mc.options.useKey.isPressed() && mc.player.getItemUseTicks() > 0) { - if ((!mc.player.handSwinging - || mc.player.handSwingTicks >= ((LivingEntityAccessor) mc.player).getArmSwingAnimationEnd() - / 2 + if (mc.player != null && isEnabled() && useAndMine && mc.player.abilities.allowModifyWorld && + mc.result != null && mc.result.type == BlockHitResult.Type.BLOCK && mc.options.attackKey.isPressed() && + mc.options.useKey.isPressed() && mc.player.getItemUseTicks() > 0) { + if ((!mc.player.handSwinging || mc.player.handSwingTicks >= ((LivingEntityAccessor) mc.player).getArmSwingAnimationEnd() / 2 || mc.player.handSwingTicks < 0)) { mc.player.handSwingTicks = -1; mc.player.handSwinging = true; } - if (particles) { mc.particleManager.addBlockBreakingParticles(mc.result.getBlockPos(), mc.result.direction); } @@ -117,10 +122,6 @@ public void onTick(PreTickEvent event) { @EventHandler public void onItemTransform(TransformFirstPersonItemEvent event) { - if (!(bow || rod)) { - return; - } - // https://github.com/sp614x/optifine/issues/2098 if (mc.player.isUsingItem() && event.itemToRender.getItem() instanceof BowItem) { if (bow) @@ -128,11 +129,13 @@ public void onItemTransform(TransformFirstPersonItemEvent event) { } else if ((event.itemToRender.getItem() instanceof FishingRodItem) && rod) { GlStateManager.translate(0.08f, -0.027f, -0.33f); GlStateManager.scale(0.93f, 1.0f, 1.0f); + } else if (event.itemToRender.getItem() != null) { + GlStateManager.rotate(-1, 0.0f, 1.0f, 0.0f); + GlStateManager.translate(-0.027, 0.002, 0.0005); } } - public static void oldDrinking(ItemStack itemToRender, AbstractClientPlayerEntity clientPlayer, - float partialTicks) { + public static void oldDrinking(ItemStack itemToRender, AbstractClientPlayerEntity clientPlayer, float partialTicks) { float var14 = clientPlayer.getItemUseTicks() - partialTicks + 1.0F; float var15 = 1.0F - var14 / itemToRender.getMaxUseTime(); float var16 = 1.0F - var15; @@ -150,10 +153,4 @@ public static void oldDrinking(ItemStack itemToRender, AbstractClientPlayerEntit GlStateManager.translate(0, -0.0F, 0.06F); GlStateManager.rotate(-4F, 1, 0, 0); } - - public static void oldBlocking() { - GlStateManager.scale(0.83F, 0.88F, 0.85F); - GlStateManager.translate(-0.3F, 0.1F, 0.0F); - } - } diff --git a/src/main/java/io/github/solclient/client/util/MinecraftUtils.java b/src/main/java/io/github/solclient/client/util/MinecraftUtils.java index 48af22b3..c0b18dc8 100644 --- a/src/main/java/io/github/solclient/client/util/MinecraftUtils.java +++ b/src/main/java/io/github/solclient/client/util/MinecraftUtils.java @@ -24,7 +24,6 @@ import java.nio.ByteBuffer; import java.nio.channels.*; import java.nio.charset.StandardCharsets; -import java.nio.file.*; import java.util.*; import java.util.concurrent.*; import java.util.function.IntConsumer; @@ -64,6 +63,8 @@ import net.minecraft.util.*; import net.minecraft.util.Util.OperatingSystem; import net.minecraft.util.math.Box; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; /** * Utils involving Minecraft classes. @@ -382,66 +383,65 @@ public void openUrl(String url) { } switch (Util.getOperatingSystem()) { - case LINUX: - if (reveal) { - if (new File("/usr/bin/xdg-mime").exists() && new File("/usr/bin/gio").exists()) { - try { - Process process = new ProcessBuilder("xdg-mime", "query", "default", "inode/directory") - .start(); - int code = process.waitFor(); - - if (code > 0) { - throw new IllegalStateException("xdg-mime exited with code " + code); - } - - String file; - try (BufferedReader reader = new BufferedReader( - new InputStreamReader(process.getInputStream()))) { - file = reader.readLine(); - } + case LINUX: + if (reveal) { + if (new File("/usr/bin/xdg-mime").exists() && new File("/usr/bin/gio").exists()) { + try { + Process process = new ProcessBuilder("xdg-mime", "query", "default", "inode/directory").start(); + int code = process.waitFor(); + + if (code > 0) { + throw new IllegalStateException("xdg-mime exited with code " + code); + } - if (file != null) { - url = decodeUrl(url); - url = url.substring(7); + String file; + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(process.getInputStream()))) { + file = reader.readLine(); + } - if (!file.startsWith("/")) { - file = "/usr/share/applications/" + file; - } + if (file != null) { + url = decodeUrl(url); + url = url.substring(7); - command = new String[] { "gio", "launch", file, url }; - break; + if (!file.startsWith("/")) { + file = "/usr/share/applications/" + file; } - } catch (IOException | InterruptedException | IllegalStateException error) { - Client.LOGGER.error("Could not determine directory handler:", error); + + command = new String[] { "gio", "launch", file, url }; + break; } + } catch (IOException | InterruptedException | IllegalStateException error) { + Client.LOGGER.error("Could not determine directory handler:", error); } - url = urlDirname(url); } + url = urlDirname(url); + } - if (new File("/usr/bin/xdg-open").exists()) { - command = new String[] { "xdg-open", url }; - break; - } - // fall through to default - default: - // fall back to AWT, but without a message - command = null; - break; - case MACOS: - if (reveal) { - command = new String[] { "open", "-R", decodeUrl(url).substring(7) }; - } else { - command = new String[] { "open", url }; - } + if (new File("/usr/bin/xdg-open").exists()) { + command = new String[] { "xdg-open", url }; break; - case WINDOWS: - if (reveal) { - command = new String[] { "Explorer", "/select," + decodeUrl(url).substring(8).replace('/', '\\') }; - } else { - command = new String[] { "rundll32", "url.dll,FileProtocolHandler", url }; - } + } + // fall through to default + default: + // fall back to AWT, but without a message + command = null; + break; + case MACOS: + if (reveal) { + command = new String[] { "open", "-R", decodeUrl(url).substring(7) }; + } else { + command = new String[] { "open", url }; + } + break; + case WINDOWS: + if (reveal) { + command = new String[] { "Explorer", "/select," + decodeUrl(url).substring(8).replace('/', '\\') }; + } else { + command = new String[] { "rundll32", "url.dll,FileProtocolHandler", url }; + } - break; + break; } if (command != null) { @@ -545,12 +545,12 @@ public String getScoreboardTitle() { public String getNativeFileExtension() { switch (Util.getOperatingSystem()) { - case WINDOWS: - return "dll"; - case MACOS: - return "dylib"; - default: - return "so"; + case WINDOWS: + return "dll"; + case MACOS: + return "dylib"; + default: + return "so"; } } @@ -768,4 +768,16 @@ public UUID getPlayerUuid() { return MinecraftClient.getInstance().getSession().getProfile().getId(); } + public int getHeightValue(World world, int x, int y) { + if (x >= -30000000 && y >= -30000000 && x < 30000000 && y < 30000000) { + if (!world.getChunkProvider().chunkExists(x >> 4, y >> 4)) { + return 0; + } else { + Chunk chunk = world.getChunk(x >> 4, y >> 4); + return chunk.getHighestBlockY(x & 15, y & 15); + } + } else + return 64; + } + } diff --git a/src/main/resources/assets/sol_client/lang/en_US.lang b/src/main/resources/assets/sol_client/lang/en_US.lang index d36d9508..54c17697 100644 --- a/src/main/resources/assets/sol_client/lang/en_US.lang +++ b/src/main/resources/assets/sol_client/lang/en_US.lang @@ -386,6 +386,7 @@ sol_client.mod.1.7_visuals.option.rod=Fishing rod sol_client.mod.1.7_visuals.option.bow=Bow sol_client.mod.1.7_visuals.option.armourDamage=Damage effect on armor sol_client.mod.1.7_visuals.option.sneaking=Animated sneaking +sol_client.mod.1.7_visuals.option.debug=Debug overlay sol_client.mod.item_physics.name=Item Physics sol_client.mod.item_physics.description=Add a spinning animation to items. diff --git a/src/main/resources/sol-client.mixins.json b/src/main/resources/sol-client.mixins.json index df8e19f0..10288c14 100644 --- a/src/main/resources/sol-client.mixins.json +++ b/src/main/resources/sol-client.mixins.json @@ -29,6 +29,7 @@ "client.ChatScreenMixin", "client.ClickEventMixin", "client.ClientPlayerEntityMixin", + "client.ClientPlayerInteractionManagerAccessor", "client.ClientPlayNetworkHandlerMixin", "client.ClientWorldMixin", "client.ControlsOptionsScreenMixin", @@ -53,6 +54,7 @@ "client.MinecraftClientAccessor", "client.MinecraftClientMixin", "client.ModelLoaderAccessor", + "client.PlayerListHudMixin", "client.PlayerSkinTexture$1Mixin", "client.ResourcePackEntryWidgetMixin", "client.ResourcePackListWidgetMixin", @@ -68,59 +70,64 @@ "client.TranslationStorageMixin", "client.VertexBufferMixin", "client.WorldRendererAccessor", - "client.PlayerListHudMixin", "lwjgl.GLContextAccessor", "lwjgl.LinuxKeyboardMixin", "lwjgl.LinuxKeycodesAccessor", "lwjgl.NanoVGGLConfigMixin", "lwjgl.WindowsDisplayMixin", - "mod.ChatModMixins$ScreenMixin", - "mod.ChatModMixins$GameOptionsMixin", - "mod.ChatModMixins$TextsMixin", - "mod.ChatModMixins$ChatScreenMixin", + "mod.ChatModMixins$ChatHudLineMixin", "mod.ChatModMixins$ChatHudMixin", - "mod.ChatModMixins$MinecraftClientMixin", "mod.ChatModMixins$ChatOptionsScreenMixin", - "mod.ChatModMixins$ChatHudLineMixin", + "mod.ChatModMixins$ChatScreenMixin", + "mod.ChatModMixins$GameOptionsMixin", + "mod.ChatModMixins$MinecraftClientMixin", + "mod.ChatModMixins$ScreenMixin", + "mod.ChatModMixins$TextsMixin", "mod.ChunkAnimatorModMixins$BuiltChunkMixin", "mod.ChunkAnimatorModMixins$ClientPlayerInteractionManagerMixin", "mod.CosmeticaModMixins$PlayerEntityRendererMixin", + "mod.CrosshairModMixins$GameRendererMixin", "mod.HypixelAdditionsModMixins$PlayerEntityRendererMixin", - "mod.SCReplayModMixins$MinecraftClientMixin", + "mod.ItemPhysicsModMixins$ItemEntityMixin", + "mod.ScreenshotsModMixins$ScreenshotUtilsMixin", + "mod.SCReplayModMixins$AbstractGuiSliderMixin", + "mod.SCReplayModMixins$CameraEntityMixin", + "mod.SCReplayModMixins$ClassicCameraControllerMixin", "mod.SCReplayModMixins$GameRendererMixin", + "mod.SCReplayModMixins$GuiHandlerMixin", + "mod.SCReplayModMixins$GuiRecordingOverlayMixin", + "mod.SCReplayModMixins$GuiReplayViewerMixin", + "mod.SCReplayModMixins$GuiSavingReplayMixin", "mod.SCReplayModMixins$InGameHudMixin", "mod.SCReplayModMixins$MCVerMixin", - "mod.SCReplayModMixins$CameraEntityMixin", - "mod.SCReplayModMixins$GuiReplayViewerMixin", + "mod.SCReplayModMixins$MinecraftClientMixin", + "mod.SCReplayModMixins$PacketListenerMixin", "mod.SCReplayModMixins$ReplayModMixin", - "mod.SCReplayModMixins$GuiSavingReplayMixin", - "mod.SCReplayModMixins$ClassicCameraControllerMixin", "mod.SCReplayModMixins$VanillaCameraControllerMixin", - "mod.SCReplayModMixins$GuiRecordingOverlayMixin", - "mod.SCReplayModMixins$AbstractGuiSliderMixin", - "mod.SCReplayModMixins$GuiHandlerMixin", - "mod.SCReplayModMixins$PacketListenerMixin", - "mod.ScreenshotsModMixins$ScreenshotUtilsMixin", - "mod.ScrollableTooltipsModMixins$ScreenMixin", "mod.ScrollableTooltipsModMixins$HandledScreenMixin", - "mod.TNTTimerModMixins$TntEntityRendererMixin", + "mod.ScrollableTooltipsModMixins$ScreenMixin", "mod.TabListModMixins$PlayerListHudMixin", - "mod.TweaksModMixins$InGameHudMixin", + "mod.TNTTimerModMixins$TntEntityRendererMixin", + "mod.TweaksModMixins$DisconnectedScreenMixin", "mod.TweaksModMixins$EnchantmentMixin", - "mod.TweaksModMixins$InventoryScreenMixin", - "mod.TweaksModMixins$PotionItemMixin", - "mod.TweaksModMixins$RendererLivingEntityMixin", - "mod.TweaksModMixins$GameRendererMixin", "mod.TweaksModMixins$GameMenuScreenMixin", - "mod.TweaksModMixins$MinecraftClientMixin", + "mod.TweaksModMixins$GameRendererMixin", + "mod.TweaksModMixins$InGameHudMixin", + "mod.TweaksModMixins$InventoryScreenMixin", "mod.TweaksModMixins$ItemRendererMixin", - "mod.TweaksModMixins$DisconnectedScreenMixin", - "mod.TweaksModMixins$ParticleManagerMixin", + "mod.TweaksModMixins$MinecraftClientMixin", "mod.TweaksModMixins$MouseInputMixin", - "mod.V1_7VisualsModMixins$ItemRendererMixin", + "mod.TweaksModMixins$ParticleManagerMixin", + "mod.TweaksModMixins$PotionItemMixin", + "mod.TweaksModMixins$RendererLivingEntityMixin", + "mod.V1_7VisualsModMixins$BiPedModelMixin", + "mod.V1_7VisualsModMixins$ClientPlayerInteractionManagerMixin", + "mod.V1_7VisualsModMixins$DebugHudMixin", + "mod.V1_7VisualsModMixins$EntityMixin", "mod.V1_7VisualsModMixins$GameRendererMixin", + "mod.V1_7VisualsModMixins$HeldItemRendererMixin", + "mod.V1_7VisualsModMixins$ItemRendererMixin", "mod.V1_7VisualsModMixins$LayerArmorBaseMixin", - "mod.ItemPhysicsModMixins$ItemEntityMixin", - "mod.CrosshairModMixins$GameRendererMixin" + "mod.V1_7VisualsModMixins$MinecraftClientMixin" ] }