Greatly improved Vein Miner performance
This commit is contained in:
@ -7,24 +7,37 @@ import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.text.Text;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import static wtf.hak.survivalfabric.config.client.ClientConfigManager.getConfig;
|
||||
|
||||
public class Zoom {
|
||||
|
||||
private static final KeyBinding ZOOM_BIND = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.survivalfabric.zoom", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_C, "category.survivalfabric.survivalfabric"));
|
||||
private static final float INITIAL_ZOOM = 20f;
|
||||
|
||||
private static boolean SHOULD_ZOOM = false;
|
||||
private static float ZOOM_STEP_VALUE = 2.5f;
|
||||
private static int ZOOM_STEP = 0;
|
||||
|
||||
@Unique
|
||||
private static boolean initialSmoothZoom;
|
||||
|
||||
public static void register() {
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
if (ZOOM_BIND.isPressed())
|
||||
|
||||
if (ZOOM_BIND.isPressed() && !SHOULD_ZOOM) {
|
||||
if(getConfig().smoothCamera) {
|
||||
initialSmoothZoom = MinecraftClient.getInstance().options.smoothCameraEnabled;
|
||||
MinecraftClient.getInstance().options.smoothCameraEnabled = true;
|
||||
}
|
||||
SHOULD_ZOOM = true;
|
||||
else {
|
||||
} else if (!ZOOM_BIND.isPressed() && SHOULD_ZOOM) {
|
||||
SHOULD_ZOOM = false;
|
||||
ZOOM_STEP = 0;
|
||||
if(getConfig().smoothCamera) {
|
||||
MinecraftClient.getInstance().options.smoothCameraEnabled = initialSmoothZoom;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -33,7 +46,7 @@ public class Zoom {
|
||||
}
|
||||
|
||||
public static float getZoomFov() {
|
||||
return INITIAL_ZOOM - -ZOOM_STEP * ZOOM_STEP_VALUE;
|
||||
return getConfig().initialZoom - -ZOOM_STEP * getConfig().zoomStep;
|
||||
}
|
||||
|
||||
public static void modifyStep(int step) {
|
||||
@ -42,9 +55,9 @@ public class Zoom {
|
||||
// Clamp the zoom level so the FOV stays within [1, 110]
|
||||
float zoomFov = getZoomFov();
|
||||
if (zoomFov < 1) {
|
||||
ZOOM_STEP = Math.round((1 - INITIAL_ZOOM) / ZOOM_STEP_VALUE) + 1;
|
||||
ZOOM_STEP = Math.round((1 - getConfig().initialZoom) / getConfig().zoomStep) + 1;
|
||||
} else if (zoomFov > 110) {
|
||||
ZOOM_STEP = Math.round((110 - INITIAL_ZOOM) / ZOOM_STEP_VALUE);
|
||||
ZOOM_STEP = Math.round((110 - getConfig().initialZoom) / getConfig().zoomStep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user