3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Merge pull request #1977 from RaphiMC/dev

fixed 1.11 -> 1.10.2 potion data remapping
Dieser Commit ist enthalten in:
Nassim 2020-08-10 22:34:50 +02:00 committet von GitHub
Commit 617abe2d8c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 91 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -3,6 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_11to1_10;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.entities.Entity1_11Types;
@ -15,6 +16,7 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.rewriters.SoundRewriter;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_9;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.data.PotionColorMapping;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.metadata.MetadataRewriter1_11To1_10;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.storage.EntityTracker1_11;
@ -260,6 +262,35 @@ public class Protocol1_11To1_10 extends Protocol<ClientboundPackets1_9_3, Client
}
});
this.registerOutgoing(ClientboundPackets1_9_3.EFFECT, new PacketRemapper() {
@Override
public void registerMap() {
this.map(Type.INT); //effectID
this.map(Type.POSITION); //pos
this.map(Type.INT); //effectData
this.map(Type.BOOLEAN); //serverwide / global
handler(packetWrapper -> {
int effectID = packetWrapper.get(Type.INT, 0);
if (effectID == 2002) {
int data = packetWrapper.get(Type.INT, 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 (isInstant) {
packetWrapper.set(Type.INT, 0, 2007);
}
packetWrapper.set(Type.INT, 1, data);
}
});
}
});
/*
INCOMING PACKETS
*/

Datei anzeigen

@ -0,0 +1,60 @@
package us.myles.ViaVersion.protocols.protocol1_11to1_10.data;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import us.myles.ViaVersion.api.Pair;
public class PotionColorMapping {
//<oldData> to <newData, isInstant> mapping
private static final Int2ObjectMap<Pair<Integer, Boolean>> POTIONS = new Int2ObjectOpenHashMap<>(37, 1.0F);
static {
addRewrite(0, 3694022, false);
addRewrite(1, 3694022, false);
addRewrite(2, 3694022, false);
addRewrite(3, 3694022, false);
addRewrite(4, 3694022, false);
addRewrite(5, 2039713, false);
addRewrite(6, 2039713, false);
addRewrite(7, 8356754, false);
addRewrite(8, 8356754, false);
addRewrite(9, 2293580, false);
addRewrite(10, 2293580, false);
addRewrite(11, 2293580, false);
addRewrite(12, 14981690, false);
addRewrite(13, 14981690, false);
addRewrite(14, 8171462, false);
addRewrite(15, 8171462, false);
addRewrite(16, 8171462, false);
addRewrite(17, 5926017, false);
addRewrite(18, 5926017, false);
addRewrite(19, 3035801, false);
addRewrite(20, 3035801, false);
addRewrite(21, 16262179, true);
addRewrite(22, 16262179, true);
addRewrite(23, 4393481, true);
addRewrite(24, 4393481, true);
addRewrite(25, 5149489, false);
addRewrite(26, 5149489, false);
addRewrite(27, 5149489, false);
addRewrite(28, 13458603, false);
addRewrite(29, 13458603, false);
addRewrite(30, 13458603, false);
addRewrite(31, 9643043, false);
addRewrite(32, 9643043, false);
addRewrite(33, 9643043, false);
addRewrite(34, 4738376, false);
addRewrite(35, 4738376, false);
addRewrite(36, 3381504, false);
}
public static Pair<Integer, Boolean> getNewData(int oldData) {
return POTIONS.get(oldData);
}
private static void addRewrite(int oldData, int newData, boolean isInstant) {
POTIONS.put(oldData, new Pair<>(newData, isInstant));
}
}