3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 00:50:13 +01:00

minor code improvements

Dieser Commit ist enthalten in:
Koppe 2020-08-10 22:28:40 +02:00
Ursprung 0b17b81b63
Commit 93c84b1912
2 geänderte Dateien mit 10 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -270,17 +270,19 @@ public class Protocol1_11To1_10 extends Protocol<ClientboundPackets1_9_3, Client
this.map(Type.INT); //effectData
this.map(Type.BOOLEAN); //serverwide / global
handler(packetWrapper -> {
final int effectID = packetWrapper.get(Type.INT, 0);
int effectID = packetWrapper.get(Type.INT, 0);
if (effectID == 2002) {
int data = packetWrapper.get(Type.INT, 1);
final Pair<Integer, Boolean> newData = PotionColorMapping.getNewData(data);
if (newData.getKey() == -1) {
boolean isInstant = false;
Pair<Integer, Boolean> newData = PotionColorMapping.getNewData(data);
if (newData == null) {
Via.getPlatform().getLogger().warning("Received unknown 1.11 -> 1.10.2 potion data (" + data + ")");
data = 0;
} else {
data = newData.getKey();
isInstant = newData.getValue();
}
if (newData.getValue()) {
if (isInstant) {
packetWrapper.set(Type.INT, 0, 2007);
}
packetWrapper.set(Type.INT, 1, data);

Datei anzeigen

@ -7,7 +7,7 @@ import us.myles.ViaVersion.api.Pair;
public class PotionColorMapping {
//<oldData> to <newData, isInstant> mapping
private static final Int2ObjectMap<Pair<Integer, Boolean>> POTIONS = new Int2ObjectOpenHashMap<>(17, 1.0F);
private static final Int2ObjectMap<Pair<Integer, Boolean>> POTIONS = new Int2ObjectOpenHashMap<>(37, 1.0F);
static {
addRewrite(0, 3694022, false);
@ -49,15 +49,11 @@ public class PotionColorMapping {
addRewrite(36, 3381504, false);
}
public static Pair<Integer, Boolean> getNewData(final int oldData) {
return POTIONS.getOrDefault(oldData, new Pair<>(-1, false));
public static Pair<Integer, Boolean> getNewData(int oldData) {
return POTIONS.get(oldData);
}
public static boolean contains(final int oldData) {
return POTIONS.containsKey(oldData);
}
private static void addRewrite(final int oldData, final int newData, final boolean isInstant) {
private static void addRewrite(int oldData, int newData, boolean isInstant) {
POTIONS.put(oldData, new Pair<>(newData, isInstant));
}