Cleaned PerServerVersionScreen

This commit is contained in:
FlorianMichael 2024-01-02 04:39:15 +01:00
parent 5b5b68e2ec
commit 6e91f4419a
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 18 additions and 13 deletions

View File

@ -60,8 +60,9 @@ public abstract class MixinPlayerEntity extends LivingEntity {
@Shadow @Shadow
@Final @Final
private PlayerInventory inventory; private PlayerInventory inventory;
@Unique @Unique
private static final EntityDimensions viaFabricPlus$sneaking_dimensions_v1_13_2 = EntityDimensions.changing(0.6f, 1.65f); private static final EntityDimensions viaFabricPlus$sneaking_dimensions_v1_13_2 = EntityDimensions.changing(0.6F, 1.65F);
@Unique @Unique
private static final SoundEvent viaFabricPlus$oof_hurt = SoundEvent.of(new Identifier("viafabricplus", "oof.hurt")); private static final SoundEvent viaFabricPlus$oof_hurt = SoundEvent.of(new Identifier("viafabricplus", "oof.hurt"));

View File

@ -60,33 +60,37 @@ public class PerServerVersionScreen extends VFPScreen {
this.renderTitle(context); this.renderTitle(context);
} }
public class SlotList extends AlwaysSelectedEntryListWidget<DummyProtocolSlot> { public class SlotList extends AlwaysSelectedEntryListWidget<SharedSlot> {
public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) { public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) {
super(minecraftClient, width, height - top - bottom, top, entryHeight); super(minecraftClient, width, height - top - bottom, top, entryHeight);
this.addEntry(new ResetProtocolSlot()); this.addEntry(new ResetSlot());
VersionEnum.SORTED_VERSIONS.stream().map(ViaProtocolSlot::new).forEach(this::addEntry); VersionEnum.SORTED_VERSIONS.stream().map(ProtocolSlot::new).forEach(this::addEntry);
} }
} }
// Dummy class files used to have a shared superclass for ResetSlot and ProtocolSlot
public abstract class SharedSlot extends AlwaysSelectedEntryListWidget.Entry<SharedSlot> {
public abstract static class DummyProtocolSlot extends AlwaysSelectedEntryListWidget.Entry<DummyProtocolSlot> { @Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
playClickSound();
close();
return super.mouseClicked(mouseX, mouseY, button);
}
} }
public class ResetProtocolSlot extends DummyProtocolSlot { public class ResetSlot extends SharedSlot {
@Override @Override
public Text getNarration() { public Text getNarration() {
return Text.translatable("base.viafabricplus.cancel_and_reset"); return Text.translatable("base.viafabricplus.cancel_and_reset");
} }
@Override @Override
public boolean mouseClicked(double mouseX, double mouseY, int button) { public boolean mouseClicked(double mouseX, double mouseY, int button) {
selectionConsumer.accept(null); selectionConsumer.accept(null);
playClickSound();
close();
return super.mouseClicked(mouseX, mouseY, button); return super.mouseClicked(mouseX, mouseY, button);
} }
@ -98,10 +102,11 @@ public class PerServerVersionScreen extends VFPScreen {
} }
} }
public class ViaProtocolSlot extends DummyProtocolSlot { public class ProtocolSlot extends SharedSlot {
private final VersionEnum versionEnum; private final VersionEnum versionEnum;
public ViaProtocolSlot(final VersionEnum versionEnum) { public ProtocolSlot(final VersionEnum versionEnum) {
this.versionEnum = versionEnum; this.versionEnum = versionEnum;
} }
@ -113,8 +118,6 @@ public class PerServerVersionScreen extends VFPScreen {
@Override @Override
public boolean mouseClicked(double mouseX, double mouseY, int button) { public boolean mouseClicked(double mouseX, double mouseY, int button) {
selectionConsumer.accept(versionEnum); selectionConsumer.accept(versionEnum);
playClickSound();
close();
return super.mouseClicked(mouseX, mouseY, button); return super.mouseClicked(mouseX, mouseY, button);
} }

View File

@ -117,6 +117,7 @@ public class ProtocolSelectionScreen extends VFPScreen {
} }
public static class ProtocolSlot extends AlwaysSelectedEntryListWidget.Entry<ProtocolSlot> { public static class ProtocolSlot extends AlwaysSelectedEntryListWidget.Entry<ProtocolSlot> {
private final VersionEnum versionEnum; private final VersionEnum versionEnum;
public ProtocolSlot(final VersionEnum versionEnum) { public ProtocolSlot(final VersionEnum versionEnum) {