Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Improve ceillog2 method
Dieser Commit ist enthalten in:
Ursprung
782d7a2172
Commit
8de7a4c828
@ -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_17 = register(755, "1.17");
|
||||
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 ProtocolVersion register(int version, String name) {
|
||||
|
@ -46,6 +46,13 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
public Protocol1_18To1_17_1() {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
entityRewriter.register();
|
||||
itemRewriter.register();
|
||||
WorldPackets.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MappingData getMappingData() {
|
||||
return MAPPINGS;
|
||||
|
@ -20,18 +20,12 @@ package com.viaversion.viaversion.util;
|
||||
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
|
||||
*/
|
||||
public static int ceilLog2(final int i) {
|
||||
int j = 1;
|
||||
int k = 0;
|
||||
while (j < i) {
|
||||
j *= 2;
|
||||
k++;
|
||||
}
|
||||
return k;
|
||||
return i > 0 ? 31 - Integer.numberOfLeadingZeros(i) : 0;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren