FlorianMichael 2023-06-24 23:14:25 +02:00
parent 72204af164
commit 989c876920
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 15 additions and 6 deletions

View File

@ -45,7 +45,7 @@ public class DebugSettings extends SettingGroup {
// 1.9 -> 1.8.x
public final ProtocolSyncBooleanSetting removeCooldowns = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.cooldown"), VersionRange.andOlder(VersionEnum.r1_8));
public final ProtocolSyncBooleanSetting sendIdlePacket = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.idle"), new VersionRange(VersionEnum.r1_8, VersionEnum.r1_3_1tor1_3_2));
public final ProtocolSyncBooleanSetting sendIdlePacket = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.idle"), new VersionRange(VersionEnum.r1_8, VersionEnum.r1_4_2), VersionRange.andOlder(VersionEnum.r1_2_4tor1_2_5));
public final ProtocolSyncBooleanSetting replaceAttributeModifiers = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.attribute"), VersionRange.andOlder(VersionEnum.r1_8));
// 1.8.x -> 1.7.6

View File

@ -30,9 +30,9 @@ public class ProtocolSyncBooleanSetting extends AbstractSetting<Integer> {
public final static int AUTO = 2;
public final static int ENABLED = 0;
private final VersionRange protocolRange;
private final VersionRange[] protocolRange;
public ProtocolSyncBooleanSetting(SettingGroup parent, MutableText name, VersionRange protocolRange) {
public ProtocolSyncBooleanSetting(SettingGroup parent, MutableText name, VersionRange... protocolRange) {
super(parent, name, 2);
this.protocolRange = protocolRange;
@ -65,12 +65,20 @@ public class ProtocolSyncBooleanSetting extends AbstractSetting<Integer> {
}
public boolean isEnabled() {
if (isAuto()) return this.getProtocolRange().contains(ProtocolHack.getTargetVersion());
if (isAuto()) {
if (getProtocolRange().length == 1) {
return getProtocolRange()[0].contains(ProtocolHack.getTargetVersion());
} else {
for (VersionRange versionRange : getProtocolRange()) {
if (versionRange.contains(ProtocolHack.getTargetVersion())) return true;
}
}
}
return getValue() == ENABLED;
}
public VersionRange getProtocolRange() {
public VersionRange[] getProtocolRange() {
return protocolRange;
}
}

View File

@ -26,6 +26,7 @@ import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.awt.*;
import java.util.Arrays;
public class ProtocolSyncBooleanSettingRenderer extends MappedSlotEntry {
private final ProtocolSyncBooleanSetting value;
@ -54,7 +55,7 @@ public class ProtocolSyncBooleanSettingRenderer extends MappedSlotEntry {
final int length = context.drawTextWithShadow(textRenderer, this.value.getName().formatted(Formatting.GRAY), 3, entryHeight / 2 - textRenderer.fontHeight / 2, -1);
context.drawTextWithShadow(textRenderer, "(" + this.value.getProtocolRange().toString() + ")", length + 2, entryHeight / 2 - textRenderer.fontHeight / 2, -1);
context.drawTextWithShadow(textRenderer, Arrays.toString(this.value.getProtocolRange()).replace("[", "(").replace("]", ")"), length + 2, entryHeight / 2 - textRenderer.fontHeight / 2, -1);
context.drawTextWithShadow(textRenderer, text, entryWidth - textRenderer.getWidth(text) - 3 - 3, entryHeight / 2 - textRenderer.fontHeight / 2, color.getRGB());
}
}