Skip to content

Commit

Permalink
*gasp* No tabs?????
Browse files Browse the repository at this point in the history
  • Loading branch information
EnnuiL committed Oct 20, 2024
1 parent 35f3a08 commit 5e62672
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public ConfigTextUtils(Config config) {
this.scheme = this.config.metadata(SerializedNameConvention.TYPE);
}

public static Component getConfigTitle(ResourceLocation configId) {
return Component.translatable("config." + configId.getNamespace() + ".title");
}
public static Component getConfigTitle(ResourceLocation configId) {
return Component.translatable("config." + configId.getNamespace() + ".title");
}

public Component getCategoryText(String category) {
return Component.translatable("config." + this.config.family() + "." + this.scheme.coerce(category));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,50 @@

// The implementation of the multiplied cinematic camera
public class MultipliedCinematicCameraMouseModifier implements MouseModifier {
private final Minecraft minecraft;
private final SmoothDouble cursorXZoomSmoother = new SmoothDouble();
private final SmoothDouble cursorYZoomSmoother = new SmoothDouble();
private boolean active;
private boolean cinematicCameraEnabled;
private final double multiplier;

public MultipliedCinematicCameraMouseModifier(double multiplier) {
this.multiplier = multiplier;
this.minecraft = Minecraft.getInstance();
}

@Override
public boolean getActive() {
return this.active;
}

@Override
public double applyXModifier(double cursorDeltaX, double cursorSensitivity, double mouseUpdateTimeDelta, double targetDivisor, double transitionMultiplier) {
if (this.cinematicCameraEnabled) {
this.cursorXZoomSmoother.reset();
return cursorDeltaX;
}

return this.cursorXZoomSmoother.getNewDeltaValue(cursorDeltaX, mouseUpdateTimeDelta * this.multiplier * cursorSensitivity);
}

@Override
public double applyYModifier(double cursorDeltaY, double cursorSensitivity, double mouseUpdateTimeDelta, double targetDivisor, double transitionMultiplier) {
if (this.cinematicCameraEnabled) {
this.cursorYZoomSmoother.reset();
return cursorDeltaY;
}

return this.cursorYZoomSmoother.getNewDeltaValue(cursorDeltaY, mouseUpdateTimeDelta * this.multiplier * cursorSensitivity);
}

@Override
public void tick(boolean active) {
this.cinematicCameraEnabled = this.minecraft.options.smoothCamera;
if (!active && this.active) {
this.cursorXZoomSmoother.reset();
this.cursorYZoomSmoother.reset();
}
this.active = active;
}
private final Minecraft minecraft;
private final SmoothDouble cursorXZoomSmoother = new SmoothDouble();
private final SmoothDouble cursorYZoomSmoother = new SmoothDouble();
private boolean active;
private boolean cinematicCameraEnabled;
private final double multiplier;

public MultipliedCinematicCameraMouseModifier(double multiplier) {
this.multiplier = multiplier;
this.minecraft = Minecraft.getInstance();
}

@Override
public boolean getActive() {
return this.active;
}

@Override
public double applyXModifier(double cursorDeltaX, double cursorSensitivity, double mouseUpdateTimeDelta, double targetDivisor, double transitionMultiplier) {
if (this.cinematicCameraEnabled) {
this.cursorXZoomSmoother.reset();
return cursorDeltaX;
}

return this.cursorXZoomSmoother.getNewDeltaValue(cursorDeltaX, mouseUpdateTimeDelta * this.multiplier * cursorSensitivity);
}

@Override
public double applyYModifier(double cursorDeltaY, double cursorSensitivity, double mouseUpdateTimeDelta, double targetDivisor, double transitionMultiplier) {
if (this.cinematicCameraEnabled) {
this.cursorYZoomSmoother.reset();
return cursorDeltaY;
}

return this.cursorYZoomSmoother.getNewDeltaValue(cursorDeltaY, mouseUpdateTimeDelta * this.multiplier * cursorSensitivity);
}

@Override
public void tick(boolean active) {
this.cinematicCameraEnabled = this.minecraft.options.smoothCamera;
if (!active && this.active) {
this.cursorXZoomSmoother.reset();
this.cursorYZoomSmoother.reset();
}
this.active = active;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,33 @@

// An implementation of the spyglass overlay as a zoom overlay
public class SpyglassZoomOverlay implements ZoomOverlay {
private final ResourceLocation textureId;
//private Minecraft minecraft;
private float scale;
private boolean active;
private final ResourceLocation textureId;
//private Minecraft minecraft;
private float scale;
private boolean active;

public SpyglassZoomOverlay(ResourceLocation textureId) {
this.textureId = textureId;
this.scale = 0.5F;
this.active = false;
public SpyglassZoomOverlay(ResourceLocation textureId) {
this.textureId = textureId;
this.scale = 0.5F;
this.active = false;
//this.minecraft = Minecraft.getInstance();
}
}

@Override
public boolean getActive() {
return this.active;
}
@Override
public boolean getActive() {
return this.active;
}

@Override
public boolean cancelOverlayRendering() {
return true;
}
@Override
public boolean cancelOverlayRendering() {
return true;
}

// TODO - Consider whenever a third-person view block tweak option is desirable
@Override
public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, TransitionMode transitionMode) {
int guiWidth = graphics.guiWidth();
int guiHeight = graphics.guiHeight();
@Override
public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, TransitionMode transitionMode) {
int guiWidth = graphics.guiWidth();
int guiHeight = graphics.guiHeight();
float smallerLength = (float) Math.min(guiWidth, guiHeight);
float scaledSmallerLength = Math.min((float) guiWidth / smallerLength, (float) guiHeight / smallerLength) * scale;
int width = Mth.floor(smallerLength * scaledSmallerLength);
Expand All @@ -53,19 +53,19 @@ public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, Trans
graphics.fill(RenderType.guiOverlay(), 0, 0, guiWidth, y, -90, CommonColors.BLACK);
graphics.fill(RenderType.guiOverlay(), 0, y, x, borderY, -90, CommonColors.BLACK);
graphics.fill(RenderType.guiOverlay(), borderX, y, guiWidth, borderY, -90, CommonColors.BLACK);
}
}

@Override
public void tick(boolean active, double divisor, TransitionMode transitionMode) {
this.active = active;
}
@Override
public void tick(boolean active, double divisor, TransitionMode transitionMode) {
this.active = active;
}

@Override
public void tickBeforeRender(DeltaTracker deltaTracker) {
@Override
public void tickBeforeRender(DeltaTracker deltaTracker) {
if (!this.active) {
this.scale = 0.5F;
} else {
this.scale = Mth.lerp(0.5F * deltaTracker.getGameTimeDeltaTicks(), this.scale, 1.125F);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@

// Implements the zoom overlay
public class ZoomerZoomOverlay implements ZoomOverlay {
private final ResourceLocation textureId;
private boolean active;
private final ResourceLocation textureId;
private boolean active;

public ZoomerZoomOverlay(ResourceLocation textureId) {
this.textureId = textureId;
this.active = false;
}
public ZoomerZoomOverlay(ResourceLocation textureId) {
this.textureId = textureId;
this.active = false;
}

@Override
public boolean getActive() {
return this.active;
}
@Override
public boolean getActive() {
return this.active;
}

@Override
public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, TransitionMode transitionMode) {
@Override
public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, TransitionMode transitionMode) {
RenderSystem.disableDepthTest();
RenderSystem.depthMask(false);
RenderSystem.enableBlend();
Expand All @@ -40,12 +40,12 @@ public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, Trans
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.defaultBlendFunc();
RenderSystem.disableBlend();
}
}

@Override
public void tick(boolean active, double divisor, TransitionMode transitionMode) {
if (active || !transitionMode.getActive()) {
this.active = active;
}
}
@Override
public void tick(boolean active, double divisor, TransitionMode transitionMode) {
if (active || !transitionMode.getActive()) {
this.active = active;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,60 @@

// The implementation of the linear transition
public class LinearTransitionMode implements TransitionMode {
private boolean active;
private final double minimumLinearStep;
private final double maximumLinearStep;
private float fovMultiplier;
private float internalMultiplier;
private float lastInternalMultiplier;
private boolean active;
private final double minimumLinearStep;
private final double maximumLinearStep;
private float fovMultiplier;
private float internalMultiplier;
private float lastInternalMultiplier;
private float internalFade;
private float lastInternalFade;

public LinearTransitionMode(double minimumLinearStep, double maximumLinearStep) {
this.active = false;
this.minimumLinearStep = minimumLinearStep;
this.maximumLinearStep = maximumLinearStep;
this.internalMultiplier = 1.0F;
this.lastInternalMultiplier = 1.0F;
public LinearTransitionMode(double minimumLinearStep, double maximumLinearStep) {
this.active = false;
this.minimumLinearStep = minimumLinearStep;
this.maximumLinearStep = maximumLinearStep;
this.internalMultiplier = 1.0F;
this.lastInternalMultiplier = 1.0F;
this.internalFade = 0.0F;
this.lastInternalFade = 0.0F;
}
}

@Override
public boolean getActive() {
return this.active;
}
@Override
public boolean getActive() {
return this.active;
}

@Override
public float applyZoom(float fov, float tickDelta) {
fovMultiplier = Mth.lerp(tickDelta, this.lastInternalMultiplier, this.internalMultiplier);
return fov * fovMultiplier;
}
@Override
public float applyZoom(float fov, float tickDelta) {
fovMultiplier = Mth.lerp(tickDelta, this.lastInternalMultiplier, this.internalMultiplier);
return fov * fovMultiplier;
}

@Override
public float getFade(float tickDelta) {
return Mth.lerp(tickDelta, this.lastInternalFade, this.internalFade);
}

@Override
public void tick(boolean active, double divisor) {
double zoomMultiplier = 1.0 / divisor;
public void tick(boolean active, double divisor) {
double zoomMultiplier = 1.0 / divisor;
double fadeMultiplier = active ? 1.0D : 0.0D;

this.lastInternalMultiplier = this.internalMultiplier;
this.lastInternalFade = this.internalFade;

double linearStep = Mth.clamp(zoomMultiplier, this.minimumLinearStep, this.maximumLinearStep);
this.internalMultiplier = Mth.approach(this.internalMultiplier, (float) zoomMultiplier, (float) linearStep);
this.internalFade = Mth.approach(this.internalFade, (float) fadeMultiplier, (float) linearStep);
double linearStep = Mth.clamp(zoomMultiplier, this.minimumLinearStep, this.maximumLinearStep);
this.internalMultiplier = Mth.approach(this.internalMultiplier, (float) zoomMultiplier, (float) linearStep);
this.internalFade = Mth.approach(this.internalFade, (float) fadeMultiplier, (float) linearStep);

if (active || fovMultiplier == this.internalMultiplier) {
this.active = active;
}
}
if (active || fovMultiplier == this.internalMultiplier) {
this.active = active;
}
}

@Override
public double getInternalMultiplier() {
return this.internalMultiplier;
}
@Override
public double getInternalMultiplier() {
return this.internalMultiplier;
}
}

0 comments on commit 5e62672

Please sign in to comment.