From 616a165f891c00263b490ecdc76cd33334439760 Mon Sep 17 00:00:00 2001 From: mlgnez Date: Sun, 1 May 2022 20:43:35 -0500 Subject: [PATCH] added custoim zoom out becaue it ios ocool anmd totally not buggy and weirtd hehehehahah ahah hHEHEHE --- .../java/rubyboat/ghost/config/Config.java | 18 +++++++++++++++++- .../java/rubyboat/ghost/mixin/CameraMixin.java | 5 ++--- .../ghost/mixin/MinecraftClientMixin.java | 17 +++++++++++++++++ .../resources/assets/ghost/lang/en_us.json | 4 +++- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/main/java/rubyboat/ghost/config/Config.java b/src/main/java/rubyboat/ghost/config/Config.java index 2f33ea7..9a05c77 100644 --- a/src/main/java/rubyboat/ghost/config/Config.java +++ b/src/main/java/rubyboat/ghost/config/Config.java @@ -42,6 +42,8 @@ public class Config { static String weather = ""; static Integer water = 0; static Integer waterfog = 0; + static String version = ""; + static int distance = 0; public static String[] blocks = { "diamond_block", @@ -117,6 +119,9 @@ public static int getZoomStrength() public static Integer grass(){return getConfig().grass;} public static Integer water(){return getConfig().water;} public static Integer waterfog(){return getConfig().waterfog;} + public static String getVersion(){return getConfig().version;} + public static Integer getDistance(){return getConfig().distance;} + public static SerializedConfig config = null; public static SerializedConfig loadConfig() { @@ -156,6 +161,8 @@ public static SerializedConfig loadConfig() Config.model_offset = to_return.model_offset; Config.water = to_return.water; Config.waterfog = to_return.waterfog; + Config.version = to_return.version; + Config.distance = to_return.distance; return to_return; } @@ -294,6 +301,12 @@ public static ConfigBuilder MakeConfig() .setSaveConsumer(newValue -> Config.waterfog = newValue) .setTooltip(new TranslatableText("tooltip.ghost.waterfog")) .build()); + general.addEntry(entryBuilder.startStrField(new TranslatableText("entry.ghost.version"), Config.version) + .setSaveConsumer(newValue -> Config.version = newValue) + .build()); + general.addEntry(entryBuilder.startIntField(new TranslatableText("entry.ghost.distance"), Config.distance) + .setSaveConsumer(newValue -> Config.distance = newValue) + .build()); //Build return builder; } @@ -322,6 +335,8 @@ public static class SerializedConfig public float model_offset; public Integer water; public Integer waterfog; + public String version; + public int distance; public int zoom_strength; @@ -351,7 +366,8 @@ public SerializedConfig() this.model_offset = Config.model_offset; this.water = Config.water; this.waterfog = Config.waterfog; - + this.version = Config.version; + this.distance = Config.distance; } public String serialized(){ return new Gson().toJson(this); diff --git a/src/main/java/rubyboat/ghost/mixin/CameraMixin.java b/src/main/java/rubyboat/ghost/mixin/CameraMixin.java index 218a156..61cab7b 100644 --- a/src/main/java/rubyboat/ghost/mixin/CameraMixin.java +++ b/src/main/java/rubyboat/ghost/mixin/CameraMixin.java @@ -72,7 +72,8 @@ public void update(BlockView area, Entity focusedEntity, boolean thirdPerson, bo if (inverseView) { this.setRotation(this.yaw + 180.0f, -this.pitch); } - this.moveBy(-this.clipToSpace(4.0), 0.0, 0.0); + + this.moveBy(-this.clipToSpace(Config.getDistance()), 0.0, 0.0); } else if (focusedEntity instanceof LivingEntity && ((LivingEntity)focusedEntity).isSleeping()) { Direction direction = ((LivingEntity)focusedEntity).getSleepingDirection(); this.setRotation(direction != null ? direction.asRotation() - 180.0f : 0.0f, 0.0f); @@ -97,6 +98,4 @@ public void getSubmersionType(CallbackInfoReturnable cir){ } } - - } diff --git a/src/main/java/rubyboat/ghost/mixin/MinecraftClientMixin.java b/src/main/java/rubyboat/ghost/mixin/MinecraftClientMixin.java index d65ab23..d7ef740 100644 --- a/src/main/java/rubyboat/ghost/mixin/MinecraftClientMixin.java +++ b/src/main/java/rubyboat/ghost/mixin/MinecraftClientMixin.java @@ -3,6 +3,8 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -15,6 +17,9 @@ @Environment(EnvType.CLIENT) @Mixin(MinecraftClient.class) public abstract class MinecraftClientMixin { + + @Shadow @Nullable public ClientPlayerEntity player; + @Inject(at = @At("HEAD"), method = "tick") public void tick(CallbackInfo ci){ if(GhostClient.keyBinding2.isPressed()) @@ -28,4 +33,16 @@ public void getWindowTitle(CallbackInfoReturnable cir){ cir.setReturnValue(Config.getTitle()); } } + @Inject(at = @At("HEAD"), method = "getGameVersion", cancellable = true) + public void getGameVersion(CallbackInfoReturnable cir){ + if(!Config.getVersion().equalsIgnoreCase("")){ + cir.setReturnValue(Config.getVersion()); + } + } + @Inject(at = @At("HEAD"), method = "getVersionType", cancellable = true) + public void getVersionType(CallbackInfoReturnable cir){ + if(!Config.getVersion().equalsIgnoreCase("")){ + cir.setReturnValue(Config.getVersion()); + } + } } diff --git a/src/main/resources/assets/ghost/lang/en_us.json b/src/main/resources/assets/ghost/lang/en_us.json index 116b455..fbde274 100644 --- a/src/main/resources/assets/ghost/lang/en_us.json +++ b/src/main/resources/assets/ghost/lang/en_us.json @@ -41,5 +41,7 @@ "entry.ghost.water": "Water Color", "tooltip.ghost.water": "Base value: 000000", "entry.ghost.waterfog":"Water Fog Color", - "tooltip.ghost.waterfog": "Base value: 000000" + "tooltip.ghost.waterfog": "Base value: 000000", + "entry.ghost.version": "Minecraft Version", + "entry.ghost.distance": "Zoom Out Camera Distance" } \ No newline at end of file