fixed Protocol Range impl

This commit is contained in:
FlorianMichael 2023-02-20 05:16:25 +01:00
parent 2ce8031494
commit 16d8079d73
4 changed files with 7 additions and 12 deletions

View File

@ -1,10 +1,3 @@
# ViaFabricPlus # ViaFabricPlus
Clientside ViaVersion, ViaLegacy and ViaAprilFools implementation with clientside fixes for Fabric Clientside ViaVersion, ViaLegacy and ViaAprilFools implementation with clientside fixes for Fabric
TODO:
ViaFabricPlus-Visual:
Armor
Hunger bar
Signature indicator
Petrified Oak slab

View File

@ -41,7 +41,7 @@ public class ItemReleaseVersionDefinition {
private final static Map<Item, ProtocolRange[]> itemMap = new HashMap<>(); private final static Map<Item, ProtocolRange[]> itemMap = new HashMap<>();
public static boolean contains(final Item item, final ComparableProtocolVersion version) { public static boolean contains(final Item item, final ComparableProtocolVersion version) {
if (!itemMap.containsKey(item)) return false; if (!itemMap.containsKey(item)) return true;
return Arrays.stream(itemMap.get(item)).anyMatch(protocolRange -> protocolRange.contains(version)); return Arrays.stream(itemMap.get(item)).anyMatch(protocolRange -> protocolRange.contains(version));
} }

View File

@ -50,9 +50,11 @@ public class ProtocolRange {
} }
public boolean contains(final ComparableProtocolVersion protocolVersion) { public boolean contains(final ComparableProtocolVersion protocolVersion) {
if (this.lowerBound != null && this.lowerBound.getIndex() < protocolVersion.getIndex()) return false; if (this.lowerBound != null && protocolVersion.getIndex() < lowerBound.getIndex())
return false;
return this.upperBound == null || this.upperBound.getIndex() <= protocolVersion.getIndex(); if (this.upperBound != null && protocolVersion.getIndex() > upperBound.getIndex())
return false;
return true;
} }
@Override @Override

View File

@ -31,7 +31,7 @@ public class ProtocolSyncBooleanValue extends AbstractValue<Boolean> {
private boolean syncWithProtocol; private boolean syncWithProtocol;
public ProtocolSyncBooleanValue(String name, ProtocolRange protocolRange) { public ProtocolSyncBooleanValue(String name, ProtocolRange protocolRange) {
super(name, true); super(name + " (" + protocolRange.toString() + ")", true);
this.protocolRange = protocolRange; this.protocolRange = protocolRange;
} }