Skip to content

Commit

Permalink
change: Remove RSO suggestion screen
Browse files Browse the repository at this point in the history
  • Loading branch information
FlashyReese committed Sep 29, 2023
1 parent cc29e9f commit cb9c0ce
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ public class SodiumExtraGameOptions {
public final DetailSettings detailSettings = new DetailSettings();
public final RenderSettings renderSettings = new RenderSettings();
public final ExtraSettings extraSettings = new ExtraSettings();
public final NotificationSettings notificationSettings = new NotificationSettings();
public final SuperSecretSettings superSecretSettings = new SuperSecretSettings();
private File file;
private boolean suggestedRSO;

public static SodiumExtraGameOptions load(File file) {
SodiumExtraGameOptions config;
Expand All @@ -52,7 +50,6 @@ public static SodiumExtraGameOptions load(File file) {
}

config.file = file;
config.suggestedRSO = false;
config.writeChanges();

return config;
Expand All @@ -76,14 +73,6 @@ public void writeChanges() {
}
}

public boolean hasSuggestedRSO() {
return this.suggestedRSO;
}

public void setSuggestedRSO(boolean suggestedRSO) {
this.suggestedRSO = suggestedRSO;
}

public enum OverlayCorner implements TextProvider {
TOP_LEFT("sodium-extra.option.overlay_corner.top_left"),
TOP_RIGHT("sodium-extra.option.overlay_corner.top_right"),
Expand Down Expand Up @@ -276,14 +265,6 @@ public ExtraSettings() {
}
}

public static class NotificationSettings {
public boolean hideRSORecommendation;

public NotificationSettings() {
this.hideRSORecommendation = false;
}
}

public static class SuperSecretSettings {
public boolean fetchSodiumExtraCrowdinTranslations;
public String sodiumExtraCrowdinProjectIdentifier;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter;
import me.jellysquid.mods.sodium.client.util.Dim2i;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.Rect2i;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
import org.apache.commons.lang3.Validate;
Expand Down Expand Up @@ -52,7 +51,6 @@ public int getMaxWidth() {
private static class Slider extends ControlElement<Integer> {
private static final int THUMB_WIDTH = 2, TRACK_HEIGHT = 1;

private final Rect2i sliderBounds;
private final ControlValueFormatter formatter;
private final boolean displayIntValueWhileSliding;

Expand All @@ -71,8 +69,10 @@ public Slider(Option<Integer> option, Dim2i dim, int min, int max, int interval,
this.thumbPosition = this.getThumbPositionForValue(option.getValue());
this.formatter = formatter;
this.displayIntValueWhileSliding = displayIntValueWhileSliding;
}

this.sliderBounds = new Rect2i(dim.getLimitX() - 96, dim.getCenterY() - 5, 90, 10);
public Dim2i getSliderBounds() {
return new Dim2i(dim.getLimitX() - 96, dim.getCenterY() - 5, 90, 10);
}

@Override
Expand All @@ -87,10 +87,10 @@ public void render(DrawContext drawContext, int mouseX, int mouseY, float delta)
}

private void renderStandaloneValue(DrawContext drawContext) {
int sliderX = this.sliderBounds.getX();
int sliderY = this.sliderBounds.getY();
int sliderWidth = this.sliderBounds.getWidth();
int sliderHeight = this.sliderBounds.getHeight();
int sliderX = this.getSliderBounds().x();
int sliderY = this.getSliderBounds().y();
int sliderWidth = this.getSliderBounds().width();
int sliderHeight = this.getSliderBounds().height();

Text label = this.formatter.format(this.option.getValue());
int labelWidth = this.font.getWidth(label);
Expand All @@ -99,10 +99,10 @@ private void renderStandaloneValue(DrawContext drawContext) {
}

private void renderSlider(DrawContext drawContext) {
int sliderX = this.sliderBounds.getX();
int sliderY = this.sliderBounds.getY();
int sliderWidth = this.sliderBounds.getWidth();
int sliderHeight = this.sliderBounds.getHeight();
int sliderX = this.getSliderBounds().x();
int sliderY = this.getSliderBounds().y();
int sliderWidth = this.getSliderBounds().width();
int sliderHeight = this.getSliderBounds().height();

this.thumbPosition = this.getThumbPositionForValue(option.getValue());

Expand Down Expand Up @@ -135,7 +135,7 @@ public double getThumbPositionForValue(int value) {

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (this.option.isAvailable() && button == 0 && this.sliderBounds.contains((int) mouseX, (int) mouseY)) {
if (this.option.isAvailable() && button == 0 && this.getSliderBounds().containsCursor(mouseX, mouseY)) {
this.setValueFromMouse(mouseX);

return true;
Expand All @@ -145,7 +145,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
}

private void setValueFromMouse(double d) {
this.setValue((d - (double) this.sliderBounds.getX()) / (double) this.sliderBounds.getWidth());
this.setValue((d - (double) this.getSliderBounds().x()) / (double) this.getSliderBounds().width());
}

private void setValue(double d) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,14 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = BeaconBlockEntityRenderer.class, priority = 1500)
public class MixinBeaconBlockEntityRenderer {

@Inject(method = "render(Lnet/minecraft/block/entity/BeaconBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "HEAD"), cancellable = true)
public void render(BeaconBlockEntity beaconBlockEntity, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j, CallbackInfo ci) {
Frustum frustum = ((WorldRendererAccessor) MinecraftClient.getInstance().worldRenderer).getFrustum();
Box box = new Box(
beaconBlockEntity.getPos().getX() - 1.0,
beaconBlockEntity.getPos().getY() - 1.0,
beaconBlockEntity.getPos().getZ() - 1.0,
beaconBlockEntity.getPos().getX() + 1.0,
beaconBlockEntity.getPos().getY() + (beaconBlockEntity.getBeamSegments().isEmpty() ? 1.0 : 1024.0), // todo: probably want to limit this to max height vanilla overshoots as well
beaconBlockEntity.getPos().getZ() + 1.0);

if (!frustum.isVisible(box)) {
ci.cancel();
}
}
public abstract class MixinBeaconBlockEntityRenderer {

/**
* @author FlashyReese
* @reason Use optimized vertex writer, also avoids unnecessary allocations
*/
@Inject(method = "renderBeam(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/util/Identifier;FFJII[FFF)V", at = @At(value = "HEAD"), cancellable = true)
private static void renderBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, Identifier textureId, float tickDelta, float heightScale, long worldTime, int yOffset, int maxY, float[] color, float innerRadius, float outerRadius, CallbackInfo ci) {
private static void optimizeRenderBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, Identifier textureId, float tickDelta, float heightScale, long worldTime, int yOffset, int maxY, float[] color, float innerRadius, float outerRadius, CallbackInfo ci) {
ci.cancel();
if (IrisCompat.isIrisPresent()) {
if (IrisCompat.isRenderingShadowPass()) {
Expand Down Expand Up @@ -137,4 +121,20 @@ private static long transformAndWriteVertex(long ptr, Matrix4f positionMatrix, f
ptr += ModelVertex.STRIDE;
return ptr;
}

@Inject(method = "render(Lnet/minecraft/block/entity/BeaconBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "HEAD"), cancellable = true)
public void render(BeaconBlockEntity beaconBlockEntity, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j, CallbackInfo ci) {
Frustum frustum = ((WorldRendererAccessor) MinecraftClient.getInstance().worldRenderer).getFrustum();
Box box = new Box(
beaconBlockEntity.getPos().getX() - 1.0,
beaconBlockEntity.getPos().getY() - 1.0,
beaconBlockEntity.getPos().getZ() - 1.0,
beaconBlockEntity.getPos().getX() + 1.0,
beaconBlockEntity.getPos().getY() + (beaconBlockEntity.getBeamSegments().isEmpty() ? 1.0 : 1024.0), // todo: probably want to limit this to max height vanilla overshoots as well
beaconBlockEntity.getPos().getZ() + 1.0);

if (!frustum.isVisible(box)) {
ci.cancel();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,35 @@
import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Coerce;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Objects;

@Mixin(value = BeaconBlockEntityRenderer.class, priority = 999)
public class MixinBeaconBlockEntityRenderer {

@Shadow
private static void renderBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumers, float tickDelta, long worldTime, int yOffset, int maxY, float[] color) {
}

@Inject(method = "render(Lnet/minecraft/block/entity/BeaconBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "HEAD"), cancellable = true)
public void render(BeaconBlockEntity beaconBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j, CallbackInfo ci) {
if (!SodiumExtraClientMod.options().renderSettings.beaconBeam)
ci.cancel();
}

@Coerce
@Redirect(method = "render(Lnet/minecraft/block/entity/BeaconBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/entity/BeaconBlockEntityRenderer;renderBeam(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;FJII[F)V"))
private void modifyMaxY(MatrixStack matrices, VertexConsumerProvider vertexConsumers, float tickDelta, long worldTime, int yOffset, int maxY, float[] color, BeaconBlockEntity beaconBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) {
if (maxY == 1024) {
int lastSegment = beaconBlockEntity.getPos().getY() + yOffset;
maxY = Objects.requireNonNull(beaconBlockEntity.getWorld()).getTopY() - lastSegment; // Todo: This fixes the beam to max height of the world, should be toggle-able
}
renderBeam(matrices, vertexConsumers, tickDelta, worldTime, yOffset, maxY, color);
}
}
1 change: 0 additions & 1 deletion src/main/resources/sodium-extra.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"biome_colors.MixinBiomeColors",
"cloud.MixinDimensionEffectsOverworld",
"compat.MixinSodiumOptionsGUI",
"compat.MixinTitleScreen",
"fog.MixinBackgroundRenderer",
"fog_falloff.MixinBackgroundRenderer",
"gui.MinecraftClientAccessor",
Expand Down

0 comments on commit cb9c0ce

Please sign in to comment.