Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubyboat1207 committed Jun 17, 2022
2 parents 98624c8 + 6dec213 commit b819559
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/main/java/rubyboat/ghost/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,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",
Expand Down Expand Up @@ -134,6 +136,9 @@ public static boolean getBouncy()
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()
{
Expand Down Expand Up @@ -174,6 +179,7 @@ public static SerializedConfig loadConfig()
Config.water = to_return.water;
Config.waterfog = to_return.waterfog;
Config.bouncy = to_return.bouncy;
Config.distance = to_return.distance;
return to_return;
}

Expand Down Expand Up @@ -321,6 +327,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;
}
Expand Down Expand Up @@ -351,6 +363,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;

Expand Down Expand Up @@ -380,6 +394,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;
this.bouncy = Config.bouncy;
this.antfarm = Config.antfarm;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/rubyboat/ghost/mixin/CameraMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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);
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/rubyboat/ghost/mixin/MinecraftClientMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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())
Expand All @@ -28,4 +33,16 @@ public void getWindowTitle(CallbackInfoReturnable<String> cir){
cir.setReturnValue(Config.getTitle());
}
}
@Inject(at = @At("HEAD"), method = "getGameVersion", cancellable = true)
public void getGameVersion(CallbackInfoReturnable<String> cir){
if(!Config.getVersion().equalsIgnoreCase("")){
cir.setReturnValue(Config.getVersion());
}
}
@Inject(at = @At("HEAD"), method = "getVersionType", cancellable = true)
public void getVersionType(CallbackInfoReturnable<String> cir){
if(!Config.getVersion().equalsIgnoreCase("")){
cir.setReturnValue(Config.getVersion());
}
}
}
4 changes: 3 additions & 1 deletion src/main/resources/assets/ghost/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,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"
}

0 comments on commit b819559

Please sign in to comment.