3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 16:12:43 +01:00

Fix 1.11->1.10 potion splash effect

Dieser Commit ist enthalten in:
KennyTV 2020-02-04 14:53:15 +01:00
Ursprung d9e5f650f1
Commit c560373be3
3 geänderte Dateien mit 58 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -110,8 +110,9 @@ public class EntityTypeNames {
Tag idTag = tag.get("id"); Tag idTag = tag.get("id");
if (idTag instanceof StringTag) { if (idTag instanceof StringTag) {
StringTag id = (StringTag) idTag; StringTag id = (StringTag) idTag;
if (NEW_TO_OLD_NAMES.containsKey(id.getValue())) { String value = NEW_TO_OLD_NAMES.get(id.getValue());
id.setValue(NEW_TO_OLD_NAMES.get(id.getValue())); if (value != null) {
id.setValue(value);
} }
} }
} }
@ -120,7 +121,7 @@ public class EntityTypeNames {
Tag spawnDataTag; Tag spawnDataTag;
if (tag != null && (spawnDataTag = tag.get("SpawnData")) != null) { if (tag != null && (spawnDataTag = tag.get("SpawnData")) != null) {
CompoundTag spawnData = (CompoundTag) spawnDataTag; CompoundTag spawnData = (CompoundTag) spawnDataTag;
if (spawnData != null && spawnData.contains("id")) { if (spawnData != null) {
toClient(spawnData); toClient(spawnData);
} }
} }

Datei anzeigen

@ -0,0 +1,30 @@
package nl.matsv.viabackwards.protocol.protocol1_10to1_11;
import java.util.HashMap;
import java.util.Map;
public class PotionSplashHandler {
private static final Map<Integer, Integer> DATA = new HashMap<>();
static {
DATA.put(2039713, 5); // night vision
DATA.put(8356754, 7); // invisibility
DATA.put(2293580, 9); // jump boost
DATA.put(14981690, 12); // fire resistance
DATA.put(8171462, 14); // swiftness
DATA.put(5926017, 17); // slowness
DATA.put(3035801, 19); // water breathing
DATA.put(16262179, 21); // instant health
DATA.put(4393481, 23); // instant damage
DATA.put(5149489, 25); // poison
DATA.put(13458603, 28); // regeneration
DATA.put(9643043, 31); // strength
DATA.put(4738376, 34); // weakness
DATA.put(3381504, 36); // luck
}
public static Integer getOldData(int data) {
return DATA.get(data);
}
}

Datei anzeigen

@ -15,6 +15,7 @@ import nl.matsv.viabackwards.api.entities.storage.EntityData;
import nl.matsv.viabackwards.api.entities.storage.MetaStorage; import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
import nl.matsv.viabackwards.api.exceptions.RemovedValueException; import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
import nl.matsv.viabackwards.api.rewriters.EntityRewriter; import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.PotionSplashHandler;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11; import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage; import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
import nl.matsv.viabackwards.utils.Block; import nl.matsv.viabackwards.utils.Block;
@ -41,6 +42,29 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
@Override @Override
protected void registerPackets() { protected void registerPackets() {
protocol.registerOutgoing(State.PLAY, 0x21, 0x21, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT);
map(Type.POSITION);
map(Type.INT);
handler(wrapper -> {
int type = wrapper.get(Type.INT, 0);
if (type == 2002 || type == 2007) {
// 2007 potion id doesn't exist in 1.10
if (type == 2007) {
wrapper.set(Type.INT, 0, 2002);
}
Integer mappedData = PotionSplashHandler.getOldData(wrapper.get(Type.INT, 1));
if (mappedData != null) {
wrapper.set(Type.INT, 1, mappedData);
}
}
});
}
});
// Spawn Object // Spawn Object
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
@Override @Override