mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-26 10:27:56 +01:00
minor code improvements
This commit is contained in:
parent
0b17b81b63
commit
93c84b1912
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user