Skip to content
Merged
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
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build

on:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:
branches:
- 'master'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 21

- name: Get data from gradle.properties
id: mod_data
uses: christian-draeger/read-properties@1.1.1
with:
path: './gradle.properties'
properties: 'mod_id version minecraft_version'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5

- name: Build with Gradle
run: ./gradlew build

- name: Upload Fabric build
uses: actions/upload-artifact@v7
with:
name: ${{ steps.mod_data.outputs.mod_id }}-fabric-${{ steps.mod_data.outputs.minecraft_version }}-${{ steps.mod_data.outputs.version }}.jar
path: fabric/build/libs/${{ steps.mod_data.outputs.mod_id }}-fabric-${{ steps.mod_data.outputs.minecraft_version }}-${{ steps.mod_data.outputs.version }}.jar
retention-days: 90
- name: Upload NeoForge build
uses: actions/upload-artifact@v7
with:
name: ${{ steps.mod_data.outputs.mod_id }}-neoforge-${{ steps.mod_data.outputs.minecraft_version }}-${{ steps.mod_data.outputs.version }}.jar
path: neoforge/build/libs/${{ steps.mod_data.outputs.mod_id }}-neoforge-${{ steps.mod_data.outputs.minecraft_version }}-${{ steps.mod_data.outputs.version }}.jar
retention-days: 90
32 changes: 7 additions & 25 deletions LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
Copyright (c) 2026

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>



GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Expand Down Expand Up @@ -648,8 +631,8 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -662,14 +645,14 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

{project} Copyright (C) {year} {fullname}
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand All @@ -681,12 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

<https://www.gnu.org/licenses/why-not-lgpl.html>.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<img src="common/src/main/resources/icon.png" alt="DynamicView Icon" width="128" align="center">

# Dynamic View

Dynamic View is a Fabric and NeoForge mod which automatically changes the player's perspective. It has configurable
contexts including:

- Swimming
- Crawling
- Flying
- Riding
22 changes: 8 additions & 14 deletions buildSrc/src/main/groovy/multiloader-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,17 @@ repositories {
}
exclusiveContent {
forRepositories(
maven {
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org/'
},
maven {
name = "NeoForge"
url = 'https://maven.neoforged.net/releases'
}
maven {
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org/'
},
maven {
name = "NeoForge"
url = 'https://maven.neoforged.net/releases'
}
)
filter { includeGroup('org.parchmentmc.data') }
}
maven {
name = 'BlameJared'
url = 'https://maven.blamejared.com'
}
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }
}
Expand Down Expand Up @@ -99,8 +95,6 @@ processResources {
'description' : project.description,
'neoforge_version' : neoforge_version,
'neoforge_loader_version_range': neoforge_loader_version_range,
"forge_version" : forge_version,
"forge_loader_version_range" : forge_loader_version_range,
'credits' : credits,
'java_version' : java_version,
'modmenu_version' : modmenu_version,
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def loaderAttribute = Attribute.of('io.github.mcgradleconventions.loader', Strin
}
}
sourceSets.configureEach {
[it.compileClasspathConfigurationName, it.runtimeClasspathConfigurationName].each { variant->
[it.compileClasspathConfigurationName, it.runtimeClasspathConfigurationName].each { variant ->
configurations.named("$variant") {
attributes {
attribute(loaderAttribute, 'common')
Expand Down
3 changes: 1 addition & 2 deletions common/src/main/java/me/collinb/dynamicview/Constants.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package me.collinb.dynamicview;

import net.minecraft.client.Minecraft;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Constants {

public static final String MOD_ID = "dynamicview";
public static final String MOD_NAME = "DynamicView";
public static final String MOD_NAME = "Dynamic View";
public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME);
}
9 changes: 5 additions & 4 deletions common/src/main/java/me/collinb/dynamicview/DynamicView.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.collinb.dynamicview;

import me.collinb.dynamicview.camera.CameraAnimation;
import me.collinb.dynamicview.config.ModConfig;
import me.collinb.dynamicview.platform.Services;
import me.shedaniel.autoconfig.AutoConfig;
Expand All @@ -14,13 +15,13 @@ public class DynamicView {
public static void setCameraType(CameraType cameraType) {
if (!isCameraDynamic() && getMC().options.getCameraType() != cameraType) {
previousCameraType = getMC().options.getCameraType();
Constants.LOG.info("Setting previousCameraType={}", getMC().options.getCameraType());
Constants.LOG.debug("Setting previousCameraType={}", getMC().options.getCameraType());
if (cameraType != null) {
getMC().options.setCameraType(cameraType);
}
CameraAnimation.INSTANCE.currentDistance = 0.0f;
CameraAnimation.INSTANCE.targetDistance = 4.0f;
Constants.LOG.info("Setting cameraType={}", cameraType);
Constants.LOG.debug("Setting cameraType={}", cameraType);
}
}

Expand All @@ -31,7 +32,7 @@ public static void unsetCameraType() {
if (config.animationEnabled) {
CameraAnimation.INSTANCE.onAnimationComplete = () -> {
getMC().options.setCameraType(previousCameraType);
Constants.LOG.info("Resetting cameraType={}", previousCameraType);
Constants.LOG.debug("Resetting cameraType={}", previousCameraType);
previousCameraType = null;
};
} else {
Expand All @@ -43,7 +44,7 @@ public static void unsetCameraType() {
}

public static void init() {
Constants.LOG.info("Hello from Common init on {}! we are currently in a {} environment!", Services.PLATFORM.getPlatformName(), Services.PLATFORM.getEnvironmentName());
Constants.LOG.debug("Hello from Common init on {}! we are currently in a {} environment!", Services.PLATFORM.getPlatformName(), Services.PLATFORM.getEnvironmentName());
}

public static void preTick(Minecraft mc) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package me.collinb.dynamicview;
package me.collinb.dynamicview.camera;

import me.collinb.dynamicview.config.ModConfig;
import me.shedaniel.autoconfig.AutoConfig;

public class CameraAnimation {
public final class CameraAnimation {
public static CameraAnimation INSTANCE = new CameraAnimation();

private final ModConfig config;
Expand Down Expand Up @@ -38,6 +38,11 @@ public void tick() {
if (Math.abs(currentDistance - targetDistance) < 0.1f && onAnimationComplete != null) {
onAnimationComplete.run();
onAnimationComplete = null;
this.currentDistance = this.targetDistance;
}
}

public boolean isCameraAnimating() {
return this.currentDistance != this.targetDistance;
}
}

This file was deleted.

31 changes: 25 additions & 6 deletions common/src/main/java/me/collinb/dynamicview/config/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import me.shedaniel.autoconfig.ConfigHolder;
import me.shedaniel.autoconfig.annotation.Config;
import me.shedaniel.autoconfig.annotation.ConfigEntry;
import me.shedaniel.autoconfig.annotation.ConfigEntry.Gui.EnumHandler.EnumDisplayOption;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
import net.minecraft.client.CameraType;

@Config(name = Constants.MOD_ID)
public class ModConfig implements ConfigData {
Expand All @@ -15,15 +17,32 @@ public static void init() {
}

@ConfigEntry.Gui.CollapsibleObject
public EnabledContexts enabledContexts = new EnabledContexts();
public static class EnabledContexts {
public boolean swimming = true;
public boolean crawling = true;
public boolean flying = true;
public boolean riding = true;
public Contexts contexts = new Contexts();

public static class Contexts {
public boolean swimmingEnabled = true;
@ConfigEntry.Gui.EnumHandler(option = EnumDisplayOption.BUTTON)
public CameraType swimmingCamera = CameraType.THIRD_PERSON_BACK;

public boolean crawlingEnabled = true;
@ConfigEntry.Gui.EnumHandler(option = EnumDisplayOption.BUTTON)
public CameraType crawlingCamera = CameraType.FIRST_PERSON;

public boolean flyingEnabled = true;
@ConfigEntry.Gui.EnumHandler(option = EnumDisplayOption.BUTTON)
public CameraType flyingCamera = CameraType.THIRD_PERSON_BACK;

public boolean ridingEnabled = true;
@ConfigEntry.Gui.EnumHandler(option = EnumDisplayOption.BUTTON)
public CameraType ridingCamera = CameraType.THIRD_PERSON_BACK;

}

public boolean animationEnabled = true;

@ConfigEntry.BoundedDiscrete(min = 0, max = 10)
public float animationEnterEasing = 0.2f;

@ConfigEntry.BoundedDiscrete(min = 0, max = 10)
public float animationExitEasing = 0.6f;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.collinb.dynamicview.mixin;

import me.collinb.dynamicview.CameraAnimation;
import me.collinb.dynamicview.DynamicView;
import me.collinb.dynamicview.camera.CameraAnimation;
import me.collinb.dynamicview.config.ModConfig;
import me.shedaniel.autoconfig.AutoConfig;
import net.minecraft.client.Camera;
Expand All @@ -16,8 +16,11 @@
@Mixin(Camera.class)
public abstract class CameraMixin {

@Inject(method = "getMaxZoom", at = @At("HEAD"), cancellable = true)
@Inject(method = "getMaxZoom", at = @At("TAIL"), cancellable = true)
private void useSmoothZooming(float pMaxZoom, CallbackInfoReturnable<Float> cir) {
if (!CameraAnimation.INSTANCE.isCameraAnimating()) {
return;
}
ModConfig config = AutoConfig.getConfigHolder(ModConfig.class).get();
if (DynamicView.isCameraDynamic() && config.animationEnabled) {
float partial = getMC().getDeltaTracker().getGameTimeDeltaPartialTick(true);
Expand All @@ -26,7 +29,9 @@ private void useSmoothZooming(float pMaxZoom, CallbackInfoReturnable<Float> cir)
CameraAnimation.INSTANCE.previousDistance,
CameraAnimation.INSTANCE.currentDistance
);
cir.setReturnValue(smoothDistance);
if (smoothDistance <= cir.getReturnValue()) {
cir.setReturnValue(smoothDistance);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.spongepowered.asm.mixin.Shadow;

@Mixin(Entity.class)
public class EntityAccessor {
public abstract class EntityAccessor {
@Shadow
@Final
protected static EntityDataAccessor<Pose> DATA_POSE;
Expand Down
Loading