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
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
* declared one decides the perspective.
*/
public enum CameraContext {
AIMING,

Check warning on line 9 in common/src/main/java/me/collinb/dynamicview/camera/CameraContext.java

View workflow job for this annotation

GitHub Actions / build

no comment
LUNGING,
CLIMBING,

Check warning on line 11 in common/src/main/java/me/collinb/dynamicview/camera/CameraContext.java

View workflow job for this annotation

GitHub Actions / build

no comment
RIDING,
FLYING,

Check warning on line 13 in common/src/main/java/me/collinb/dynamicview/camera/CameraContext.java

View workflow job for this annotation

GitHub Actions / build

no comment
SWIMMING,
CRAWLING
CRAWLING,

Check warning on line 15 in common/src/main/java/me/collinb/dynamicview/camera/CameraContext.java

View workflow job for this annotation

GitHub Actions / build

no comment
FISHING,

Check warning on line 16 in common/src/main/java/me/collinb/dynamicview/camera/CameraContext.java

View workflow job for this annotation

GitHub Actions / build

no comment
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ public static class Contexts {
@ConfigEntry.Gui.EnumHandler(option = EnumDisplayOption.BUTTON)
public CameraType ridingCamera = CameraType.THIRD_PERSON_BACK;

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

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

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

public boolean lungingEnabled = false;
@ConfigEntry.Gui.EnumHandler(option = EnumDisplayOption.BUTTON)
public CameraType lungingCamera = CameraType.THIRD_PERSON_BACK;
}

public boolean animationEnabled = true;
Expand All @@ -61,6 +76,6 @@ public void validatePostLoad() {
}

private static int clampSpeed(int speed) {
return Math.max(1, Math.min(100, speed));
return Math.clamp(speed, 1, 100);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public abstract class CameraMixin {

@Inject(method = "getMaxZoom", at = @At("TAIL"), cancellable = true)
private void useSmoothZooming(float pMaxZoom, CallbackInfoReturnable<Float> cir) {
private void useSmoothZooming(float cameraDist, CallbackInfoReturnable<Float> cir) {
CameraAnimation animation = CameraAnimation.INSTANCE;
if (!animation.isAnimating()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import me.collinb.dynamicview.config.ModConfig;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.item.BowItem;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -13,15 +14,12 @@
@Mixin(LocalPlayer.class)
public abstract class LocalPlayerMixin {

// Polling once per tick (instead of hooking mount/dismount and pose data
// updates) catches every way a context can start or stop: failed mount
// attempts, leaving water while still in the swimming pose, config changes
// mid-context, respawning, and so on.
@Inject(method = "tick", at = @At("TAIL"))
private void dynamicView$updateContexts(CallbackInfo ci) {
LocalPlayer player = (LocalPlayer) (Object) this;
ModConfig.Contexts contexts = ModConfig.get().contexts;
boolean swimmingPose = player.getPose() == Pose.SWIMMING;
boolean drawingBow = player.isUsingItem() && player.getUseItem().getItem() instanceof BowItem;

DynamicView.setContextActive(CameraContext.RIDING,
contexts.ridingEnabled && player.getVehicle() != null,
Expand All @@ -35,5 +33,17 @@ public abstract class LocalPlayerMixin {
DynamicView.setContextActive(CameraContext.CRAWLING,
contexts.crawlingEnabled && swimmingPose && !player.isInWater(),
contexts.crawlingCamera);
DynamicView.setContextActive(CameraContext.CLIMBING,
contexts.climbingEnabled && player.onClimbable(),
contexts.climbingCamera);
DynamicView.setContextActive(CameraContext.AIMING,
contexts.aimingEnabled && drawingBow,
contexts.aimingCamera);
DynamicView.setContextActive(CameraContext.FISHING,
contexts.fishingEnabled && player.fishing != null,
contexts.fishingCamera);
DynamicView.setContextActive(CameraContext.LUNGING,
contexts.lungingEnabled && player.isAutoSpinAttack(),
contexts.lungingCamera);
}
}
8 changes: 8 additions & 0 deletions common/src/main/resources/assets/dynamicview/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
"text.autoconfig.dynamicview.option.contexts.flyingCamera": "Flying Camera",
"text.autoconfig.dynamicview.option.contexts.ridingEnabled": "Riding Enabled",
"text.autoconfig.dynamicview.option.contexts.ridingCamera": "Riding Camera",
"text.autoconfig.dynamicview.option.contexts.climbingEnabled": "Climbing Enabled",
"text.autoconfig.dynamicview.option.contexts.climbingCamera": "Climbing Camera",
"text.autoconfig.dynamicview.option.contexts.fishingEnabled": "Fishing Enabled",
"text.autoconfig.dynamicview.option.contexts.fishingCamera": "Fishing Camera",
"text.autoconfig.dynamicview.option.contexts.aimingEnabled": "Aiming Enabled",
"text.autoconfig.dynamicview.option.contexts.aimingCamera": "Aiming Camera",
"text.autoconfig.dynamicview.option.contexts.lungingEnabled": "Lunging Enabled",
"text.autoconfig.dynamicview.option.contexts.lungingCamera": "Lunging Camera",
"text.autoconfig.dynamicview.option.animationEnabled": "Enable Zoom Animation",
"text.autoconfig.dynamicview.option.animationEnterSpeed": "Enter Animation Speed (%)",
"text.autoconfig.dynamicview.option.animationExitSpeed": "Exit Animation Speed (%)"
Expand Down
Loading