Implemented jigsaw screen changes

This commit is contained in:
RaphiMC 2023-12-13 18:07:46 +01:00
parent ecd5d18818
commit 24368bb5eb
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
2 changed files with 25 additions and 12 deletions

View File

@ -19,6 +19,7 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
import net.minecraft.block.entity.JigsawBlockEntity;
import net.minecraft.client.gui.DrawContext;
@ -28,6 +29,7 @@ import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.gui.widget.CyclingButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.text.Text;
import net.raphimc.vialoader.util.VersionEnum;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@ -46,25 +48,36 @@ public abstract class MixinJigsawBlockScreen extends Screen {
@Shadow
private TextFieldWidget targetField;
@Shadow
private TextFieldWidget selectionPriorityField;
@Shadow
private TextFieldWidget placementPriorityField;
public MixinJigsawBlockScreen(Text title) {
super(title);
}
@Inject(method = "init", at = @At("RETURN"))
private void removeWidgets(CallbackInfo ci) {
private void disableWidgets(CallbackInfo ci) {
if (VisualSettings.global().removeNewerFeaturesFromJigsawScreen.isEnabled()) {
nameField.active = false;
jointRotationButton.active = false;
int index = children().indexOf(jointRotationButton);
((ClickableWidget) children().get(index + 1)).active = false; // levels slider
((ClickableWidget) children().get(index + 2)).active = false; // keep jigsaws toggle
((ClickableWidget) children().get(index + 3)).active = false; // generate button
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
nameField.active = false;
jointRotationButton.active = false;
int index = children().indexOf(jointRotationButton);
((ClickableWidget) children().get(index + 1)).active = false; // levels slider
((ClickableWidget) children().get(index + 2)).active = false; // keep jigsaws toggle
((ClickableWidget) children().get(index + 3)).active = false; // generate button
}
selectionPriorityField.active = false;
placementPriorityField.active = false;
}
}
@Inject(method = "render", at = @At("HEAD"))
private void copyText(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (VisualSettings.global().removeNewerFeaturesFromJigsawScreen.isEnabled()) {
if (VisualSettings.global().removeNewerFeaturesFromJigsawScreen.isEnabled() && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
nameField.setText(targetField.getText());
}
}

View File

@ -19,24 +19,24 @@
package de.florianmichael.viafabricplus.settings.impl;
import net.raphimc.vialoader.util.VersionEnum;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.base.VersionedBooleanSetting;
import net.minecraft.text.Text;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialoader.util.VersionRange;
public class VisualSettings extends SettingGroup {
private static final VisualSettings instance = new VisualSettings();
// 1.20.3 -> 1.20.2 and 1.16 -> 1.15.2
public final VersionedBooleanSetting removeNewerFeaturesFromJigsawScreen = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen"), VersionRange.andOlder(VersionEnum.r1_20_2));
// 1.19.2 -> 1.19
public final VersionedBooleanSetting disableSecureChatWarning = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.disable_secure_chat_warning"), VersionRange.andOlder(VersionEnum.r1_19));
// 1.19 -> 1.18.2
public final VersionedBooleanSetting hideSignatureIndicator = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.hide_signature_indicator"), VersionRange.andOlder(VersionEnum.r1_18_2));
// 1.16 -> 1.15.2
public final VersionedBooleanSetting removeNewerFeaturesFromJigsawScreen = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen"), VersionRange.andOlder(VersionEnum.r1_15_2));
// 1.13 -> 1.12.2
public final VersionedBooleanSetting replacePetrifiedOakSlab = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.replace_petrified_oak_slab"), VersionRange.of(VersionEnum.r1_3_1tor1_3_2, VersionEnum.r1_12_2));
public final VersionedBooleanSetting changeFontRendererBehaviour = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.change_font_renderer_behaviour"), VersionRange.andOlder(VersionEnum.r1_12_2));