3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-19 14:30:16 +01:00

Improve ceillog2 method

Dieser Commit ist enthalten in:
Nassim Jahnke 2021-11-19 09:10:06 +01:00
Ursprung 782d7a2172
Commit 8de7a4c828
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
3 geänderte Dateien mit 11 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -81,6 +81,7 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4/5", new VersionRange("1.16", 4, 5)); public static final ProtocolVersion v1_16_4 = register(754, "1.16.4/5", new VersionRange("1.16", 4, 5));
public static final ProtocolVersion v1_17 = register(755, "1.17"); public static final ProtocolVersion v1_17 = register(755, "1.17");
public static final ProtocolVersion v1_17_1 = register(756, "1.17.1"); public static final ProtocolVersion v1_17_1 = register(756, "1.17.1");
public static final ProtocolVersion v1_18 = register(757, "1.18");
public static final ProtocolVersion unknown = register(-1, "UNKNOWN"); public static final ProtocolVersion unknown = register(-1, "UNKNOWN");
public static ProtocolVersion register(int version, String name) { public static ProtocolVersion register(int version, String name) {

Datei anzeigen

@ -46,6 +46,13 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
public Protocol1_18To1_17_1() { public Protocol1_18To1_17_1() {
super(ClientboundPackets1_17_1.class, ClientboundPackets1_18.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class); super(ClientboundPackets1_17_1.class, ClientboundPackets1_18.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
}
@Override
protected void registerPackets() {
entityRewriter.register();
itemRewriter.register();
WorldPackets.register(this);
final SoundRewriter soundRewriter = new SoundRewriter(this); final SoundRewriter soundRewriter = new SoundRewriter(this);
soundRewriter.registerSound(ClientboundPackets1_17_1.SOUND); soundRewriter.registerSound(ClientboundPackets1_17_1.SOUND);
@ -84,13 +91,6 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
.reader("vibration", ParticleType.Readers.VIBRATION); .reader("vibration", ParticleType.Readers.VIBRATION);
} }
@Override
protected void registerPackets() {
entityRewriter.register();
itemRewriter.register();
WorldPackets.register(this);
}
@Override @Override
public MappingData getMappingData() { public MappingData getMappingData() {
return MAPPINGS; return MAPPINGS;

Datei anzeigen

@ -20,18 +20,12 @@ package com.viaversion.viaversion.util;
public final class MathUtil { public final class MathUtil {
/** /**
* Primitive method to return the ceiled log to the base of 2 for the given number. * Returns the ceiled log to the base of 2 for the given number.
* *
* @param i number to ceillog * @param i positive number to ceillog
* @return ceiled log2 of the given number * @return ceiled log2 of the given number
*/ */
public static int ceilLog2(final int i) { public static int ceilLog2(final int i) {
int j = 1; return i > 0 ? 31 - Integer.numberOfLeadingZeros(i) : 0;
int k = 0;
while (j < i) {
j *= 2;
k++;
}
return k;
} }
} }