mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-22 16:48:25 +01:00
Resolved TODO in EntityDimensionDiff
Added ProtocolTranslator#isCloserTo
This commit is contained in:
parent
5f0ac0caea
commit
7d5408f7f9
@ -21,6 +21,7 @@ package de.florianmichael.viafabricplus.fixes.data;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.event.ChangeProtocolVersionCallback;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
import net.minecraft.entity.EntityType;
|
||||
@ -198,11 +199,10 @@ public class EntityDimensionDiff {
|
||||
}
|
||||
|
||||
// If the current version is closer to the version you are looking for
|
||||
// TODO: Fix
|
||||
/*if (closestVersion == null || Math.abs(version.ordinal() - currentVersion.ordinal()) < Math.abs(version.ordinal() - closestVersion.ordinal())) {
|
||||
if (closestVersion == null || ProtocolTranslator.isCloserTo(version, currentVersion, closestVersion)) {
|
||||
closestVersion = currentVersion;
|
||||
closestDimensions = currentDimensions;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
return closestDimensions;
|
||||
|
@ -261,6 +261,23 @@ public class ProtocolTranslator {
|
||||
new ConfigPatcher(viaLegacyConfig, viaLegacyPatches);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if first is closer to version than second
|
||||
*
|
||||
* @param version The version to compare to
|
||||
* @param first The first version
|
||||
* @param second The second version
|
||||
* @return true if first is closer to version than second
|
||||
*/
|
||||
public static boolean isCloserTo(final ProtocolVersion version, final ProtocolVersion first, final ProtocolVersion second) {
|
||||
if (version.getVersionType() == first.getVersionType() || version.getVersionType() == second.getVersionType()) {
|
||||
return Math.abs(version.getVersion() - first.getVersion()) < Math.abs(version.getVersion() - second.getVersion());
|
||||
} else {
|
||||
final int ordinal = version.getVersionType().ordinal();
|
||||
return Math.abs(ordinal - first.getVersionType().ordinal()) < Math.abs(ordinal - second.getVersionType().ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to initialize the whole Protocol Translator
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user