Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: 25
java-version: 21

- name: Make Gradle Wrapper Executable
if: ${{ runner.os != 'Windows' }}
Expand All @@ -43,4 +43,4 @@ jobs:
name: Artifacts
path: |
fabric/build/libs/*
neoforge/build/libs/*
neoforge/build/libs/*
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: 25
java-version: 21

- name: Make Gradle Wrapper Executable
if: ${{ runner.os != 'Windows' }}
Expand Down
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ allprojects {
repositories {
mavenCentral()
maven("https://maven.shedaniel.me/")
maven("https://maven.terraformersmc.com/releases/")
maven("https://maven.terraformersmc.com/releases/") {
content {
includeGroup("com.terraformersmc")
}
}
maven("https://maven.fabricmc.net/")
maven("https://maven.neoforged.net/releases/")
}
Expand Down
10 changes: 6 additions & 4 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("net.fabricmc.fabric-loom")
id("net.fabricmc.fabric-loom-remap")
id("maven-publish")
}

Expand Down Expand Up @@ -28,13 +28,15 @@ tasks.withType<JavaCompile> {

dependencies {
minecraft("com.mojang:minecraft:$minecraftVersion")
mappings(loom.officialMojangMappings())

compileOnly("io.github.llamalad7:mixinextras-common:0.5.3")
annotationProcessor("io.github.llamalad7:mixinextras-common:0.5.3")
// We depend on Fabric Loader here to use mixin and the Fabric @Environment annotations,
// compileOnly so it doesn't leak into neoforge's runtime classpath
compileOnly("net.fabricmc:fabric-loader:$fabricLoaderVersion")
modCompileOnly("net.fabricmc:fabric-loader:$fabricLoaderVersion")

// Cloth Config
compileOnly("me.shedaniel.cloth:cloth-config:$clothConfigVersion") {
modCompileOnly("me.shedaniel.cloth:cloth-config-fabric:$clothConfigVersion") {
exclude(group = "net.fabricmc.fabric-api")
}
}
Expand Down
24 changes: 12 additions & 12 deletions common/src/main/java/com/xtracr/realcamera/KeyMappings.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ public final class KeyMappings {

static {
MODEL_VIEW_SCREEN = createKeyMapping("modelViewScreen", client -> client.setScreen(new ModelViewScreen()));
createKeyMapping("togglePerspective", InputConstants.KEY_F6, _ -> {
createKeyMapping("togglePerspective", InputConstants.KEY_F6, ignoredClient -> {
boolean enabled = ConfigFile.config().enabled;
ConfigFile.load();
ConfigFile.config().enabled = !enabled;
RealCameraCore.reset();
});
createKeyMapping("toggleAdjustMode", _ -> ConfigFile.config().cycleAdjustMode());
createKeyMapping("toggleCameraMode", _ -> ConfigFile.config().isClassic = !ConfigFile.config().isClassic);
createKeyMapping("adjustUP", _ -> ConfigFile.config().adjustOffsetY(1));
createKeyMapping("adjustDOWN", _ -> ConfigFile.config().adjustOffsetY(-1));
createKeyMapping("adjustLEFT", _ -> ConfigFile.config().adjustOffsetZ(1));
createKeyMapping("adjustRIGHT", _ -> ConfigFile.config().adjustOffsetZ(-1));
createKeyMapping("adjustFRONT", _ -> ConfigFile.config().adjustOffsetX(1));
createKeyMapping("adjustBACK", _ -> ConfigFile.config().adjustOffsetX(-1));
createKeyMapping("activeConfigIndexNEXT", _ -> ConfigFile.config().binding.activeConfigIndex += 1);
createKeyMapping("activeConfigIndexPREV", _ -> ConfigFile.config().binding.activeConfigIndex -= 1);
createKeyMapping("activeConfigIndexRESET", _ -> ConfigFile.config().binding.activeConfigIndex = 0);
createKeyMapping("toggleAdjustMode", ignoredClient -> ConfigFile.config().cycleAdjustMode());
createKeyMapping("toggleCameraMode", ignoredClient -> ConfigFile.config().isClassic = !ConfigFile.config().isClassic);
createKeyMapping("adjustUP", ignoredClient -> ConfigFile.config().adjustOffsetY(1));
createKeyMapping("adjustDOWN", ignoredClient -> ConfigFile.config().adjustOffsetY(-1));
createKeyMapping("adjustLEFT", ignoredClient -> ConfigFile.config().adjustOffsetZ(1));
createKeyMapping("adjustRIGHT", ignoredClient -> ConfigFile.config().adjustOffsetZ(-1));
createKeyMapping("adjustFRONT", ignoredClient -> ConfigFile.config().adjustOffsetX(1));
createKeyMapping("adjustBACK", ignoredClient -> ConfigFile.config().adjustOffsetX(-1));
createKeyMapping("activeConfigIndexNEXT", ignoredClient -> ConfigFile.config().binding.activeConfigIndex += 1);
createKeyMapping("activeConfigIndexPREV", ignoredClient -> ConfigFile.config().binding.activeConfigIndex -= 1);
createKeyMapping("activeConfigIndexRESET", ignoredClient -> ConfigFile.config().binding.activeConfigIndex = 0);
}

private static KeyMapping createKeyMapping(String id, Consumer<Minecraft> whenPressed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.state.level.CameraRenderState;
import net.minecraft.client.renderer.state.CameraRenderState;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -89,7 +89,7 @@ public static void computeCamera(Minecraft client, float partialTicks) {
Player player = client.player;
int retentionFrames = ConfigFile.config().binding.bindResultRetentionFrames;
if (!ConfigFile.config().binding.hideFailureMessage && failureFrames == retentionFrames + 1 && player != null) {
player.sendSystemMessage(LocUtil.MESSAGE("bindingFailed", LocUtil.MOD_NAME(), LocUtil.MODEL_VIEW_TITLE(), KeyMappings.MODEL_VIEW_SCREEN.getTranslatedKeyMessage()));
player.displayClientMessage(LocUtil.MESSAGE("bindingFailed", LocUtil.MOD_NAME(), LocUtil.MODEL_VIEW_TITLE(), KeyMappings.MODEL_VIEW_SCREEN.getTranslatedKeyMessage()), false);
}
if (!lastResult.available() || failureFrames > retentionFrames) {
lastResult = BindResult.EMPTY;
Expand Down Expand Up @@ -118,7 +118,7 @@ public static void renderCameraEntity(Minecraft client, float partialTicks, Subm
vertexCatcher.forEachBuffer(builtBuffer -> {
DisableConfig[] disableConfigs = currentTarget().filteredDisableConfigs(config -> builtBuffer.textureId().contains(config.textureId()));
for (DisableConfig config : disableConfigs) if (config.disableAll()) return;
submitNodeCollector.submitCustomGeometry(poseStack, builtBuffer.renderType(), (_, buffer) -> {
submitNodeCollector.submitCustomGeometry(poseStack, builtBuffer.renderType(), (ignoredPose, buffer) -> {
if (!builtBuffer.renderType().canConsolidateConsecutiveGeometry()) {
for (VertexData vertex : builtBuffer.vertexBuffer()) vertex.render(buffer);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void initialize(PlatformHelper platformHelper) {
if (isModLoaded("freecam")) try {
Class<?> FC_Freecam = Class.forName("net.xolt.freecam.Freecam");
Method FC_Freecam_isEnabled = FC_Freecam.getDeclaredMethod("isEnabled");
DisableHelper.MAIN_FEATURE.registerOr(_ -> {
DisableHelper.MAIN_FEATURE.registerOr(ignoredPlayer -> {
try {
return (boolean) FC_Freecam_isEnabled.invoke(null);
} catch (Exception ignored) {
Expand All @@ -47,15 +47,15 @@ public static void initialize(PlatformHelper platformHelper) {
Class<?> SBW_ClientEventHandler = Class.forName("com.atsuishio.superbwarfare.event.ClientEventHandler");
SBW_ClientEventHandler_zoomTime = SBW_ClientEventHandler.getDeclaredField("zoomTime");
SBW_VehicleEntity = Class.forName("com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity");
DisableHelper.MAIN_FEATURE.registerOrInBinding(_ -> CompatibilityHelper.SBW_gunsIsZooming());
DisableHelper.MAIN_FEATURE.registerOrInBinding(ignoredPlayer -> CompatibilityHelper.SBW_gunsIsZooming());
DisableHelper.MAIN_FEATURE.registerOrInBinding(CompatibilityHelper::SBW_isDrivingVehicle);
} catch (Exception e) {
RealCamera.LOGGER.warn("Compatibility with SuperbWarfare is outdated: [{}] {}", e.getClass().getName(), e.getMessage());
}
if (isModLoaded("entity_model_features")) try {
Class<?> EMF_EMFAnimationApi = Class.forName("traben.entity_model_features.EMFAnimationApi");
if ((int) EMF_EMFAnimationApi.getMethod("getApiVersion").invoke(null) >= 9) {
Function<Object, Boolean> function = _ -> isRenderInScreen;
Function<Object, Boolean> function = ignoredContext -> isRenderInScreen;
Method EMF_registerPauseCondition = EMF_EMFAnimationApi.getMethod("registerPauseCondition", Function.class);
EMF_registerPauseCondition.invoke(null, function);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
public final class DisableHelper {
public static final Entry MAIN_FEATURE, RENDER_MODEL, RENDER_HANDS;
private static final Pattern MULTI_STAR = Pattern.compile("\\*+");
private static final Predicate<Player> FALSE = _ -> false;
private static final Predicate<Player> FALSE = ignoredPlayer -> false;
private static final Map<String, Entry> ENTRIES = new HashMap<>();
private static int exitTick = 0;

static {
MAIN_FEATURE = new Entry("mainFeature", player -> player.isSleeping() || player.isSpectator());
RENDER_MODEL = new Entry("renderModel", FALSE, Player::isScoping);
RENDER_HANDS = new Entry("renderHands", _ -> RealCameraCore.isRendering());
RENDER_HANDS = new Entry("renderHands", ignoredPlayer -> RealCameraCore.isRendering());
MAIN_FEATURE.registerOrInBinding(player -> ConfigFile.config().binding.disableWhenSneaking && player.isCrouching());
MAIN_FEATURE.registerOrInClassic(player -> ConfigFile.config().classic.disableWhenSneaking && player.isCrouching());
MAIN_FEATURE.registerOrInBinding(player -> ConfigFile.config().binding.disableWhenSwimming && checkCondition(player, player.isVisuallySwimming(), ConfigFile.config().binding.exitTick));
Expand Down Expand Up @@ -139,4 +139,4 @@ public boolean disabled(Entity cameraEntity) {
return ConfigFile.config().isClassic ? predicateInClassic.test(player) : predicateInBinding.test(player);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.entity.state.EntityRenderState;
import net.minecraft.client.renderer.state.level.CameraRenderState;
import net.minecraft.client.renderer.state.CameraRenderState;
import net.minecraft.world.phys.Vec3;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
Expand Down
28 changes: 14 additions & 14 deletions common/src/main/java/com/xtracr/realcamera/gui/GUIHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.xtracr.realcamera.renderer.state.BuiltModelRecord;
import com.xtracr.realcamera.renderer.state.VertexData;
import com.xtracr.realcamera.renderer.state.gui.*;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.navigation.ScreenRectangle;
import net.minecraft.client.gui.render.TextureSetup;
import net.minecraft.client.renderer.RenderPipelines;
Expand All @@ -23,54 +23,54 @@ public static ScreenRectangle getBounds(int x0, int y0, int x1, int y1, Matrix3x
return scissorArea != null ? scissorArea.intersection(scissorArea2) : scissorArea2;
}

public static void enableScissor(GuiGraphicsExtractor graphics, ScreenRectangle rectangle) {
public static void enableScissor(GuiGraphics graphics, ScreenRectangle rectangle) {
graphics.enableScissor(rectangle.left(), rectangle.top(), rectangle.right(), rectangle.bottom());
}

public static void fill(GuiGraphicsExtractor graphics, float x0, float y0, float x1, float y1, int argb) {
public static void fill(GuiGraphics graphics, float x0, float y0, float x1, float y1, int argb) {
fill(graphics, x0, y0, x1, y1, 0, argb);
}

public static void fill(GuiGraphicsExtractor graphics, float x0, float y0, float x1, float y1, float z, int argb) {
((GuiGraphicsExtractorAccessor) graphics).getGuiRenderState().addGuiElement(new ColoredFloatRectangleRenderState(
public static void fill(GuiGraphics graphics, float x0, float y0, float x1, float y1, float z, int argb) {
((GuiGraphicsExtractorAccessor) graphics).getGuiRenderState().submitGuiElement(new ColoredFloatRectangleRenderState(
RenderPipelines.GUI, TextureSetup.noTexture(), new Matrix3x2f(graphics.pose()),
x0, y0, x1, y1, z, argb, ((GuiGraphicsExtractorAccessor) graphics).getScissorStack().peek()));
}

public static void outline(GuiGraphicsExtractor graphics, float x, float y, float width, float height, int argb) {
public static void outline(GuiGraphics graphics, float x, float y, float width, float height, int argb) {
fill(graphics, x, y, x + width, y + 1, argb);
fill(graphics, x, y + height - 1, x + width, y + height, argb);
fill(graphics, x, y + 1, x + 1, y + height - 1, argb);
fill(graphics, x + width - 1, y + 1, x + width, y + height - 1, argb);
}

public static void triangleOrQuad(GuiGraphicsExtractor graphics, VertexData[] vertices, float z, int argb) {
public static void triangleOrQuad(GuiGraphics graphics, VertexData[] vertices, float z, int argb) {
if (vertices.length < 3) return;
float x0 = vertices[0].x(), y0 = vertices[0].y();
float x1 = vertices[1].x(), y1 = vertices[1].y();
float x2 = vertices[2].x(), y2 = vertices[2].y();
boolean isQuad = vertices.length > 3;
float x3 = isQuad ? vertices[3].x() : x2, y3 = isQuad ? vertices[3].y() : y2;
((GuiGraphicsExtractorAccessor) graphics).getGuiRenderState().addGuiElement(new ColoredFloatQuadRenderState(
((GuiGraphicsExtractorAccessor) graphics).getGuiRenderState().submitGuiElement(new ColoredFloatQuadRenderState(
RenderPipelines.GUI, TextureSetup.noTexture(), new Matrix3x2f(graphics.pose()),
x0, y0, z, x1, y1, z, x2, y2, z, x3, y3, z, argb, ((GuiGraphicsExtractorAccessor) graphics).getScissorStack().peek()));
}

public static void vector(GuiGraphicsExtractor graphics, Vec3 start, Vec3 vector, float z, int argb) {
((GuiGraphicsExtractorAccessor) graphics).getGuiRenderState().addGuiElement(new ColoredFloatLineRenderState(
public static void vector(GuiGraphics graphics, Vec3 start, Vec3 vector, float z, int argb) {
((GuiGraphicsExtractorAccessor) graphics).getGuiRenderState().submitGuiElement(new ColoredFloatLineRenderState(
RenderPipelines.GUI, TextureSetup.noTexture(), new Matrix3x2f(graphics.pose()),
(float) start.x(), (float) start.y(), z,
(float) vector.x(), (float) vector.y(), 0, argb, ((GuiGraphicsExtractorAccessor) graphics).getScissorStack().peek()));
}

public static void culledModels(GuiGraphicsExtractor graphics, List<BuiltModelRecord> records, float scale, Matrix4f transform, int x0, int y0, int x1, int y1) {
((GuiGraphicsExtractorAccessor) graphics).getGuiRenderState().addPicturesInPictureState(
public static void culledModels(GuiGraphics graphics, List<BuiltModelRecord> records, float scale, Matrix4f transform, int x0, int y0, int x1, int y1) {
((GuiGraphicsExtractorAccessor) graphics).getGuiRenderState().submitPicturesInPictureState(
new GuiCulledModelsRenderState(records, transform, x0, y0, x1, y1, scale, ((GuiGraphicsExtractorAccessor) graphics).getScissorStack().peek())
);
}

public static void flattenedModels(GuiGraphicsExtractor graphics, List<BuiltModelRecord> records, Vector3f translation, int x0, int y0, int x1, int y1, float scale) {
((GuiGraphicsExtractorAccessor) graphics).getGuiRenderState().addPicturesInPictureState(
public static void flattenedModels(GuiGraphics graphics, List<BuiltModelRecord> records, Vector3f translation, int x0, int y0, int x1, int y1, float scale) {
((GuiGraphicsExtractorAccessor) graphics).getGuiRenderState().submitPicturesInPictureState(
new GuiFlattenedModelsRenderState(records, translation, x0, y0, x1, y1, scale, ((GuiGraphicsExtractorAccessor) graphics).getScissorStack().peek())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import com.xtracr.realcamera.renderer.state.VertexData;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.rendertype.RenderType;
import net.minecraft.client.renderer.rendertype.RenderTypes;
import net.minecraft.client.renderer.state.level.CameraRenderState;
import net.minecraft.client.renderer.state.CameraRenderState;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
import org.joml.Matrix3f;
Expand Down Expand Up @@ -192,7 +192,7 @@ public void computeFocusedPolyhedron() {
focusedPolyhedron.add(focused);
}

public void drawCameraDirections(GuiGraphicsExtractor graphics, double modelScale) {
public void drawCameraDirections(GuiGraphics graphics, double modelScale) {
if (targetPrimitives[0] == null || targetPrimitives[1] == null || targetPrimitives[2] == null) return;
Vec3 start = bindResult.getPosition();
Matrix3f normal = bindResult.getRotation();
Expand All @@ -202,14 +202,14 @@ public void drawCameraDirections(GuiGraphicsExtractor graphics, double modelScal
GUIHelper.vector(graphics, start, new Vec3(normal.m00(), normal.m01(), normal.m02()).scale(modelScale / 6), Z_LINE, LEFT_ARGB);
}

public void drawBindTarget(GuiGraphicsExtractor graphics, BindTarget target, double modelScale) {
public void drawBindTarget(GuiGraphics graphics, BindTarget target, double modelScale) {
TargetConfig config = target.targetConfig();
if (targetPrimitives[0] != null) GUIHelper.triangleOrQuad(graphics, targetPrimitives[0], Z_QUAD, PLANE_ARGB);
if (targetPrimitives[1] != null) GUIHelper.vector(graphics, VertexData.position(targetPrimitives[1], config.forwardU(), config.forwardV()), VertexData.normal(targetPrimitives[1]).scale(-modelScale / 2), Z_LINE, FORWARD_ARGB);
if (targetPrimitives[2] != null) GUIHelper.vector(graphics, VertexData.position(targetPrimitives[2], config.upwardU(), config.upwardV()), VertexData.normal(targetPrimitives[2]).scale(-modelScale / 2), Z_LINE, UPWARD_ARGB);
}

public void drawFocusedInModelArea(GuiGraphicsExtractor graphics) {
public void drawFocusedInModelArea(GuiGraphics graphics) {
if (focusedPolyhedron.isEmpty() || focusedRecord == null) return;
VertexData[] focused = focusedPolyhedron.getFirst();
VertexData[] reversed = new VertexData[focused.length];
Expand All @@ -218,7 +218,7 @@ public void drawFocusedInModelArea(GuiGraphicsExtractor graphics) {
for (VertexData[] primitive : focusedPolyhedron) GUIHelper.triangleOrQuad(graphics, primitive, Z_QUAD, FOCUSED_ARGB);
}

public void drawFocusedInTextureArea(GuiGraphicsExtractor graphics, Matrix4f texturePose) {
public void drawFocusedInTextureArea(GuiGraphics graphics, Matrix4f texturePose) {
int length = 0;
VertexData[] transformed = new VertexData[0], reversed = new VertexData[0];
Vector3f position = new Vector3f();
Expand Down
Loading