Merge pull request #10 from RudideC/master
added nofog, daycounter and speedometer
This commit is contained in:
@@ -17,7 +17,10 @@ public class ModManager {
|
|||||||
new Coordinates(),
|
new Coordinates(),
|
||||||
new Freelook(),
|
new Freelook(),
|
||||||
new Keystrokes(),
|
new Keystrokes(),
|
||||||
new Fullbright()
|
new Fullbright(),
|
||||||
|
new NoFog(),
|
||||||
|
new DayCounter(),
|
||||||
|
new Speedometer()
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package org.saturnclient.modules.mods;
|
||||||
|
|
||||||
|
import org.saturnclient.modules.HudMod;
|
||||||
|
import org.saturnclient.modules.ModDimensions;
|
||||||
|
import org.saturnclient.modules.Module;
|
||||||
|
import org.saturnclient.modules.ModuleDetails;
|
||||||
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
|
import org.saturnclient.saturnclient.config.Property;
|
||||||
|
import org.saturnclient.ui2.RenderScope;
|
||||||
|
import org.saturnclient.ui2.resources.Fonts;
|
||||||
|
|
||||||
|
public class DayCounter extends Module implements HudMod {
|
||||||
|
private static Property<Boolean> enabled = Property.bool(false);
|
||||||
|
private static ModDimensions dimensions = new ModDimensions(40, 18);
|
||||||
|
long day = 0;
|
||||||
|
|
||||||
|
public DayCounter() {
|
||||||
|
super(new ModuleDetails("DayCounter", "day")
|
||||||
|
.description("Displays the number of days that have passed")
|
||||||
|
.version("v0.1.0")
|
||||||
|
.tags("Utility"),
|
||||||
|
enabled.named("Enabled"),
|
||||||
|
dimensions.prop()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderDummy(RenderScope scope) {
|
||||||
|
renderDay(271, scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderHud(RenderScope scope) {
|
||||||
|
day = (SaturnClient.client.world.getTimeOfDay() / 24000L);
|
||||||
|
renderDay(day, scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderDay(long day, RenderScope scope) {
|
||||||
|
String text = "Day: " + day;
|
||||||
|
scope.drawText(text,
|
||||||
|
0, 0, dimensions.font.value, dimensions.fgColor.value);
|
||||||
|
dimensions.width = Fonts.getWidth(text, dimensions.font.value);
|
||||||
|
dimensions.height = 18 * text.split("\n").length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModDimensions getDimensions() {
|
||||||
|
return dimensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnabled(boolean e) {
|
||||||
|
enabled.value = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package org.saturnclient.modules.mods;
|
||||||
|
|
||||||
|
import org.saturnclient.modules.Module;
|
||||||
|
import org.saturnclient.modules.ModuleDetails;
|
||||||
|
import org.saturnclient.saturnclient.config.Property;
|
||||||
|
|
||||||
|
public class NoFog extends Module {
|
||||||
|
private static Property<Boolean> enabled = Property.bool(false);
|
||||||
|
private static Property<Boolean> liquids = Property.bool(false);
|
||||||
|
|
||||||
|
public NoFog() {
|
||||||
|
super(
|
||||||
|
new ModuleDetails("No Fog", "nofog")
|
||||||
|
.description("Stops fog from rendering")
|
||||||
|
.tags("Camera")
|
||||||
|
.version("v0.1.0"),
|
||||||
|
enabled.named("Enabled"),
|
||||||
|
liquids.named("See through liquids"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnabled(boolean e) {
|
||||||
|
enabled.value = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
// static for the mixin
|
||||||
|
public static boolean isActive() {
|
||||||
|
return enabled.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean liquids() {
|
||||||
|
return liquids.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
package org.saturnclient.modules.mods;
|
||||||
|
|
||||||
|
import org.saturnclient.modules.HudMod;
|
||||||
|
import org.saturnclient.modules.ModDimensions;
|
||||||
|
import org.saturnclient.modules.Module;
|
||||||
|
import org.saturnclient.modules.ModuleDetails;
|
||||||
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
|
import org.saturnclient.saturnclient.config.Property;
|
||||||
|
import org.saturnclient.ui2.RenderScope;
|
||||||
|
import org.saturnclient.ui2.resources.Fonts;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
|
||||||
|
public class Speedometer extends Module implements HudMod {
|
||||||
|
private static Property<Boolean> enabled = Property.bool(false);
|
||||||
|
private static Property<Integer> axis = Property.select(1, "Absolute", "X axis", "Y axis");
|
||||||
|
private static Property<Integer> unitText = Property.select(0, "None", "Blocks/s", "blocks/s", "b/s");
|
||||||
|
private static Property<Boolean> speedText = Property.bool(true);
|
||||||
|
private static ModDimensions dimensions = new ModDimensions(40, 18);
|
||||||
|
double speed = 0.;
|
||||||
|
Vec3d velocity;
|
||||||
|
double y = 0.;
|
||||||
|
|
||||||
|
public Speedometer() {
|
||||||
|
super(new ModuleDetails("Speedometer", "speed")
|
||||||
|
.description("Displays your current speed")
|
||||||
|
.version("v0.1.0")
|
||||||
|
.tags("Utility"),
|
||||||
|
enabled.named("Enabled"),
|
||||||
|
axis.named("Speed type"),
|
||||||
|
unitText.named("Unit text"),
|
||||||
|
speedText.named("Show speed text"),
|
||||||
|
dimensions.prop()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderDummy(RenderScope scope) {
|
||||||
|
renderSpeed(2.71, scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderHud(RenderScope scope) {
|
||||||
|
Entity vehicle = SaturnClient.client.player.getVehicle();
|
||||||
|
Entity player = SaturnClient.client.player;
|
||||||
|
|
||||||
|
if (vehicle == null) {
|
||||||
|
velocity = player.getVelocity();
|
||||||
|
y = player.isOnGround() ? 0. : velocity.y;
|
||||||
|
} else {
|
||||||
|
velocity = vehicle.getVelocity();
|
||||||
|
y = vehicle.isOnGround() ? 0. : velocity.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (axis.value) {
|
||||||
|
case 0: // Absolute
|
||||||
|
speed = (Math.sqrt(Math.pow(velocity.x, 2) + Math.pow(y, 2) + Math.pow(velocity.z, 2)));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: // x axis
|
||||||
|
speed = (Math.sqrt(Math.pow(velocity.x, 2) + Math.pow(velocity.z, 2)));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: // y axis
|
||||||
|
speed = (Math.abs(y));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
renderSpeed(speed * 20, scope); // blocks/tick to blocks/s
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderSpeed(double speed, RenderScope scope) {
|
||||||
|
String f = String.format("%.2f ", speed);
|
||||||
|
|
||||||
|
switch (unitText.value) {
|
||||||
|
case 1:
|
||||||
|
f += "Blocks/s";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
f += "blocks/s";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
f += "b/s";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
String text = f;
|
||||||
|
|
||||||
|
if (speedText.value) {
|
||||||
|
text = "Speed: " + text;
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.drawText(text,
|
||||||
|
0, 0, dimensions.font.value, dimensions.fgColor.value);
|
||||||
|
dimensions.width = Fonts.getWidth(text, dimensions.font.value);
|
||||||
|
dimensions.height = 18 * text.split("\n").length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModDimensions getDimensions() {
|
||||||
|
return dimensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnabled(boolean e) {
|
||||||
|
enabled.value = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.saturnclient.modules.mods.mixins;
|
||||||
|
|
||||||
|
import net.minecraft.client.render.BackgroundRenderer;
|
||||||
|
|
||||||
|
import org.saturnclient.modules.mods.NoFog;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(BackgroundRenderer.class)
|
||||||
|
public class BackgroundRendererMixin {
|
||||||
|
|
||||||
|
@ModifyVariable(method = "applyFog", at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||||
|
private static float modifyFogStart(float viewDistance) {
|
||||||
|
if (NoFog.isActive()) {
|
||||||
|
return Float.MAX_VALUE; // this could be customised
|
||||||
|
}
|
||||||
|
return viewDistance;
|
||||||
|
}
|
||||||
|
// liquids
|
||||||
|
@Redirect(
|
||||||
|
method = "applyFog",
|
||||||
|
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isSpectator()Z")
|
||||||
|
)
|
||||||
|
private static boolean redirectIsSpectator(Entity entity) {
|
||||||
|
if (NoFog.isActive() && NoFog.liquids()) {
|
||||||
|
return true; // pretend to be spectator
|
||||||
|
}
|
||||||
|
return entity.isSpectator();
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 294 B |
Binary file not shown.
|
After Width: | Height: | Size: 282 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
@@ -7,7 +7,8 @@
|
|||||||
"CameraMixin",
|
"CameraMixin",
|
||||||
"EntityMixin",
|
"EntityMixin",
|
||||||
"RenderMixin",
|
"RenderMixin",
|
||||||
"LightmapTextureManagerMixin"
|
"LightmapTextureManagerMixin",
|
||||||
|
"BackgroundRendererMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|||||||
Reference in New Issue
Block a user