Skip to content

Commit

Permalink
Fixed some ui issues
Browse files Browse the repository at this point in the history
  • Loading branch information
xTracr committed May 2, 2024
1 parent 8543d13 commit a56182a
Show file tree
Hide file tree
Showing 26 changed files with 113 additions and 387 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
}

architectury {
Expand Down
237 changes: 0 additions & 237 deletions changelog.md

This file was deleted.

25 changes: 10 additions & 15 deletions common/src/main/java/com/xtracr/realcamera/KeyBindings.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.xtracr.realcamera;

import com.xtracr.realcamera.config.ConfigFile;
import com.xtracr.realcamera.config.ModConfig;
import com.xtracr.realcamera.gui.ModelViewScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
Expand All @@ -19,23 +18,19 @@ public final class KeyBindings {
static {
createKeyBinding("modelViewGui", client -> client.setScreen(new ModelViewScreen()));
createKeyBinding("togglePerspective", GLFW.GLFW_KEY_F6, client -> {
boolean enabled = config().enabled();
boolean enabled = ConfigFile.config().enabled();
ConfigFile.load();
config().setEnabled(!enabled);
ConfigFile.config().setEnabled(!enabled);
RealCameraCore.readyToSendMessage();
});
createKeyBinding("toggleAdjustMode", client -> config().cycleAdjustMode());
createKeyBinding("toggleCameraMode", client -> config().setClassic(!config().isClassic()));
createKeyBinding("adjustFRONT", client -> config().adjustOffsetX(1));
createKeyBinding("adjustBACK", client -> config().adjustOffsetX(-1));
createKeyBinding("adjustUP", client -> config().adjustOffsetY(1));
createKeyBinding("adjustDOWN", client -> config().adjustOffsetY(-1));
createKeyBinding("adjustLEFT", client -> config().adjustOffsetZ(1));
createKeyBinding("adjustRIGHT", client -> config().adjustOffsetZ(-1));
}

private static ModConfig config() {
return ConfigFile.modConfig;
createKeyBinding("toggleAdjustMode", client -> ConfigFile.config().cycleAdjustMode());
createKeyBinding("toggleCameraMode", client -> ConfigFile.config().setClassic(!ConfigFile.config().isClassic()));
createKeyBinding("adjustFRONT", client -> ConfigFile.config().adjustOffsetX(1));
createKeyBinding("adjustBACK", client -> ConfigFile.config().adjustOffsetX(-1));
createKeyBinding("adjustUP", client -> ConfigFile.config().adjustOffsetY(1));
createKeyBinding("adjustDOWN", client -> ConfigFile.config().adjustOffsetY(-1));
createKeyBinding("adjustLEFT", client -> ConfigFile.config().adjustOffsetZ(1));
createKeyBinding("adjustRIGHT", client -> ConfigFile.config().adjustOffsetZ(-1));
}

private static void createKeyBinding(String id, Consumer<MinecraftClient> whenPressed) {
Expand Down
29 changes: 12 additions & 17 deletions common/src/main/java/com/xtracr/realcamera/RealCameraCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.xtracr.realcamera.compat.DisableHelper;
import com.xtracr.realcamera.config.BindingTarget;
import com.xtracr.realcamera.config.ConfigFile;
import com.xtracr.realcamera.config.ModConfig;
import com.xtracr.realcamera.util.MathUtil;
import com.xtracr.realcamera.util.VertexRecorder;
import net.minecraft.client.MinecraftClient;
Expand All @@ -18,6 +17,7 @@
import net.minecraft.util.math.Vec3d;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.joml.Vector3f;

import java.util.function.BiFunction;

Expand All @@ -39,7 +39,7 @@ public static float getYaw(float f) {
}

public static float getRoll(float f) {
if (config().isClassic()) return f + config().getClassicRoll();
if (ConfigFile.config().isClassic()) return f + ConfigFile.config().getClassicRoll();
if (currentTarget.bindRotation) return roll;
return f;
}
Expand All @@ -58,20 +58,20 @@ public static void setCameraPos(Vec3d vec3d) {

public static void init(MinecraftClient client) {
Entity entity = client.getCameraEntity();
active = config().enabled() && client.options.getPerspective().isFirstPerson() && client.gameRenderer.getCamera() != null && entity != null && !DisableHelper.isDisabled("mainFeature", entity);
rendering = active && config().renderModel() && !DisableHelper.isDisabled("renderModel", entity);
active = ConfigFile.config().enabled() && client.options.getPerspective().isFirstPerson() && client.gameRenderer.getCamera() != null && entity != null && !DisableHelper.isDisabled("mainFeature", entity);
rendering = active && ConfigFile.config().renderModel() && !DisableHelper.isDisabled("renderModel", entity);
}

public static void readyToSendMessage() {
readyToSendMessage = config().enabled();
readyToSendMessage = ConfigFile.config().enabled();
}

public static boolean isActive() {
return active;
}

public static boolean isRendering() {
return rendering;
return active && rendering;
}

public static void updateModel(MinecraftClient client, float tickDelta) {
Expand Down Expand Up @@ -114,13 +114,12 @@ public static void renderCameraEntity(VertexConsumerProvider vertexConsumers) {
public static void computeCamera() {
currentTarget = new BindingTarget();
Matrix3f normal = new Matrix3f();
for (BindingTarget target : config().getTargetList()) {
try {
pos = recorder.getTargetPosAndRot(target, normal).add(offset);
currentTarget = target;
break;
} catch (Exception ignored) {
}
for (BindingTarget target : ConfigFile.config().getTargetList()) {
Vector3f position = new Vector3f();
if (recorder.getTargetPosAndRot(target, normal, position) == null || !(Math.abs(normal.determinant() - 1) <= 0.01f)) continue;
pos = new Vec3d(position).add(offset);
currentTarget = target;
break;
}
if (currentTarget.isEmpty()) {
Entity player = MinecraftClient.getInstance().player;
Expand All @@ -135,8 +134,4 @@ public static void computeCamera() {
yaw = (float) -eulerAngle.getY();
roll = (float) eulerAngle.getZ();
}

private static ModConfig config() {
return ConfigFile.modConfig;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.xtracr.realcamera.compat;

import com.xtracr.realcamera.config.ConfigFile;
import com.xtracr.realcamera.config.ModConfig;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
Expand All @@ -17,8 +16,8 @@ public final class DisableHelper {
public static void initialize() {
registerOr("mainFeature", LivingEntity::isSleeping);
registerOr("renderModel", entity -> entity instanceof PlayerEntity player && player.isUsingSpyglass());
registerOr("renderModel", entity -> config().getDisableRenderItems().contains(Registries.ITEM.getId(entity.getMainHandStack().getItem()).toString()));
registerOr("renderModel", entity -> config().getDisableRenderItems().contains(Registries.ITEM.getId(entity.getOffHandStack().getItem()).toString()));
registerOr("renderModel", entity -> ConfigFile.config().getDisableRenderItems().contains(Registries.ITEM.getId(entity.getMainHandStack().getItem()).toString()));
registerOr("renderModel", entity -> ConfigFile.config().getDisableRenderItems().contains(Registries.ITEM.getId(entity.getOffHandStack().getItem()).toString()));
}

public static void registerOr(String type, Predicate<LivingEntity> predicate) {
Expand All @@ -27,11 +26,7 @@ public static void registerOr(String type, Predicate<LivingEntity> predicate) {

public static boolean isDisabled(String type, Entity cameraEntity) {
Predicate<LivingEntity> predicate = predicates.get(type);
if (config().isClassic() || predicate == null) return false;
if (ConfigFile.config().isClassic() || predicate == null) return false;
return cameraEntity instanceof LivingEntity entity && predicate.test(entity);
}

private static ModConfig config() {
return ConfigFile.modConfig;
}
}
Loading

0 comments on commit a56182a

Please sign in to comment.