Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f0bd98be2 | ||
|
|
e325a03c0a | ||
|
|
b9317df859 | ||
|
|
11bb1349e9 | ||
|
|
6289e9317d | ||
|
|
2d9d67bcb2 | ||
|
|
62fd868130 | ||
|
|
b2b8c48fd0 | ||
|
|
9f9d05d3c6 | ||
|
|
6e01a0affd | ||
|
|
d6d6307550 | ||
|
|
1afdf0fb81 | ||
|
|
fd529ce967 | ||
|
|
c5ba1864d1 | ||
|
|
831b8ad5ad | ||
|
|
58256b5b64 | ||
|
|
d209e9b768 | ||
|
|
61b1f0d8a4 | ||
|
|
2748624dde | ||
|
|
d5b19b8869 | ||
|
|
650f89e1ce | ||
|
|
00172ee675 | ||
|
|
45aab8f9f2 | ||
|
|
1e455b0391 | ||
|
|
59cb67da6e | ||
|
|
6b96e1a8e2 | ||
|
|
5ef94d94e6 | ||
|
|
a59c384884 | ||
|
|
7638d678bb | ||
|
|
f3c30130d2 | ||
|
|
bb583065f3 | ||
|
|
f5bb30559d | ||
|
|
87afb84a4d | ||
|
|
07078b21f1 | ||
|
|
63d3dcb31b | ||
|
|
478e663506 | ||
|
|
6bb8ae1dfc | ||
|
|
2cea70e643 | ||
|
|
54de77a110 | ||
|
|
e38cb88640 | ||
|
|
8deeda641a | ||
|
|
f75420a642 | ||
|
|
efd435e908 | ||
|
|
875ffb7f2d | ||
|
|
385ca98125 | ||
|
|
c4630039c4 | ||
|
|
cf6df691d2 | ||
|
|
76dfbe030e | ||
|
|
c7a168d3b3 | ||
|
|
b79bf429f7 | ||
|
|
6e1c482e2d | ||
|
|
b506060e48 | ||
|
|
8294f6af4f |
No files matched your search
@@ -5,7 +5,7 @@ about: Create a bug report so we can fix it
|
||||
---
|
||||
|
||||
**Describe the bug, provide any errors**
|
||||
A clear and concise description of what the bug is. Can you https://hastebin.com the error?
|
||||
A clear and concise description of what the bug is. Can you https://paste.gg/ the error?
|
||||
|
||||
**How can we reproduce it?**
|
||||
Steps to reproduce the behavior:
|
||||
@@ -24,3 +24,8 @@ If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional server info**
|
||||
Do you use a proxy (eg. BungeeCord)? What software do you use and what plugins?
|
||||
|
||||
**Checklist**
|
||||
- [ ] I have included a ViaVersion dump
|
||||
- [ ] If applicable, I have included a paste (not a screenshot) of the error
|
||||
- [ ] I have tried a build from https://ci.viaversion.com/ and the issue still persists
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
Allows older Minecraft versions on a newer Minecraft server
|
||||
|
||||
Supported versions
|
||||
-
|
||||
**Green** = ViaVersion\
|
||||
**Purple** = ViaBackwards addition
|
||||
|
||||

|
||||
|
||||
Releases / Dev Builds
|
||||
-
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-all</artifactId>
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-bukkit</artifactId>
|
||||
@@ -32,7 +32,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-bungee</artifactId>
|
||||
|
||||
@@ -21,7 +21,6 @@ public class BungeePlugin extends Plugin implements ViaBackwardsPlatform {
|
||||
Via.getManager().addEnableListener(() -> this.init(getDataFolder()));
|
||||
}
|
||||
|
||||
// Why is this not a thing in Bungee? O_o
|
||||
@Override
|
||||
public void disable() {
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-core</artifactId>
|
||||
|
||||
@@ -10,7 +10,6 @@ public abstract class BackwardsProtocol<C1 extends ClientboundPacketType, C2 ext
|
||||
extends Protocol<C1, C2, S1, S2> {
|
||||
|
||||
protected BackwardsProtocol() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected BackwardsProtocol(boolean hasMappingDataToLoad) {
|
||||
|
||||
@@ -30,6 +30,8 @@ import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1_14_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_1to1_15_2.Protocol1_15_1To1_15_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15to1_15_1.Protocol1_15To1_15_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16to1_16_1.Protocol1_16To1_16_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
@@ -42,7 +44,7 @@ import static us.myles.ViaVersion.api.protocol.ProtocolRegistry.registerProtocol
|
||||
|
||||
public interface ViaBackwardsPlatform {
|
||||
|
||||
String MINIMUM_VV_VERSION = "3.0.0";
|
||||
String MINIMUM_VV_VERSION = "3.1.0";
|
||||
|
||||
/**
|
||||
* Initialize ViaBackwards.
|
||||
@@ -86,6 +88,8 @@ public interface ViaBackwardsPlatform {
|
||||
registerProtocol(new Protocol1_15_1To1_15_2(), ProtocolVersion.v1_15_1, ProtocolVersion.v1_15_2);
|
||||
|
||||
registerProtocol(new Protocol1_15_2To1_16(), ProtocolVersion.v1_15_2, ProtocolVersion.v1_16);
|
||||
registerProtocol(new Protocol1_16To1_16_1(), ProtocolVersion.v1_16, ProtocolVersion.v1_16_1);
|
||||
registerProtocol(new Protocol1_16_1To1_16_2(), ProtocolVersion.v1_16_1, ProtocolVersion.v1_16_2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +105,7 @@ public interface ViaBackwardsPlatform {
|
||||
getLogger().severe("================================");
|
||||
getLogger().severe("YOUR VIAVERSION IS OUTDATED");
|
||||
getLogger().severe("PLEASE USE VIAVERSION " + MINIMUM_VV_VERSION + " OR NEWER");
|
||||
getLogger().severe("LINK: https://viaversion.com");
|
||||
getLogger().severe("LINK: https://ci.viaversion.com/");
|
||||
getLogger().severe("VIABACKWARDS WILL NOW DISABLE");
|
||||
getLogger().severe("================================");
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public class MappedItem {
|
||||
|
||||
public MappedItem(int id, String name) {
|
||||
this.id = id;
|
||||
this.jsonName = ChatRewriter.legacyTextToJson(ChatColor.RESET + name);
|
||||
this.jsonName = ChatRewriter.legacyTextToJson(ChatColor.RESET + name).toString();
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
|
||||
@@ -16,7 +16,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
public class EntityData {
|
||||
private final int id;
|
||||
private final int replacementId;
|
||||
private String mobName;
|
||||
private Object mobName;
|
||||
private MetaCreator defaultMeta;
|
||||
|
||||
public EntityData(int id, int replacementId) {
|
||||
@@ -47,8 +47,11 @@ public class EntityData {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return custom mobname, can be either a String or a JsonElement
|
||||
*/
|
||||
@Nullable
|
||||
public String getMobName() {
|
||||
public Object getMobName() {
|
||||
return mobName;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class EnchantmentRewriter {
|
||||
Number level = (Number) ((CompoundTag) enchantmentEntry).get("lvl").getValue();
|
||||
String loreValue = enchantmentName + " " + getRomanNumber(level.intValue());
|
||||
if (jsonFormat) {
|
||||
loreValue = ChatRewriter.legacyTextToJson(loreValue);
|
||||
loreValue = ChatRewriter.legacyTextToJson(loreValue).toString();
|
||||
}
|
||||
|
||||
lore.add(new StringTag("", loreValue));
|
||||
|
||||
@@ -193,7 +193,7 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
||||
if (data != null) {
|
||||
EntityData entityData = getEntityData(type);
|
||||
if (entityData != null && entityData.getMobName() != null
|
||||
&& (data.getValue() == null || ((String) data.getValue()).isEmpty())
|
||||
&& (data.getValue() == null || data.getValue().toString().isEmpty())
|
||||
&& data.getMetaType().getTypeID() == displayNameMetaType.getTypeID()) {
|
||||
data.setValue(entityData.getMobName());
|
||||
}
|
||||
@@ -202,35 +202,6 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
||||
return storage;
|
||||
}
|
||||
|
||||
public void registerRespawn(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
clientWorld.setEnvironment(wrapper.get(Type.INT, 0));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerJoinGame(ClientboundPacketType packetType, EntityType playerType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
clientChunks.setEnvironment(wrapper.get(Type.INT, 1));
|
||||
getEntityTracker(wrapper.user()).trackEntityType(wrapper.get(Type.INT, 0), playerType);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to handle player, painting, or xp orb trackers without meta changes.
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,7 @@ import nl.matsv.viabackwards.api.data.MappedItem;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
@@ -33,63 +34,62 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
|
||||
public Item handleItemToClient(Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
CompoundTag tag = null;
|
||||
boolean textChanged = false;
|
||||
CompoundTag display = null;
|
||||
if (translatableRewriter != null
|
||||
&& item.getTag() != null && (tag = item.getTag().get("display")) != null) {
|
||||
&& item.getTag() != null && (display = item.getTag().get("display")) != null) {
|
||||
// Handle name and lore components
|
||||
StringTag name = tag.get("Name");
|
||||
StringTag name = display.get("Name");
|
||||
if (name != null) {
|
||||
String newValue = translatableRewriter.processText(name.getValue());
|
||||
if (name.getValue().equals(newValue)) {
|
||||
textChanged = true;
|
||||
String newValue = translatableRewriter.processText(name.getValue()).toString();
|
||||
if (!newValue.equals(name.getValue())) {
|
||||
saveNameTag(display, name);
|
||||
}
|
||||
|
||||
name.setValue(newValue);
|
||||
}
|
||||
|
||||
ListTag lore = tag.get("Lore");
|
||||
ListTag lore = display.get("Lore");
|
||||
if (lore != null) {
|
||||
for (Tag loreEntry : lore) {
|
||||
if (!(loreEntry instanceof StringTag)) continue;
|
||||
ListTag original = null;
|
||||
boolean changed = false;
|
||||
for (Tag loreEntryTag : lore) {
|
||||
if (!(loreEntryTag instanceof StringTag)) continue;
|
||||
|
||||
StringTag stringTag = (StringTag) loreEntry;
|
||||
String newValue = translatableRewriter.processText(stringTag.getValue());
|
||||
if (stringTag.getValue().equals(newValue)) {
|
||||
textChanged = true;
|
||||
StringTag loreEntry = (StringTag) loreEntryTag;
|
||||
String newValue = translatableRewriter.processText(loreEntry.getValue()).toString();
|
||||
if (!changed && !newValue.equals(loreEntry.getValue())) {
|
||||
changed = true;
|
||||
original = lore.clone();
|
||||
}
|
||||
stringTag.setValue(newValue);
|
||||
|
||||
loreEntry.setValue(newValue);
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
saveLoreTag(display, original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (textChanged) {
|
||||
// Backup data for toServer
|
||||
item.getTag().put(createViaNBT(item));
|
||||
}
|
||||
|
||||
MappedItem data = mappedItemFunction.get(item.getIdentifier());
|
||||
if (data == null) {
|
||||
// Just rewrite the id
|
||||
return super.handleItemToClient(item);
|
||||
}
|
||||
|
||||
// Backup data for toServer if not already done above
|
||||
if (!textChanged) {
|
||||
if (item.getTag() == null) {
|
||||
item.setTag(new CompoundTag(""));
|
||||
}
|
||||
item.getTag().put(createViaNBT(item));
|
||||
}
|
||||
|
||||
// Set remapped id
|
||||
item.setIdentifier(data.getId());
|
||||
|
||||
// Set custom name - only done if there is no original one
|
||||
if (tag == null) {
|
||||
item.getTag().put(tag = new CompoundTag("display"));
|
||||
if (item.getTag() == null) {
|
||||
item.setTag(new CompoundTag(""));
|
||||
}
|
||||
if (!tag.contains("Name")) {
|
||||
tag.put(new StringTag("Name", data.getJsonName()));
|
||||
if (display == null) {
|
||||
item.getTag().put(display = new CompoundTag("display"));
|
||||
}
|
||||
if (!display.contains("Name")) {
|
||||
display.put(new StringTag("Name", data.getJsonName()));
|
||||
display.put(new ByteTag(nbtTagName + "|customName"));
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
|
||||
import us.myles.viaversion.libs.opennbt.conversion.builtin.CompoundTagConverter;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends Rewriter<T> {
|
||||
@@ -42,53 +42,42 @@ public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends Rewr
|
||||
@Nullable
|
||||
public Item handleItemToServer(Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
CompoundTag tag = item.getTag();
|
||||
if (tag == null) {
|
||||
if (toServerRewriter != null) {
|
||||
item.setIdentifier(toServerRewriter.rewrite(item.getIdentifier()));
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
CompoundTag viaTag = tag.remove(nbtTagName);
|
||||
if (viaTag != null) {
|
||||
short id = (short) viaTag.get("id").getValue();
|
||||
item.setIdentifier(id);
|
||||
|
||||
Tag dataTag = viaTag.get("data");
|
||||
short data = dataTag != null ? (short) dataTag.getValue() : 0;
|
||||
item.setData(data);
|
||||
|
||||
Tag amountTag = viaTag.get("amount");
|
||||
byte amount = amountTag != null ? (byte) amountTag.getValue() : 1;
|
||||
item.setAmount(amount);
|
||||
|
||||
CompoundTag extras = viaTag.get("extras");
|
||||
if (extras != null) {
|
||||
item.setTag(CONVERTER.convert("", CONVERTER.convert(extras)));
|
||||
}
|
||||
} else {
|
||||
// Rewrite id normally
|
||||
if (toServerRewriter != null) {
|
||||
item.setIdentifier(toServerRewriter.rewrite(item.getIdentifier()));
|
||||
}
|
||||
if (toServerRewriter != null) {
|
||||
item.setIdentifier(toServerRewriter.rewrite(item.getIdentifier()));
|
||||
}
|
||||
restoreDisplayTag(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
protected CompoundTag createViaNBT(Item item) {
|
||||
CompoundTag tag = new CompoundTag(nbtTagName);
|
||||
tag.put(new ShortTag("id", (short) item.getIdentifier()));
|
||||
if (item.getAmount() != 1) {
|
||||
tag.put(new ByteTag("amount", item.getAmount()));
|
||||
protected void saveNameTag(CompoundTag displayTag, StringTag original) {
|
||||
displayTag.put(new StringTag(nbtTagName + "|o" + original.getName(), original.getValue()));
|
||||
}
|
||||
|
||||
protected void saveLoreTag(CompoundTag displayTag, ListTag original) {
|
||||
displayTag.put(new ListTag(nbtTagName + "|o" + original.getName(), original.getValue()));
|
||||
}
|
||||
|
||||
protected void restoreDisplayTag(Item item) {
|
||||
if (item.getTag() == null) return;
|
||||
|
||||
CompoundTag display = item.getTag().get("display");
|
||||
if (display != null) {
|
||||
// Remove custom name / restore original name
|
||||
if (display.remove(nbtTagName + "|customName") != null) {
|
||||
display.remove("Name");
|
||||
} else {
|
||||
restoreDisplayTag(display, "Name");
|
||||
}
|
||||
|
||||
// Restore lore
|
||||
restoreDisplayTag(display, "Lore");
|
||||
}
|
||||
if (item.getData() != 0) {
|
||||
tag.put(new ShortTag("data", item.getData()));
|
||||
}
|
||||
|
||||
protected void restoreDisplayTag(CompoundTag displayTag, String tagName) {
|
||||
Tag original = displayTag.remove(nbtTagName + "|o" + tagName);
|
||||
if (original != null) {
|
||||
displayTag.put(original);
|
||||
}
|
||||
if (item.getTag() != null) {
|
||||
tag.put(CONVERTER.convert("extras", CONVERTER.convert(item.getTag())));
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
+14
-14
@@ -27,6 +27,7 @@ import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
import us.myles.viaversion.libs.gson.JsonPrimitive;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
@@ -98,14 +99,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
return super.handleItemToClient(item);
|
||||
}
|
||||
|
||||
if (item.getTag() == null) {
|
||||
item.setTag(new CompoundTag(""));
|
||||
}
|
||||
|
||||
// Backup data for toServer
|
||||
short originalData = item.getData();
|
||||
item.getTag().put(createViaNBT(item));
|
||||
|
||||
item.setIdentifier(data.getId());
|
||||
// Keep original data if mapped data is set to -1
|
||||
if (data.getData() != -1) {
|
||||
@@ -114,19 +108,25 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
|
||||
// Set display name
|
||||
if (data.getName() != null) {
|
||||
CompoundTag tag = item.getTag().get("display");
|
||||
if (tag == null) {
|
||||
item.getTag().put(tag = new CompoundTag("display"));
|
||||
if (item.getTag() == null) {
|
||||
item.setTag(new CompoundTag(""));
|
||||
}
|
||||
StringTag nameTag = tag.get("Name");
|
||||
|
||||
CompoundTag display = item.getTag().get("display");
|
||||
if (display == null) {
|
||||
item.getTag().put(display = new CompoundTag("display"));
|
||||
}
|
||||
|
||||
StringTag nameTag = display.get("Name");
|
||||
if (nameTag == null) {
|
||||
tag.put(nameTag = new StringTag("Name", data.getName()));
|
||||
display.put(nameTag = new StringTag("Name", data.getName()));
|
||||
display.put(new ByteTag(nbtTagName + "|customName"));
|
||||
}
|
||||
|
||||
// Handle colors
|
||||
String value = nameTag.getValue();
|
||||
if (value.contains("%vb_color%")) {
|
||||
tag.put(new StringTag("Name", value.replace("%vb_color%", BlockColors.get(originalData))));
|
||||
display.put(new StringTag("Name", value.replace("%vb_color%", BlockColors.get(originalData))));
|
||||
}
|
||||
}
|
||||
return item;
|
||||
@@ -246,7 +246,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
CompoundTag tag = new CompoundTag("");
|
||||
tag.put(new CompoundTag("display"));
|
||||
text = ChatColor.RESET + text;
|
||||
((CompoundTag) tag.get("display")).put(new StringTag("Name", jsonNameFormat ? ChatRewriter.legacyTextToJson(text) : text));
|
||||
((CompoundTag) tag.get("display")).put(new StringTag("Name", jsonNameFormat ? ChatRewriter.legacyTextToJson(text).toString() : text));
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -42,6 +43,35 @@ public abstract class LegacyEntityRewriter<T extends BackwardsProtocol> extends
|
||||
return objectTypes.get(type);
|
||||
}
|
||||
|
||||
protected void registerRespawn(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
clientWorld.setEnvironment(wrapper.get(Type.INT, 0));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void registerJoinGame(ClientboundPacketType packetType, EntityType playerType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
clientChunks.setEnvironment(wrapper.get(Type.INT, 1));
|
||||
getEntityTracker(wrapper.user()).trackEntityType(wrapper.get(Type.INT, 0), playerType);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||
getProtocol().registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package nl.matsv.viabackwards.api.rewriters;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
public abstract class RecipeRewriter {
|
||||
|
||||
protected final ItemRewriterBase rewriter;
|
||||
|
||||
protected RecipeRewriter(ItemRewriterBase rewriter) {
|
||||
this.rewriter = rewriter;
|
||||
}
|
||||
|
||||
public abstract void handle(PacketWrapper wrapper, String type) throws Exception;
|
||||
|
||||
public void registerDefaultHandler(ClientboundPacketType packetType) {
|
||||
rewriter.getProtocol().registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
||||
String id = wrapper.passthrough(Type.STRING); // Recipe Identifier
|
||||
handle(wrapper, type);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -5,20 +5,18 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ComponentRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
import us.myles.viaversion.libs.gson.JsonPrimitive;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TranslatableRewriter {
|
||||
public class TranslatableRewriter extends ComponentRewriter {
|
||||
|
||||
private static final Map<String, Map<String, String>> TRANSLATABLES = new HashMap<>();
|
||||
protected final BackwardsProtocol protocol;
|
||||
protected final Map<String, String> newTranslatables;
|
||||
|
||||
public static void loadTranslatables() {
|
||||
@@ -37,20 +35,21 @@ public class TranslatableRewriter {
|
||||
}
|
||||
|
||||
public TranslatableRewriter(BackwardsProtocol protocol, String sectionIdentifier) {
|
||||
this.protocol = protocol;
|
||||
super(protocol);
|
||||
final Map<String, String> newTranslatables = TRANSLATABLES.get(sectionIdentifier);
|
||||
if (newTranslatables == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Error loading " + sectionIdentifier + " translatables!");
|
||||
this.newTranslatables = new HashMap<>();
|
||||
} else
|
||||
} else {
|
||||
this.newTranslatables = newTranslatables;
|
||||
}
|
||||
}
|
||||
|
||||
public void registerPing() {
|
||||
protocol.registerOutgoing(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))));
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -59,7 +58,7 @@ public class TranslatableRewriter {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))));
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -68,23 +67,7 @@ public class TranslatableRewriter {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerBossBar(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UUID);
|
||||
map(Type.VAR_INT);
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
if (action == 0 || action == 3) {
|
||||
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)));
|
||||
}
|
||||
});
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -95,7 +78,7 @@ public class TranslatableRewriter {
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // Id
|
||||
map(Type.STRING); // Window Type
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))));
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -106,36 +89,7 @@ public class TranslatableRewriter {
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Id
|
||||
map(Type.VAR_INT); // Window Type
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerCombatEvent(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
if (wrapper.passthrough(Type.VAR_INT) == 2) {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerTitle(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.passthrough(Type.VAR_INT);
|
||||
if (action >= 0 && action <= 2) {
|
||||
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)));
|
||||
}
|
||||
});
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -145,84 +99,18 @@ public class TranslatableRewriter {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)));
|
||||
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)));
|
||||
processText(wrapper.passthrough(Type.COMPONENT));
|
||||
processText(wrapper.passthrough(Type.COMPONENT));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String processText(String value) {
|
||||
JsonElement root = GsonUtil.getJsonParser().parse(value);
|
||||
processText(root);
|
||||
return root.toString();
|
||||
}
|
||||
|
||||
protected void processText(JsonElement element) {
|
||||
if (element == null || element.isJsonNull()) return;
|
||||
if (element.isJsonArray()) {
|
||||
processAsArray(element);
|
||||
return;
|
||||
}
|
||||
if (element.isJsonPrimitive()) {
|
||||
handleText(element.getAsJsonPrimitive());
|
||||
return;
|
||||
}
|
||||
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
JsonPrimitive text = object.getAsJsonPrimitive("text");
|
||||
if (text != null) {
|
||||
handleText(text);
|
||||
}
|
||||
|
||||
JsonElement translate = object.get("translate");
|
||||
if (translate != null) {
|
||||
handleTranslate(object, translate.getAsString());
|
||||
|
||||
JsonElement with = object.get("with");
|
||||
if (with != null) {
|
||||
processAsArray(with);
|
||||
}
|
||||
}
|
||||
|
||||
JsonElement extra = object.get("extra");
|
||||
if (extra != null) {
|
||||
processAsArray(extra);
|
||||
}
|
||||
|
||||
JsonObject hoverEvent = object.getAsJsonObject("hoverEvent");
|
||||
if (hoverEvent != null) {
|
||||
handleHoverEvent(hoverEvent);
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleText(JsonPrimitive text) {
|
||||
// In case this is needed in the future
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject root, String translate) {
|
||||
String newTranslate = newTranslatables.get(translate);
|
||||
if (newTranslate != null) {
|
||||
root.addProperty("translate", newTranslate);
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleHoverEvent(JsonObject hoverEvent) {
|
||||
String action = hoverEvent.getAsJsonPrimitive("action").getAsString();
|
||||
if (action.equals("show_text")) {
|
||||
JsonElement value = hoverEvent.get("value");
|
||||
processText(value != null ? value : hoverEvent.get("contents"));
|
||||
} else if (action.equals("show_entity")) {
|
||||
JsonObject contents = hoverEvent.getAsJsonObject("contents");
|
||||
if (contents != null) {
|
||||
processText(contents.get("name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processAsArray(JsonElement element) {
|
||||
for (JsonElement jsonElement : element.getAsJsonArray()) {
|
||||
processText(jsonElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -270,7 +270,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.STRING); // 1 - Window Type
|
||||
map(Type.STRING); // 2 - Title
|
||||
map(Type.COMPONENT); // 2 - Title
|
||||
map(Type.UNSIGNED_BYTE); // 3 - Slots
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@@ -278,8 +278,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = -1;
|
||||
// Passthrough Entity ID
|
||||
if (wrapper.get(Type.STRING, 0).equals("EntityHorse"))
|
||||
if (wrapper.get(Type.STRING, 0).equals("EntityHorse")) {
|
||||
entityId = wrapper.passthrough(Type.INT);
|
||||
}
|
||||
|
||||
// Track Inventory
|
||||
String inventory = wrapper.get(Type.STRING, 0);
|
||||
@@ -288,8 +289,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
windowTracker.setEntityId(entityId);
|
||||
|
||||
// Change llama slotcount to the donkey one
|
||||
if (isLlama(wrapper.user()))
|
||||
if (isLlama(wrapper.user())) {
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 1, (short) 17);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+1
-3
@@ -297,9 +297,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11>
|
||||
Metadata data = e.getData();
|
||||
data.setId(13);
|
||||
data.setMetaType(MetaType1_9.VarInt);
|
||||
|
||||
data.setValue((int) data.getValue() == 1 ? 2 : 4);
|
||||
|
||||
data.setValue(((Number) data.getValue()).intValue() == 1 ? 2 : 4);
|
||||
return data;
|
||||
});
|
||||
|
||||
|
||||
+3
-5
@@ -16,9 +16,9 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
|
||||
public class PlayerPackets1_11 {
|
||||
private static final ValueTransformer<Short, Float> TO_NEW_FLOAT = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||
@@ -43,10 +43,8 @@ public class PlayerPackets1_11 {
|
||||
if (action == 2) {
|
||||
// Convert to the old actionbar way
|
||||
PacketWrapper actionbar = new PacketWrapper(0x0F, null, wrapper.user()); // Chat Message packet
|
||||
String msg = wrapper.read(Type.STRING);
|
||||
msg = ChatRewriter.jsonTextToLegacy(msg);
|
||||
msg = "{\"text\":\"" + msg + "\"}";
|
||||
actionbar.write(Type.STRING, msg);
|
||||
JsonElement msg = wrapper.read(Type.COMPONENT);
|
||||
actionbar.write(Type.COMPONENT, msg);
|
||||
actionbar.write(Type.BYTE, (byte) 2); // Above hotbar
|
||||
|
||||
actionbar.send(Protocol1_10To1_11.class);
|
||||
|
||||
+17
@@ -18,11 +18,15 @@ import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets.ChatPackets1_
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets.EntityPackets1_12;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets.SoundPackets1_12;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
|
||||
public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_12, ClientboundPackets1_9_3, ServerboundPackets1_12, ServerboundPackets1_9_3> {
|
||||
|
||||
@@ -40,6 +44,19 @@ public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_
|
||||
new SoundPackets1_12(this).register();
|
||||
new ChatPackets1_12(this).register();
|
||||
|
||||
registerOutgoing(ClientboundPackets1_12.TITLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.passthrough(Type.VAR_INT);
|
||||
if (action >= 0 && action <= 2) {
|
||||
JsonElement component = wrapper.read(Type.COMPONENT);
|
||||
wrapper.write(Type.COMPONENT, Protocol1_9To1_8.fixJson(component.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
cancelOutgoing(ClientboundPackets1_12.ADVANCEMENTS);
|
||||
cancelOutgoing(ClientboundPackets1_12.UNLOCK_RECIPES);
|
||||
cancelOutgoing(ClientboundPackets1_12.SELECT_ADVANCEMENTS_TAB);
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ public class ShoulderTracker extends StoredObject {
|
||||
public void update() {
|
||||
PacketWrapper wrapper = new PacketWrapper(0x0F, null, getUser());
|
||||
|
||||
wrapper.write(Type.STRING, Protocol1_9To1_8.fixJson(generateString()));
|
||||
wrapper.write(Type.COMPONENT, Protocol1_9To1_8.fixJson(generateString()));
|
||||
wrapper.write(Type.BYTE, (byte) 2);
|
||||
|
||||
try {
|
||||
|
||||
+2
-2
@@ -57,8 +57,8 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
if (columns <= 0) return;
|
||||
|
||||
short rows = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
wrapper.passthrough(Type.BYTE); //X
|
||||
wrapper.passthrough(Type.BYTE); //Z
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // X
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Z
|
||||
byte[] data = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
short color = (short) (data[i] & 0xFF);
|
||||
|
||||
+13
-64
@@ -10,22 +10,28 @@
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.AdvancementTranslations;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ComponentRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ChatPackets1_12 extends Rewriter<Protocol1_11_1To1_12> {
|
||||
|
||||
private final ComponentRewriter componentRewriter = new ComponentRewriter() {
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject object, String translate) {
|
||||
String text = AdvancementTranslations.get(translate);
|
||||
if (text != null) {
|
||||
object.addProperty("translate", text);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public ChatPackets1_12(Protocol1_11_1To1_12 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
@@ -35,68 +41,11 @@ public class ChatPackets1_12 extends Rewriter<Protocol1_11_1To1_12> {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.CHAT_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Json Data
|
||||
map(Type.BYTE); // 1 - Position
|
||||
|
||||
handler(wrapper -> {
|
||||
try {
|
||||
JsonObject object = GsonUtil.getJsonParser().parse(wrapper.get(Type.STRING, 0)).getAsJsonObject();
|
||||
// Skip if the root doesn't contain translate
|
||||
if (object.has("translate")) {
|
||||
handleTranslations(object);
|
||||
}
|
||||
|
||||
ChatItemRewriter.toClient(object, wrapper.user());
|
||||
wrapper.set(Type.STRING, 0, object.toString());
|
||||
} catch (Exception e) {
|
||||
// Only print if ViaVer debug is enabled
|
||||
if (Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().severe("Failed to handle translations");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
JsonElement element = wrapper.passthrough(Type.COMPONENT);
|
||||
componentRewriter.processText(element);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// improve this, not copying will cause ConcurrentModificationException
|
||||
public void handleTranslations(JsonObject object) {
|
||||
JsonObject copiedObj = copy(object);
|
||||
|
||||
if (object.isJsonObject()) {
|
||||
for (Map.Entry<String, JsonElement> entry : copiedObj.entrySet()) {
|
||||
// Get the text that doesn't exist for 1.11 <
|
||||
|
||||
if (entry.getKey().equalsIgnoreCase("translate")) {
|
||||
String translate = entry.getValue().getAsString();
|
||||
String text = AdvancementTranslations.get(translate);
|
||||
if (text != null) {
|
||||
object.addProperty("translate", text);
|
||||
}
|
||||
}
|
||||
// Handle arrays
|
||||
if (entry.getValue().isJsonArray())
|
||||
for (JsonElement element : object.get(entry.getKey()).getAsJsonArray())
|
||||
if (element.isJsonObject())
|
||||
handleTranslations(element.getAsJsonObject());
|
||||
|
||||
// Handle objects
|
||||
if (entry.getValue().isJsonObject())
|
||||
handleTranslations(object.get(entry.getKey()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JsonObject copy(JsonObject object) {
|
||||
JsonObject result = new JsonObject();
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
if (entry.getValue().isJsonObject())
|
||||
result.add(entry.getKey(), copy(entry.getValue().getAsJsonObject()));
|
||||
else
|
||||
result.add(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+10
-2
@@ -39,9 +39,13 @@ public class ParticleMapping {
|
||||
|
||||
int type = blockType >> 4;
|
||||
int meta = blockType & 15;
|
||||
|
||||
return new int[]{type + (meta << 12)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockHandler() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
particles = new ParticleData[]{
|
||||
@@ -148,11 +152,15 @@ public class ParticleMapping {
|
||||
return new ParticleData(replacementId, handler);
|
||||
}
|
||||
|
||||
interface ParticleHandler {
|
||||
public interface ParticleHandler {
|
||||
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception;
|
||||
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data);
|
||||
|
||||
default boolean isBlockHandler() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class ParticleData {
|
||||
|
||||
+7
-7
@@ -246,9 +246,9 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
int chunkZ = wrapper.get(Type.INT, 1);
|
||||
int block = record.getBlockId();
|
||||
Position position = new Position(
|
||||
(record.getHorizontal() >> 4 & 15) + (chunkX * 16),
|
||||
record.getSectionX() + (chunkX * 16),
|
||||
record.getY(),
|
||||
(record.getHorizontal() & 15) + (chunkZ * 16));
|
||||
record.getSectionZ() + (chunkZ * 16));
|
||||
|
||||
// Store if needed
|
||||
storage.checkAndStore(position, block);
|
||||
@@ -441,7 +441,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
byte z = wrapper.read(Type.BYTE);
|
||||
byte direction = wrapper.read(Type.BYTE);
|
||||
if (wrapper.read(Type.BOOLEAN)) {
|
||||
wrapper.read(Type.STRING);
|
||||
wrapper.read(Type.COMPONENT);
|
||||
}
|
||||
if (type > 9) {
|
||||
wrapper.set(Type.VAR_INT, 1, wrapper.get(Type.VAR_INT, 1) - 1);
|
||||
@@ -592,8 +592,8 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
if (display != null) {
|
||||
StringTag name = display.get("Name");
|
||||
if (name instanceof StringTag) {
|
||||
StringTag via = display.remove(extraNbtTag + "|Name");
|
||||
name.setValue(via != null ? via.getValue() : ChatRewriter.jsonTextToLegacy(name.getValue()));
|
||||
display.put(new StringTag(extraNbtTag + "|Name", name.getValue()));
|
||||
name.setValue(ChatRewriter.jsonTextToLegacy(name.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -788,8 +788,8 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
CompoundTag displayTag = (CompoundTag) display;
|
||||
StringTag name = displayTag.get("Name");
|
||||
if (name instanceof StringTag) {
|
||||
displayTag.put(new StringTag(extraNbtTag + "|Name", name.getValue()));
|
||||
name.setValue(ChatRewriter.legacyTextToJson(name.getValue()));
|
||||
StringTag via = displayTag.remove(extraNbtTag + "|Name");
|
||||
name.setValue(via != null ? via.getValue() : ChatRewriter.legacyTextToJson(name.getValue()).toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -323,7 +323,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
// Rewrite Custom Name from Chat to String
|
||||
registerMetaHandler().filter(Entity1_13Types.EntityType.ENTITY, true, 2).handle(e -> {
|
||||
Metadata meta = e.getData();
|
||||
String value = (String) meta.getValue();
|
||||
String value = meta.getValue().toString();
|
||||
if (value.isEmpty()) return meta;
|
||||
meta.setValue(ChatRewriter.jsonTextToLegacy(value));
|
||||
return meta;
|
||||
@@ -382,6 +382,11 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
int secondArg = 0;
|
||||
int[] particleArgs = data.rewriteMeta(protocol, particle.getArguments());
|
||||
if (particleArgs != null && particleArgs.length != 0) {
|
||||
if (data.getHandler().isBlockHandler() && particleArgs[0] == 0) {
|
||||
// Air doesn't have a break particle for sub 1.13 clients -> glass pane
|
||||
particleArgs[0] = 102;
|
||||
}
|
||||
|
||||
firstArg = particleArgs[0];
|
||||
secondArg = particleArgs.length == 2 ? particleArgs[1] : 0;
|
||||
}
|
||||
|
||||
+26
-11
@@ -21,6 +21,7 @@ import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
@@ -138,8 +139,15 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
|
||||
int[] data = old.rewriteData(protocol, wrapper);
|
||||
if (data != null) {
|
||||
for (int i : data)
|
||||
if (old.getHandler().isBlockHandler() && data[0] == 0) {
|
||||
// Cancel air block particles
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i : data) {
|
||||
wrapper.write(Type.VAR_INT, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -171,7 +179,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
packetWrapper.passthrough(Type.COMPONENT);
|
||||
}
|
||||
} else if (action == 1) { // Update Game Mode
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
@@ -179,7 +187,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
} else if (action == 3) { // Update Display Name
|
||||
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
packetWrapper.passthrough(Type.COMPONENT);
|
||||
}
|
||||
} else if (action == 4) { // Remove Player
|
||||
storage.usernames.remove(uuid);
|
||||
@@ -200,9 +208,12 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
byte mode = wrapper.get(Type.BYTE, 0);
|
||||
if (mode == 0 || mode == 2) {
|
||||
String value = wrapper.read(Type.STRING);
|
||||
String value = wrapper.read(Type.COMPONENT).toString();
|
||||
value = ChatRewriter.jsonTextToLegacy(value);
|
||||
if (value.length() > 32) value = value.substring(0, 32);
|
||||
if (value.length() > 32) {
|
||||
value = value.substring(0, 32);
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, value);
|
||||
int type = wrapper.read(Type.VAR_INT);
|
||||
wrapper.write(Type.STRING, type == 1 ? "hearts" : "integer");
|
||||
@@ -225,7 +236,9 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
String displayName = wrapper.read(Type.STRING);
|
||||
displayName = ChatRewriter.jsonTextToLegacy(displayName);
|
||||
displayName = ChatUtil.removeUnusedColor(displayName, 'f');
|
||||
if (displayName.length() > 32) displayName = displayName.substring(0, 32);
|
||||
if (displayName.length() > 32) {
|
||||
displayName = displayName.substring(0, 32);
|
||||
}
|
||||
wrapper.write(Type.STRING, displayName);
|
||||
|
||||
byte flags = wrapper.read(Type.BYTE);
|
||||
@@ -237,9 +250,10 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
colour = -1;
|
||||
}
|
||||
|
||||
String prefix = wrapper.read(Type.STRING);
|
||||
String suffix = wrapper.read(Type.STRING);
|
||||
prefix = prefix == null || prefix.equals("null") ? "" : ChatRewriter.jsonTextToLegacy(prefix);
|
||||
JsonElement prefixComponent = wrapper.read(Type.COMPONENT);
|
||||
JsonElement suffixComponent = wrapper.read(Type.COMPONENT);
|
||||
|
||||
String prefix = prefixComponent == null || prefixComponent.isJsonNull() ? "" : ChatRewriter.jsonTextToLegacy(prefixComponent.toString());
|
||||
if (ViaBackwards.getConfig().addTeamColorTo1_13Prefix()) {
|
||||
prefix += "§" + (colour > -1 && colour <= 15 ? Integer.toHexString(colour) : "r");
|
||||
}
|
||||
@@ -248,10 +262,11 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
if (prefix.length() > 16) prefix = prefix.substring(0, 16);
|
||||
if (prefix.endsWith("§")) prefix = prefix.substring(0, prefix.length() - 1);
|
||||
|
||||
suffix = suffix == null || suffix.equals("null") ? "" : ChatRewriter.jsonTextToLegacy(suffix);
|
||||
suffix = ChatUtil.removeUnusedColor(suffix, 'f');
|
||||
String suffix = suffixComponent == null || suffixComponent.isJsonNull() ? "" : ChatRewriter.jsonTextToLegacy(suffixComponent.toString());
|
||||
suffix = ChatUtil.removeUnusedColor(suffix, '\0'); // Don't remove white coloring
|
||||
if (suffix.length() > 16) suffix = suffix.substring(0, 16);
|
||||
if (suffix.endsWith("§")) suffix = suffix.substring(0, suffix.length() - 1);
|
||||
|
||||
wrapper.write(Type.STRING, prefix);
|
||||
wrapper.write(Type.STRING, suffix);
|
||||
|
||||
|
||||
+2
-2
@@ -49,8 +49,8 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol<ClientboundPackets
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
wrapper.passthrough(Type.COMPONENT); // Title
|
||||
wrapper.passthrough(Type.COMPONENT); // Description
|
||||
Item icon = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
wrapper.write(Type.FLAT_ITEM, icon);
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
|
||||
-41
@@ -56,47 +56,6 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
cancelOutgoing(ClientboundPackets1_14.UPDATE_VIEW_DISTANCE);
|
||||
cancelOutgoing(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||
|
||||
registerOutgoing(ClientboundPackets1_14.ADVANCEMENTS, new PacketRemapper() { // c
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN))
|
||||
wrapper.passthrough(Type.STRING);
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
blockItemPackets.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_14.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.ItemRewriterBase;
|
||||
import nl.matsv.viabackwards.api.rewriters.RecipeRewriter;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
public class RecipeRewriter1_14 extends RecipeRewriter {
|
||||
|
||||
public RecipeRewriter1_14(ItemRewriterBase rewriter) {
|
||||
super(rewriter);
|
||||
}
|
||||
|
||||
public void handle(PacketWrapper wrapper, String type) throws Exception {
|
||||
switch (type) {
|
||||
case "crafting_shapeless":
|
||||
handleCraftingShapeless(wrapper);
|
||||
break;
|
||||
case "crafting_shaped":
|
||||
handleCraftingShaped(wrapper);
|
||||
break;
|
||||
case "smelting":
|
||||
handleSmelting(wrapper);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleSmelting(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) {
|
||||
rewriter.handleItemToClient(item);
|
||||
}
|
||||
|
||||
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
}
|
||||
|
||||
public void handleCraftingShaped(PacketWrapper wrapper) throws Exception {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) {
|
||||
rewriter.handleItemToClient(item);
|
||||
}
|
||||
}
|
||||
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
|
||||
public void handleCraftingShapeless(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) {
|
||||
rewriter.handleItemToClient(item);
|
||||
}
|
||||
}
|
||||
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
}
|
||||
+21
-20
@@ -4,11 +4,9 @@ import com.google.common.collect.ImmutableSet;
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.EnchantmentRewriter;
|
||||
import nl.matsv.viabackwards.api.rewriters.RecipeRewriter;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.RecipeRewriter1_14;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
@@ -24,17 +22,19 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.BlockRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.RecipeRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.RecipeRewriter1_13_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
import us.myles.viaversion.libs.opennbt.conversion.ConverterRegistry;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
@@ -137,19 +137,19 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
|
||||
wrapper.write(Type.STRING, stringType);
|
||||
|
||||
String title = wrapper.read(Type.STRING);
|
||||
JsonElement title = wrapper.read(Type.COMPONENT);
|
||||
if (containerTitle != null) {
|
||||
// Don't rewrite renamed, only translatable titles
|
||||
JsonObject object = GsonUtil.getGson().fromJson(title, JsonObject.class);
|
||||
if (object.has("translate")) {
|
||||
JsonObject object;
|
||||
if (title.isJsonObject() && (object = title.getAsJsonObject()).has("translate")) {
|
||||
// Don't rewrite other 9x3 translatable containers
|
||||
if (type != 2 || object.getAsJsonPrimitive("translate").getAsString().equals("container.barrel")) {
|
||||
title = ChatRewriter.legacyTextToJson(containerTitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
wrapper.write(Type.STRING, title);
|
||||
|
||||
wrapper.write(Type.COMPONENT, title);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) slotSize);
|
||||
}
|
||||
});
|
||||
@@ -165,7 +165,9 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Window id
|
||||
wrapper.write(Type.STRING, "EntityHorse"); // Type
|
||||
wrapper.write(Type.STRING, "{\"translate\":\"minecraft.horse\"}"); // Title
|
||||
JsonObject object = new JsonObject();
|
||||
object.addProperty("translate", "minecraft.horse");
|
||||
wrapper.write(Type.COMPONENT, object); // Title
|
||||
wrapper.write(Type.UNSIGNED_BYTE, wrapper.read(Type.VAR_INT).shortValue()); // Number of slots
|
||||
wrapper.passthrough(Type.INT); // Entity id
|
||||
}
|
||||
@@ -179,6 +181,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_14.COOLDOWN, BlockItemPackets1_14::getOldItemId);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_14.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerAdvancements(ClientboundPackets1_14.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
// Trade List -> Plugin Message
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.TRADE_LIST, ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@@ -280,12 +283,12 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() { // c
|
||||
RecipeRewriter recipeHandler = new RecipeRewriter1_13_2(protocol, this::handleItemToClient);
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
private final Set<String> removedTypes = ImmutableSet.of("crafting_special_suspiciousstew", "blasting", "smoking", "campfire_cooking", "stonecutting");
|
||||
private final RecipeRewriter recipeHandler = new RecipeRewriter1_14(BlockItemPackets1_14.this);
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
@@ -413,7 +416,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.read(new Chunk1_14Type(clientWorld));
|
||||
Chunk chunk = wrapper.read(new Chunk1_14Type());
|
||||
wrapper.write(new Chunk1_13Type(clientWorld), chunk);
|
||||
|
||||
ChunkLightStorage.ChunkLight chunkLight = wrapper.user().get(ChunkLightStorage.class).getStoredLight(chunk.getX(), chunk.getZ());
|
||||
@@ -535,21 +538,19 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
CompoundTag display = tag.get("display");
|
||||
if (((CompoundTag) tag.get("display")).get("Lore") instanceof ListTag) {
|
||||
ListTag lore = display.get("Lore");
|
||||
ListTag via = display.get(nbtTagName + "|Lore");
|
||||
ListTag via = display.remove(nbtTagName + "|Lore");
|
||||
if (via != null) {
|
||||
display.put(ConverterRegistry.convertToTag("Lore", ConverterRegistry.convertToValue(via)));
|
||||
} else {
|
||||
for (Tag loreEntry : lore) {
|
||||
if (loreEntry instanceof StringTag) {
|
||||
((StringTag) loreEntry).setValue(
|
||||
ChatRewriter.jsonTextToLegacy(
|
||||
((StringTag) loreEntry).getValue()
|
||||
)
|
||||
);
|
||||
if (!(loreEntry instanceof StringTag)) continue;
|
||||
|
||||
String value = ((StringTag) loreEntry).getValue();
|
||||
if (value != null && !value.isEmpty()) {
|
||||
((StringTag) loreEntry).setValue(ChatRewriter.jsonTextToLegacy(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
display.remove(nbtTagName + "|Lore");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,7 +574,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
display.put(ConverterRegistry.convertToTag(nbtTagName + "|Lore", ConverterRegistry.convertToValue(lore)));
|
||||
for (Tag loreEntry : lore) {
|
||||
if (loreEntry instanceof StringTag) {
|
||||
((StringTag) loreEntry).setValue(ChatRewriter.legacyTextToJson(((StringTag) loreEntry).getValue()));
|
||||
((StringTag) loreEntry).setValue(ChatRewriter.legacyTextToJson(((StringTag) loreEntry).getValue()).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-29
@@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.rewriters.TagRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
@@ -103,7 +104,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
if (action == 0 || action == 3) {
|
||||
wrapper.write(Type.STRING, translatableRewriter.processText(wrapper.read(Type.STRING)));
|
||||
translatableRewriter.processText(wrapper.passthrough(Type.COMPONENT));
|
||||
if (action == 0) {
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
@@ -136,8 +137,8 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
wrapper.passthrough(Type.COMPONENT); // Title
|
||||
wrapper.passthrough(Type.COMPONENT); // Description
|
||||
Item icon = wrapper.passthrough(Type.FLAT_ITEM);
|
||||
InventoryPackets1_13_1.toClient(icon);
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
@@ -160,32 +161,8 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_13.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int blockTagsSize = wrapper.passthrough(Type.VAR_INT); // block tags
|
||||
for (int i = 0; i < blockTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
int[] blocks = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
for (int j = 0; j < blocks.length; j++) {
|
||||
blocks[j] = getNewBlockId(blocks[j]);
|
||||
}
|
||||
}
|
||||
int itemTagsSize = wrapper.passthrough(Type.VAR_INT); // item tags
|
||||
for (int i = 0; i < itemTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
int[] items = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
for (int j = 0; j < items.length; j++) {
|
||||
items[j] = InventoryPackets1_13_1.getOldItemId(items[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
new TagRewriter(this, Protocol1_13To1_13_1::getNewBlockId,
|
||||
InventoryPackets1_13_1::getOldItemId, null).register(ClientboundPackets1_13.TAGS);
|
||||
}
|
||||
|
||||
public static int getNewBlockStateId(int blockId) {
|
||||
|
||||
-4
@@ -5,8 +5,4 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
|
||||
public class Protocol1_14_1To1_14_2 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
public Protocol1_14_1To1_14_2() {
|
||||
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
}
|
||||
+19
-64
@@ -4,9 +4,11 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.RecipeRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
|
||||
|
||||
public class Protocol1_14_2To1_14_3 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
@@ -47,77 +49,30 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol<ClientboundPackets
|
||||
}
|
||||
});
|
||||
|
||||
RecipeRewriter recipeHandler = new RecipeRewriter1_14(this, item -> {});
|
||||
registerOutgoing(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
int deleted = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
String fullType = wrapper.read(Type.STRING);
|
||||
String type = fullType.replace("minecraft:", "");
|
||||
String id = wrapper.read(Type.STRING); // id
|
||||
handler(wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
int deleted = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
String fullType = wrapper.read(Type.STRING);
|
||||
String type = fullType.replace("minecraft:", "");
|
||||
String id = wrapper.read(Type.STRING); // id
|
||||
|
||||
if (type.equals("crafting_special_repairitem")) {
|
||||
deleted++;
|
||||
continue;
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, fullType);
|
||||
wrapper.write(Type.STRING, id);
|
||||
|
||||
switch (type) {
|
||||
case "crafting_shapeless": {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
}
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
|
||||
|
||||
break;
|
||||
}
|
||||
case "crafting_shaped": {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
}
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
|
||||
|
||||
break;
|
||||
}
|
||||
case "stonecutting":
|
||||
wrapper.passthrough(Type.STRING); // Group?
|
||||
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); // Result
|
||||
|
||||
break;
|
||||
case "smelting":
|
||||
case "blasting":
|
||||
case "campfire_cooking":
|
||||
case "smoking":
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
|
||||
break;
|
||||
}
|
||||
if (type.equals("crafting_special_repairitem")) {
|
||||
deleted++;
|
||||
continue;
|
||||
}
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, size - deleted);
|
||||
wrapper.write(Type.STRING, fullType);
|
||||
wrapper.write(Type.STRING, id);
|
||||
|
||||
recipeHandler.handle(wrapper, type);
|
||||
}
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, size - deleted);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+7
-91
@@ -12,16 +12,14 @@ import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets.BlockItemPack
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets.EntityPackets1_15;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.TagRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_15, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
@@ -80,89 +78,8 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_15.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
}
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
blockItemPackets.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0) {
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
}
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_15.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int blockTagsSize = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < blockTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
int[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
for (int j = 0; j < blockIds.length; j++) {
|
||||
int id = blockIds[j];
|
||||
blockIds[j] = BackwardsMappings.blockMappings.getNewId(id);
|
||||
}
|
||||
}
|
||||
|
||||
int itemTagsSize = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < itemTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
for (int j = 0; j < itemIds.length; j++) {
|
||||
int oldId = MappingData.oldToNewItems.inverse().get(itemIds[j]);
|
||||
itemIds[j] = oldId;
|
||||
}
|
||||
}
|
||||
|
||||
int fluidTagsSize = wrapper.passthrough(Type.VAR_INT); // fluid tags
|
||||
for (int i = 0; i < fluidTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
}
|
||||
|
||||
int entityTagsSize = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < entityTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
int[] entityIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
for (int j = 0; j < entityIds.length; j++) {
|
||||
entityIds[j] = EntityTypeMapping.getOldEntityId(entityIds[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id),
|
||||
id -> MappingData.oldToNewItems.inverse().get(id), EntityTypeMapping::getOldEntityId).register(ClientboundPackets1_15.TAGS);
|
||||
}
|
||||
|
||||
public static int getNewBlockStateId(int id) {
|
||||
@@ -174,7 +91,6 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
|
||||
return newId;
|
||||
}
|
||||
|
||||
|
||||
public static int getNewBlockId(int id) {
|
||||
int newId = BackwardsMappings.blockMappings.getNewId(id);
|
||||
if (newId == -1) {
|
||||
@@ -186,12 +102,12 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
if (!user.has(ClientWorld.class))
|
||||
user.put(new ClientWorld(user));
|
||||
if (!user.has(ImmediateRespawn.class))
|
||||
if (!user.has(ImmediateRespawn.class)) {
|
||||
user.put(new ImmediateRespawn(user));
|
||||
if (!user.has(EntityTracker.class))
|
||||
}
|
||||
if (!user.has(EntityTracker.class)) {
|
||||
user.put(new EntityTracker(user));
|
||||
}
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
}
|
||||
|
||||
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.ItemRewriterBase;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.RecipeRewriter1_14;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
public class RecipeRewriter1_15 extends RecipeRewriter1_14 {
|
||||
|
||||
public RecipeRewriter1_15(ItemRewriterBase rewriter) {
|
||||
super(rewriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper, String type) throws Exception {
|
||||
switch (type) {
|
||||
case "crafting_shapeless":
|
||||
handleCraftingShapeless(wrapper);
|
||||
break;
|
||||
case "crafting_shaped":
|
||||
handleCraftingShaped(wrapper);
|
||||
break;
|
||||
case "blasting": // new
|
||||
case "smoking": // new
|
||||
case "campfire_cooking": // new
|
||||
case "smelting":
|
||||
handleSmelting(wrapper);
|
||||
break;
|
||||
case "stonecutting": // new
|
||||
handleStonecutting(wrapper);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleStonecutting(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) {
|
||||
rewriter.handleItemToClient(item);
|
||||
}
|
||||
|
||||
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
}
|
||||
+6
-46
@@ -5,7 +5,6 @@ import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ParticleMapping;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.RecipeRewriter1_15;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
@@ -16,11 +15,11 @@ import us.myles.ViaVersion.api.rewriters.BlockRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.ItemRewriter<Protocol1_14_4To1_15> {
|
||||
|
||||
@@ -33,7 +32,7 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_14_4To1_15::getNewBlockStateId, Protocol1_14_4To1_15::getNewBlockId);
|
||||
|
||||
new RecipeRewriter1_15(this).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES);
|
||||
new RecipeRewriter1_14(protocol, this::handleItemToClient).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES);
|
||||
|
||||
protocol.registerIncoming(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
@@ -45,47 +44,9 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_15.COOLDOWN, BlockItemPackets1_15::getOldItemId);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.TRADE_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
Item input = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
handleItemToClient(input);
|
||||
|
||||
Item output = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
handleItemToClient(output);
|
||||
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item
|
||||
// Second Item
|
||||
Item second = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
handleItemToClient(second);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerTradeList(ClientboundPackets1_15.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_15.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerAdvancements(ClientboundPackets1_15.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
@@ -100,9 +61,8 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.read(new Chunk1_15Type(clientWorld));
|
||||
wrapper.write(new Chunk1_14Type(clientWorld), chunk);
|
||||
Chunk chunk = wrapper.read(new Chunk1_15Type());
|
||||
wrapper.write(new Chunk1_14Type(), chunk);
|
||||
|
||||
if (chunk.isFullChunk()) {
|
||||
int[] biomeData = chunk.getBiomeData();
|
||||
|
||||
-2
@@ -91,7 +91,6 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
map(Type.LONG, Type.NOTHING); // Seed
|
||||
handler(getDimensionHandler(0));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -110,7 +109,6 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
map(Type.BOOLEAN); // 6 - Reduce Debug Info
|
||||
|
||||
handler(getTrackerHandler(Entity1_15Types.EntityType.PLAYER, Type.INT));
|
||||
handler(getDimensionHandler(1));
|
||||
|
||||
handler(wrapper -> wrapper.user().get(ImmediateRespawn.class).setImmediateRespawn(wrapper.read(Type.BOOLEAN)));
|
||||
}
|
||||
|
||||
-5
@@ -1,13 +1,8 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_15_1to1_15_2;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
|
||||
public class Protocol1_15_1To1_15_2 extends BackwardsProtocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
public Protocol1_15_1To1_15_2() {
|
||||
super(ClientboundPackets1_15.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
}
|
||||
+2
-38
@@ -53,7 +53,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
registerOutgoing(ClientboundPackets1_16.CHAT_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, translatableRewriter.processText(wrapper.read(Type.STRING))));
|
||||
handler(wrapper -> translatableRewriter.processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
map(Type.BYTE);
|
||||
map(Type.UUID, Type.NOTHING); // Sender
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Window Id
|
||||
map(Type.VAR_INT); // Window Type
|
||||
handler(wrapper -> wrapper.write(Type.STRING, translatableRewriter.processText(wrapper.read(Type.STRING))));
|
||||
handler(wrapper -> translatableRewriter.processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
handler(wrapper -> {
|
||||
int windowType = wrapper.get(Type.VAR_INT, 1);
|
||||
if (windowType == 20) { // Smithing table
|
||||
@@ -95,42 +95,6 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_16.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
}
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
blockItemPackets.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0) {
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
}
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_16.STATISTICS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
||||
+10
-7
@@ -31,7 +31,7 @@ public class TranslatableRewriter1_16 extends TranslatableRewriter {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
protected void processText(JsonElement value) {
|
||||
public void processText(JsonElement value) {
|
||||
super.processText(value);
|
||||
if (!value.isJsonObject()) return;
|
||||
|
||||
@@ -98,13 +98,16 @@ public class TranslatableRewriter1_16 extends TranslatableRewriter {
|
||||
}
|
||||
|
||||
// Check by the greatest diff of the 3 values
|
||||
int rDiff = Math.abs(color.r - r);
|
||||
int gDiff = Math.abs(color.g - g);
|
||||
int bDiff = Math.abs(color.b - b);
|
||||
int maxDiff = Math.max(Math.max(rDiff, gDiff), bDiff);
|
||||
if (closest == null || maxDiff < smallestDiff) {
|
||||
int rAverage = (color.r + r) / 2;
|
||||
int rDiff = color.r - r;
|
||||
int gDiff = color.g - g;
|
||||
int bDiff = color.b - b;
|
||||
int diff = ((2 + (rAverage >> 8)) * rDiff * rDiff)
|
||||
+ (4 * gDiff * gDiff)
|
||||
+ ((2 + ((255 - rAverage) >> 8)) * bDiff * bDiff);
|
||||
if (closest == null || diff < smallestDiff) {
|
||||
closest = color;
|
||||
smallestDiff = maxDiff;
|
||||
smallestDiff = diff;
|
||||
}
|
||||
}
|
||||
return closest.colorName;
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data;
|
||||
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
|
||||
public class MapColorRewriter {
|
||||
|
||||
private static final Int2IntMap MAPPINGS = new Int2IntOpenHashMap();
|
||||
|
||||
static {
|
||||
MAPPINGS.put(208, 113);
|
||||
MAPPINGS.put(209, 114);
|
||||
MAPPINGS.put(210, 114);
|
||||
MAPPINGS.put(211, 112);
|
||||
MAPPINGS.put(212, 152);
|
||||
MAPPINGS.put(213, 83);
|
||||
MAPPINGS.put(214, 83);
|
||||
MAPPINGS.put(215, 155);
|
||||
MAPPINGS.put(216, 143);
|
||||
MAPPINGS.put(217, 115);
|
||||
MAPPINGS.put(218, 115);
|
||||
MAPPINGS.put(219, 143);
|
||||
MAPPINGS.put(220, 127);
|
||||
MAPPINGS.put(221, 127);
|
||||
MAPPINGS.put(222, 127);
|
||||
MAPPINGS.put(223, 95);
|
||||
MAPPINGS.put(224, 127);
|
||||
MAPPINGS.put(225, 127);
|
||||
MAPPINGS.put(226, 124);
|
||||
MAPPINGS.put(227, 95);
|
||||
MAPPINGS.put(228, 187);
|
||||
MAPPINGS.put(229, 155);
|
||||
MAPPINGS.put(230, 184);
|
||||
MAPPINGS.put(231, 187);
|
||||
MAPPINGS.put(232, 127);
|
||||
MAPPINGS.put(233, 124);
|
||||
MAPPINGS.put(234, 125);
|
||||
MAPPINGS.put(235, 127);
|
||||
}
|
||||
|
||||
public static int getMappedColor(int color) {
|
||||
return MAPPINGS.getOrDefault(color, -1);
|
||||
}
|
||||
}
|
||||
-84
@@ -1,84 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.ItemRewriterBase;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.RecipeRewriter1_15;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
public class RecipeRewriter1_16 extends RecipeRewriter1_15 {
|
||||
|
||||
public RecipeRewriter1_16(ItemRewriterBase rewriter) {
|
||||
super(rewriter);
|
||||
}
|
||||
|
||||
public void register(ClientboundPacketType packetType) {
|
||||
// Remove new smithing type, only in this handler
|
||||
rewriter.getProtocol().registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
int newSize = size;
|
||||
for (int i = 0; i < size; i++) {
|
||||
String originalType = wrapper.read(Type.STRING);
|
||||
String type = originalType.replace("minecraft:", "");
|
||||
if (type.equals("smithing")) {
|
||||
newSize--;
|
||||
|
||||
wrapper.read(Type.STRING);
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
continue;
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, originalType);
|
||||
String id = wrapper.passthrough(Type.STRING); // Recipe Identifier
|
||||
handle(wrapper, type);
|
||||
}
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, newSize);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper, String type) throws Exception {
|
||||
switch (type) {
|
||||
case "crafting_shapeless":
|
||||
handleCraftingShapeless(wrapper);
|
||||
break;
|
||||
case "crafting_shaped":
|
||||
handleCraftingShaped(wrapper);
|
||||
break;
|
||||
case "blasting":
|
||||
case "smoking":
|
||||
case "campfire_cooking":
|
||||
case "smelting":
|
||||
handleSmelting(wrapper);
|
||||
break;
|
||||
case "stonecutting":
|
||||
handleStonecutting(wrapper);
|
||||
break;
|
||||
case "smithing": // new
|
||||
handleSmithing(wrapper);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleSmithing(PacketWrapper wrapper) throws Exception {
|
||||
Item[] baseIngredients = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
for (Item item : baseIngredients) {
|
||||
rewriter.handleItemToClient(item);
|
||||
}
|
||||
Item[] ingredients = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
for (Item item : ingredients) {
|
||||
rewriter.handleItemToClient(item);
|
||||
}
|
||||
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
}
|
||||
+120
-66
@@ -5,8 +5,9 @@ import nl.matsv.viabackwards.api.rewriters.EnchantmentRewriter;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.RecipeRewriter1_16;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.MapColorRewriter;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
@@ -16,12 +17,13 @@ import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.UUIDIntArrayType;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.InventoryPackets;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.ViaVersion.util.CompactArrayUtil;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
|
||||
@@ -47,47 +49,42 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_15_2To1_16::getNewBlockStateId, Protocol1_15_2To1_16::getNewBlockId);
|
||||
|
||||
new RecipeRewriter1_16(this).register(ClientboundPackets1_16.DECLARE_RECIPES);
|
||||
RecipeRewriter1_14 recipeRewriter = new RecipeRewriter1_14(protocol, this::handleItemToClient);
|
||||
// Remove new smithing type, only in this handler
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
int newSize = size;
|
||||
for (int i = 0; i < size; i++) {
|
||||
String originalType = wrapper.read(Type.STRING);
|
||||
String type = originalType.replace("minecraft:", "");
|
||||
if (type.equals("smithing")) {
|
||||
newSize--;
|
||||
|
||||
wrapper.read(Type.STRING);
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
continue;
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, originalType);
|
||||
String id = wrapper.passthrough(Type.STRING); // Recipe Identifier
|
||||
recipeRewriter.handle(wrapper, type);
|
||||
}
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, newSize);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_16.COOLDOWN, BlockItemPackets1_16::getOldItemId);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.TRADE_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
Item input = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
handleItemToClient(input);
|
||||
|
||||
Item output = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
handleItemToClient(output);
|
||||
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item
|
||||
// Second Item
|
||||
Item second = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
handleItemToClient(second);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
});
|
||||
}
|
||||
});
|
||||
itemRewriter.registerTradeList(ClientboundPackets1_16.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerAdvancements(ClientboundPackets1_16.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_16.BLOCK_ACTION);
|
||||
@@ -140,9 +137,8 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.read(new Chunk1_16Type(clientWorld));
|
||||
wrapper.write(new Chunk1_15Type(clientWorld), chunk);
|
||||
Chunk chunk = wrapper.read(new Chunk1_16Type());
|
||||
wrapper.write(new Chunk1_15Type(), chunk);
|
||||
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
@@ -177,36 +173,14 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
|
||||
if (chunk.getBlockEntities() == null) return;
|
||||
for (CompoundTag blockEntity : chunk.getBlockEntities()) {
|
||||
String id = ((StringTag) blockEntity.get("id")).getValue();
|
||||
if (id.equals("minecraft:conduit")) {
|
||||
IntArrayTag targetUuidTag = blockEntity.remove("Target");
|
||||
if (targetUuidTag == null) continue;
|
||||
|
||||
// Target -> target_uuid
|
||||
UUID targetUuid = UUIDIntArrayType.uuidFromIntArray(targetUuidTag.getValue());
|
||||
blockEntity.put(new StringTag("target_uuid", targetUuid.toString()));
|
||||
} else if (id.equals("minecraft:skull") && blockEntity.get("SkullOwner") instanceof CompoundTag) {
|
||||
CompoundTag skullOwnerTag = blockEntity.remove("SkullOwner");
|
||||
IntArrayTag ownerUuidTag = skullOwnerTag.remove("Id");
|
||||
if (ownerUuidTag != null) {
|
||||
UUID ownerUuid = UUIDIntArrayType.uuidFromIntArray(ownerUuidTag.getValue());
|
||||
skullOwnerTag.put(new StringTag("Id", ownerUuid.toString()));
|
||||
}
|
||||
|
||||
// SkullOwner -> Owner
|
||||
CompoundTag ownerTag = new CompoundTag("Owner");
|
||||
for (Tag tag : skullOwnerTag) {
|
||||
ownerTag.put(tag);
|
||||
}
|
||||
blockEntity.put(ownerTag);
|
||||
}
|
||||
handleBlockEntity(blockEntity);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerEffect(ClientboundPackets1_16.EFFECT, 1010, 2001, BlockItemPackets1_16::getOldItemId);
|
||||
blockRewriter.registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, 3, 23, 32,
|
||||
blockRewriter.registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, 3, 23, 34,
|
||||
BlockItemPackets1_16::getNewParticleId, this::handleItemToClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.WINDOW_PROPERTY, new PacketRemapper() {
|
||||
@@ -229,6 +203,55 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.MAP_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Map ID
|
||||
map(Type.BYTE); // Scale
|
||||
map(Type.BOOLEAN); // Tracking Position
|
||||
map(Type.BOOLEAN); // Locked
|
||||
handler(wrapper -> {
|
||||
int iconCount = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < iconCount; i++) {
|
||||
wrapper.passthrough(Type.VAR_INT); // Type
|
||||
wrapper.passthrough(Type.BYTE); // X
|
||||
wrapper.passthrough(Type.BYTE); // Z
|
||||
wrapper.passthrough(Type.BYTE); // Direction
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.COMPONENT); // Display Name
|
||||
}
|
||||
}
|
||||
|
||||
short columns = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
if (columns < 1) return;
|
||||
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Rows
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // X
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Z
|
||||
byte[] data = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
int color = data[i] & 0xFF;
|
||||
int mappedColor = MapColorRewriter.getMappedColor(color);
|
||||
if (mappedColor != -1) {
|
||||
data[i] = (byte) mappedColor;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
Position position = wrapper.passthrough(Type.POSITION1_14);
|
||||
short action = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
CompoundTag tag = wrapper.passthrough(Type.NBT);
|
||||
handleBlockEntity(tag);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
@@ -240,6 +263,35 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
});
|
||||
}
|
||||
|
||||
private void handleBlockEntity(CompoundTag tag) {
|
||||
String id = ((StringTag) tag.get("id")).getValue();
|
||||
if (id.equals("minecraft:conduit")) {
|
||||
Tag targetUuidTag = tag.remove("Target");
|
||||
if (!(targetUuidTag instanceof IntArrayTag)) return;
|
||||
|
||||
// Target -> target_uuid
|
||||
UUID targetUuid = UUIDIntArrayType.uuidFromIntArray((int[]) targetUuidTag.getValue());
|
||||
tag.put(new StringTag("target_uuid", targetUuid.toString()));
|
||||
} else if (id.equals("minecraft:skull")) {
|
||||
Tag skullOwnerTag = tag.remove("SkullOwner");
|
||||
if (!(skullOwnerTag instanceof CompoundTag)) return;
|
||||
|
||||
CompoundTag skullOwnerCompoundTag = (CompoundTag) skullOwnerTag;
|
||||
Tag ownerUuidTag = skullOwnerCompoundTag.remove("Id");
|
||||
if (ownerUuidTag instanceof IntArrayTag) {
|
||||
UUID ownerUuid = UUIDIntArrayType.uuidFromIntArray((int[]) ownerUuidTag.getValue());
|
||||
skullOwnerCompoundTag.put(new StringTag("Id", ownerUuid.toString()));
|
||||
}
|
||||
|
||||
// SkullOwner -> Owner
|
||||
CompoundTag ownerTag = new CompoundTag("Owner");
|
||||
for (Tag t : skullOwnerCompoundTag) {
|
||||
ownerTag.put(t);
|
||||
}
|
||||
tag.put(ownerTag);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNewParticleId(int id) {
|
||||
switch (id) {
|
||||
case 27: // soul flame -> flame
|
||||
@@ -290,6 +342,7 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
}
|
||||
|
||||
InventoryPackets.newToOldAttributes(item);
|
||||
enchantmentRewriter.handleToClient(item);
|
||||
return item;
|
||||
}
|
||||
@@ -314,6 +367,7 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
}
|
||||
|
||||
InventoryPackets.oldToNewAttributes(item);
|
||||
enchantmentRewriter.handleToServer(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
+56
-3
@@ -17,8 +17,10 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.Particle;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
|
||||
public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
|
||||
@@ -56,7 +58,19 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
map(Type.BYTE, Type.NOTHING); // Previous gamemode
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
clientWorld.setEnvironment(wrapper.get(Type.INT, 0));
|
||||
int dimension = wrapper.get(Type.INT, 0);
|
||||
|
||||
// Send a dummy respawn with a different dimension if the previous one is equal to the new
|
||||
if (clientWorld.getEnvironment() != null && dimension == clientWorld.getEnvironment().getId()) {
|
||||
PacketWrapper packet = wrapper.create(ClientboundPackets1_15.RESPAWN.ordinal());
|
||||
packet.write(Type.INT, dimension == 0 ? -1 : 0);
|
||||
packet.write(Type.LONG, 0L);
|
||||
packet.write(Type.UNSIGNED_BYTE, (short) 0);
|
||||
packet.write(Type.STRING, "default");
|
||||
packet.send(Protocol1_15_2To1_16.class, true, true);
|
||||
}
|
||||
|
||||
clientWorld.setEnvironment(dimension);
|
||||
|
||||
wrapper.write(Type.STRING, "default"); // Level type
|
||||
wrapper.read(Type.BOOLEAN); // Debug
|
||||
@@ -128,6 +142,45 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.PLAYER_INFO, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(packetWrapper -> {
|
||||
int action = packetWrapper.passthrough(Type.VAR_INT);
|
||||
int playerCount = packetWrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < playerCount; i++) {
|
||||
packetWrapper.passthrough(Type.UUID);
|
||||
if (action == 0) { // Add
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
int properties = packetWrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < properties; j++) {
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
}
|
||||
}
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||
// Display Name
|
||||
protocol.getTranslatableRewriter().processText(packetWrapper.passthrough(Type.COMPONENT));
|
||||
}
|
||||
} else if (action == 1) { // Update Game Mode
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
} else if (action == 2) { // Update Ping
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
} else if (action == 3) { // Update Display Name
|
||||
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||
// Display name
|
||||
protocol.getTranslatableRewriter().processText(packetWrapper.passthrough(Type.COMPONENT));
|
||||
}
|
||||
} // 4 = Remove Player
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,9 +196,9 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
Particle particle = (Particle) meta.getValue();
|
||||
particle.setId(ParticleMapping.getOldId(particle.getId()));
|
||||
} else if (type == MetaType1_14.OptChat) {
|
||||
String text = meta.getCastedValue();
|
||||
JsonElement text = meta.getCastedValue();
|
||||
if (text != null) {
|
||||
meta.setValue(protocol.getTranslatableRewriter().processText(text));
|
||||
protocol.getTranslatableRewriter().processText(text);
|
||||
}
|
||||
}
|
||||
return meta;
|
||||
|
||||
-5
@@ -1,13 +1,8 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_15to1_15_1;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
|
||||
public class Protocol1_15To1_15_1 extends BackwardsProtocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
public Protocol1_15To1_15_1() {
|
||||
super(ClientboundPackets1_15.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets.BlockItemPackets1_16_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets.EntityPackets1_16_2;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.TagRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||
|
||||
public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets1_16_2, ClientboundPackets1_16, ServerboundPackets1_16_2, ServerboundPackets1_16> {
|
||||
|
||||
private BlockItemPackets1_16_2 blockItemPackets;
|
||||
private TranslatableRewriter translatableRewriter;
|
||||
|
||||
public Protocol1_16_1To1_16_2() {
|
||||
super(ClientboundPackets1_16_2.class, ClientboundPackets1_16.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_16_2To1_16_1.class, BackwardsMappings::init);
|
||||
|
||||
translatableRewriter = new TranslatableRewriter(this);
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_16_2.BOSSBAR);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_16_2.COMBAT_EVENT);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_16_2.DISCONNECT);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_16_2.TAB_LIST);
|
||||
translatableRewriter.registerTitle(ClientboundPackets1_16_2.TITLE);
|
||||
translatableRewriter.registerChatMessage(ClientboundPackets1_16_2.CHAT_MESSAGE);
|
||||
translatableRewriter.registerOpenWindow(ClientboundPackets1_16_2.OPEN_WINDOW);
|
||||
translatableRewriter.registerPing();
|
||||
|
||||
(blockItemPackets = new BlockItemPackets1_16_2(this, translatableRewriter)).register();
|
||||
EntityPackets1_16_2 entityPackets = new EntityPackets1_16_2(this);
|
||||
entityPackets.register();
|
||||
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this,
|
||||
id -> BackwardsMappings.soundMappings.getNewId(id), stringId -> BackwardsMappings.soundMappings.getNewId(stringId));
|
||||
soundRewriter.registerSound(ClientboundPackets1_16_2.SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_16_2.ENTITY_SOUND);
|
||||
soundRewriter.registerNamedSound(ClientboundPackets1_16_2.NAMED_SOUND);
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_16_2.STOP_SOUND);
|
||||
|
||||
// Recipe book data has been split into 2 separate packets
|
||||
registerIncoming(ServerboundPackets1_16.RECIPE_BOOK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int type = wrapper.read(Type.VAR_INT);
|
||||
if (type == 0) {
|
||||
// Shown, change to its own packet
|
||||
wrapper.passthrough(Type.STRING); // Recipe
|
||||
wrapper.setId(ServerboundPackets1_16_2.SEEN_RECIPE.ordinal());
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
|
||||
// Settings
|
||||
for (int i = 0; i < 3; i++) {
|
||||
sendSeenRecipePacket(i, wrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendSeenRecipePacket(int recipeType, PacketWrapper wrapper) throws Exception {
|
||||
boolean open = wrapper.read(Type.BOOLEAN);
|
||||
boolean filter = wrapper.read(Type.BOOLEAN);
|
||||
|
||||
PacketWrapper newPacket = wrapper.create(ServerboundPackets1_16_2.RECIPE_BOOK_DATA.ordinal());
|
||||
newPacket.write(Type.VAR_INT, recipeType);
|
||||
newPacket.write(Type.BOOLEAN, open);
|
||||
newPacket.write(Type.BOOLEAN, filter);
|
||||
newPacket.sendToServer(Protocol1_16_1To1_16_2.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
|
||||
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_16_2.TAGS);
|
||||
}
|
||||
|
||||
public static int getNewBlockStateId(int id) {
|
||||
int newId = BackwardsMappings.blockStateMappings.getNewId(id);
|
||||
if (newId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16 blockstate id for 1.16.2 block " + id);
|
||||
return 0;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
public static int getNewBlockId(int id) {
|
||||
int newId = BackwardsMappings.blockMappings.getNewId(id);
|
||||
if (newId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16 block id for 1.16.2 block " + id);
|
||||
return id;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
if (!user.has(EntityTracker.class)) {
|
||||
user.put(new EntityTracker(user));
|
||||
}
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
}
|
||||
|
||||
public BlockItemPackets1_16_2 getBlockItemPackets() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
|
||||
public TranslatableRewriter getTranslatableRewriter() {
|
||||
return translatableRewriter;
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.data;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.data.VBItemMappings;
|
||||
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
|
||||
import nl.matsv.viabackwards.api.data.VBMappings;
|
||||
import nl.matsv.viabackwards.api.data.VBSoundMappings;
|
||||
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
||||
import us.myles.ViaVersion.api.data.Mappings;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
public class BackwardsMappings {
|
||||
public static Mappings blockStateMappings;
|
||||
public static Mappings blockMappings;
|
||||
public static VBSoundMappings soundMappings;
|
||||
public static VBItemMappings itemMappings;
|
||||
|
||||
public static void init() {
|
||||
ViaBackwards.getPlatform().getLogger().info("Loading 1.16.2 -> 1.16.1 mappings...");
|
||||
JsonObject mapping1_16 = MappingDataLoader.getMappingsCache().get("mapping-1.16.json");
|
||||
JsonObject mapping1_16_2 = MappingDataLoader.getMappingsCache().get("mapping-1.16.2.json");
|
||||
JsonObject mapping1_16to1_16_2 = VBMappingDataLoader.loadFromDataDir("mapping-1.16to1.16.2.json");
|
||||
|
||||
blockStateMappings = new VBMappings(mapping1_16_2.getAsJsonObject("blockstates"), mapping1_16.getAsJsonObject("blockstates"), mapping1_16to1_16_2.getAsJsonObject("blockstates"));
|
||||
blockMappings = new VBMappings(mapping1_16_2.getAsJsonObject("blocks"), mapping1_16.getAsJsonObject("blocks"), mapping1_16to1_16_2.getAsJsonObject("blocks"), false);
|
||||
itemMappings = new VBItemMappings(mapping1_16_2.getAsJsonObject("items"), mapping1_16.getAsJsonObject("items"), mapping1_16to1_16_2.getAsJsonObject("items"));
|
||||
soundMappings = new VBSoundMappings(mapping1_16_2.getAsJsonArray("sounds"), mapping1_16.getAsJsonArray("sounds"), mapping1_16to1_16_2.getAsJsonObject("sounds"));
|
||||
}
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.data.BackwardsMappings;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord1_8;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.BlockRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
||||
|
||||
public class BlockItemPackets1_16_2 extends nl.matsv.viabackwards.api.rewriters.ItemRewriter<Protocol1_16_1To1_16_2> {
|
||||
|
||||
public BlockItemPackets1_16_2(Protocol1_16_1To1_16_2 protocol, TranslatableRewriter translatableRewriter) {
|
||||
super(protocol, translatableRewriter,
|
||||
BlockItemPackets1_16_2::getOldItemId, BlockItemPackets1_16_2::getNewItemId, id -> BackwardsMappings.itemMappings.getMappedItem(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_16_1To1_16_2::getNewBlockStateId, Protocol1_16_1To1_16_2::getNewBlockId);
|
||||
|
||||
new RecipeRewriter1_16(protocol, this::handleItemToClient).registerDefaultHandler(ClientboundPackets1_16_2.DECLARE_RECIPES);
|
||||
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_16_2.COOLDOWN, BlockItemPackets1_16_2::getOldItemId);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_16_2.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_16_2.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerEntityEquipmentArray(ClientboundPackets1_16_2.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerTradeList(ClientboundPackets1_16_2.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerAdvancements(ClientboundPackets1_16_2.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.UNLOCK_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.BOOLEAN); // Open
|
||||
wrapper.passthrough(Type.BOOLEAN); // Filter
|
||||
wrapper.passthrough(Type.BOOLEAN); // Furnace Open
|
||||
wrapper.passthrough(Type.BOOLEAN); // Filter furnace
|
||||
// Blast furnace / smoker
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16_2.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_16_2.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_16_2.BLOCK_CHANGE);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
Chunk chunk = wrapper.read(new Chunk1_16_2Type());
|
||||
wrapper.write(new Chunk1_16Type(), chunk);
|
||||
|
||||
chunk.setIgnoreOldLightData(true);
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null) continue;
|
||||
for (int j = 0; j < section.getPaletteSize(); j++) {
|
||||
int old = section.getPaletteEntry(j);
|
||||
section.setPaletteEntry(j, Protocol1_16_1To1_16_2.getNewBlockStateId(old));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.cancel();
|
||||
long chunkPosition = wrapper.read(Type.LONG);
|
||||
wrapper.read(Type.BOOLEAN); // Ignore old light data
|
||||
|
||||
int chunkX = (int) (chunkPosition >> 42);
|
||||
int chunkY = (int) (chunkPosition << 44 >> 44);
|
||||
int chunkZ = (int) (chunkPosition << 22 >> 42);
|
||||
wrapper.write(Type.INT, chunkX);
|
||||
wrapper.write(Type.INT, chunkZ);
|
||||
|
||||
BlockChangeRecord[] blockChangeRecord = wrapper.read(Type.VAR_LONG_BLOCK_CHANGE_RECORD_ARRAY);
|
||||
wrapper.write(Type.BLOCK_CHANGE_RECORD_ARRAY, blockChangeRecord);
|
||||
for (int i = 0; i < blockChangeRecord.length; i++) {
|
||||
BlockChangeRecord record = blockChangeRecord[i];
|
||||
int blockId = Protocol1_16_1To1_16_2.getNewBlockStateId(record.getBlockId());
|
||||
// Relative y -> absolute y
|
||||
blockChangeRecord[i] = new BlockChangeRecord1_8(record.getSectionX(), record.getY(chunkY), record.getSectionZ(), blockId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerEffect(ClientboundPackets1_16_2.EFFECT, 1010, 2001, BlockItemPackets1_16_2::getOldItemId);
|
||||
blockRewriter.registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, 3, 23, 34,
|
||||
null, this::handleItemToClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
|
||||
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
protocol.registerIncoming(ServerboundPackets1_16.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static int getNewItemId(int id) {
|
||||
int newId = MappingData.oldToNewItems.get(id);
|
||||
if (newId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16.2 item for 1.16 item " + id);
|
||||
return 1;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
public static int getOldItemId(int id) {
|
||||
int oldId = MappingData.oldToNewItems.inverse().get(id);
|
||||
if (oldId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16 item for 1.16.2 item " + id);
|
||||
return 1;
|
||||
}
|
||||
return oldId;
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_16Types;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_16_2Types;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.EntityPackets;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class EntityPackets1_16_2 extends EntityRewriter<Protocol1_16_1To1_16_2> {
|
||||
|
||||
private final Set<String> oldDimensions = Sets.newHashSet("minecraft:overworld", "minecraft:the_nether", "minecraft:the_end");
|
||||
|
||||
public EntityPackets1_16_2(Protocol1_16_1To1_16_2 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerSpawnTrackerWithData(ClientboundPackets1_16_2.SPAWN_ENTITY, Entity1_16_2Types.EntityType.FALLING_BLOCK, Protocol1_16_1To1_16_2::getNewBlockStateId);
|
||||
registerSpawnTracker(ClientboundPackets1_16_2.SPAWN_MOB);
|
||||
registerExtraTracker(ClientboundPackets1_16_2.SPAWN_EXPERIENCE_ORB, Entity1_16_2Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_16_2.SPAWN_PAINTING, Entity1_16_2Types.EntityType.PAINTING);
|
||||
registerExtraTracker(ClientboundPackets1_16_2.SPAWN_PLAYER, Entity1_16_2Types.EntityType.PLAYER);
|
||||
registerEntityDestroy(ClientboundPackets1_16_2.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_16_2.ENTITY_METADATA, Types1_14.METADATA_LIST);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // Entity ID
|
||||
handler(wrapper -> {
|
||||
boolean hardcore = wrapper.read(Type.BOOLEAN);
|
||||
short gamemode = wrapper.read(Type.UNSIGNED_BYTE);
|
||||
if (hardcore) {
|
||||
gamemode |= 0x08;
|
||||
}
|
||||
wrapper.write(Type.UNSIGNED_BYTE, gamemode);
|
||||
});
|
||||
map(Type.BYTE); // Previous Gamemode
|
||||
map(Type.STRING_ARRAY); // World List
|
||||
handler(wrapper -> {
|
||||
// Just screw the registry and write the defaults for 1.16 and 1.16.1 clients
|
||||
wrapper.read(Type.NBT);
|
||||
wrapper.write(Type.NBT, EntityPackets.DIMENSIONS_TAG);
|
||||
|
||||
CompoundTag dimensionData = wrapper.read(Type.NBT);
|
||||
wrapper.write(Type.STRING, getDimensionFromData(dimensionData));
|
||||
});
|
||||
map(Type.STRING); // Dimension
|
||||
map(Type.LONG); // Seed
|
||||
handler(wrapper -> {
|
||||
int maxPlayers = wrapper.read(Type.VAR_INT);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) Math.max(maxPlayers, 255));
|
||||
});
|
||||
// ...
|
||||
handler(getTrackerHandler(Entity1_16_2Types.EntityType.PLAYER, Type.INT));
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
CompoundTag dimensionData = wrapper.read(Type.NBT);
|
||||
wrapper.write(Type.STRING, getDimensionFromData(dimensionData));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getDimensionFromData(CompoundTag dimensionData) {
|
||||
// This may technically break other custom dimension settings for 1.16/1.16.1 clients, so those cases are considered semi "unsupported" here
|
||||
StringTag effectsLocation = dimensionData.get("effects");
|
||||
return effectsLocation != null && oldDimensions.contains(effectsLocation.getValue()) ? effectsLocation.getValue() : "minecraft:overworld";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
registerMetaHandler().handle(e -> {
|
||||
Metadata meta = e.getData();
|
||||
MetaType type = meta.getMetaType();
|
||||
if (type == MetaType1_14.Slot) {
|
||||
meta.setValue(protocol.getBlockItemPackets().handleItemToClient((Item) meta.getValue()));
|
||||
} else if (type == MetaType1_14.BlockID) {
|
||||
meta.setValue(Protocol1_16_1To1_16_2.getNewBlockStateId((int) meta.getValue()));
|
||||
} else if (type == MetaType1_14.OptChat) {
|
||||
JsonElement text = meta.getCastedValue();
|
||||
if (text != null) {
|
||||
protocol.getTranslatableRewriter().processText(text);
|
||||
}
|
||||
}
|
||||
return meta;
|
||||
});
|
||||
|
||||
mapTypes(Entity1_16_2Types.EntityType.values(), Entity1_16Types.EntityType.class);
|
||||
mapEntity(Entity1_16_2Types.EntityType.PIGLIN_BRUTE, Entity1_16_2Types.EntityType.PIGLIN).jsonName("Piglin Brute");
|
||||
|
||||
registerMetaHandler().filter(Entity1_16_2Types.EntityType.ABSTRACT_PIGLIN, true).handle(meta -> {
|
||||
if (meta.getIndex() == 15) {
|
||||
meta.getData().setId(16);
|
||||
} else if (meta.getIndex() == 16) {
|
||||
meta.getData().setId(15);
|
||||
}
|
||||
return meta.getData();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getTypeFromId(int typeId) {
|
||||
return Entity1_16Types.getTypeFromId(typeId);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16to1_16_1;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||
|
||||
public class Protocol1_16To1_16_1 extends BackwardsProtocol<ClientboundPackets1_16, ClientboundPackets1_16, ServerboundPackets1_16, ServerboundPackets1_16> {
|
||||
}
|
||||
@@ -12,6 +12,7 @@ public class ChatUtil {
|
||||
|
||||
public static String removeUnusedColor(String legacy, char defaultColor, boolean isPrefix) {
|
||||
if (legacy == null) return null;
|
||||
|
||||
Pattern pattern = isPrefix ? UNUSED_COLOR_PATTERN_PREFIX : UNUSED_COLOR_PATTERN;
|
||||
legacy = pattern.matcher(legacy).replaceAll("$1$2");
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@@ -22,10 +23,12 @@ public class ChatUtil {
|
||||
builder.append(current);
|
||||
continue;
|
||||
}
|
||||
|
||||
current = legacy.charAt(++i);
|
||||
if (current == last) continue;
|
||||
builder.append('§').append(current);
|
||||
last = current;
|
||||
if (current != last) {
|
||||
builder.append('§').append(current);
|
||||
last = current;
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -5864,39 +5864,39 @@
|
||||
"name": "1.16 Netherite Scrap"
|
||||
},
|
||||
"minecraft:netherite_sword": {
|
||||
"id": "minecraft:iron_sword",
|
||||
"id": "minecraft:diamond_sword",
|
||||
"name": "1.16 Netherite Sword"
|
||||
},
|
||||
"minecraft:netherite_shovel": {
|
||||
"id": "minecraft:iron_shovel",
|
||||
"id": "minecraft:diamond_shovel",
|
||||
"name": "1.16 Netherite Shovel"
|
||||
},
|
||||
"minecraft:netherite_pickaxe": {
|
||||
"id": "minecraft:iron_pickaxe",
|
||||
"id": "minecraft:diamond_pickaxe",
|
||||
"name": "1.16 Netherite Pickaxe"
|
||||
},
|
||||
"minecraft:netherite_axe": {
|
||||
"id": "minecraft:iron_axe",
|
||||
"id": "minecraft:diamond_axe",
|
||||
"name": "1.16 Netherite Axe"
|
||||
},
|
||||
"minecraft:netherite_hoe": {
|
||||
"id": "minecraft:iron_hoe",
|
||||
"id": "minecraft:diamond_hoe",
|
||||
"name": "1.16 Netherite Hoe"
|
||||
},
|
||||
"minecraft:netherite_helmet": {
|
||||
"id": "minecraft:chainmail_helmet",
|
||||
"id": "minecraft:diamond_helmet",
|
||||
"name": "1.16 Netherite Helmet"
|
||||
},
|
||||
"minecraft:netherite_chestplate": {
|
||||
"id": "minecraft:chainmail_chestplate",
|
||||
"id": "minecraft:diamond_chestplate",
|
||||
"name": "1.16 Netherite Chestplate"
|
||||
},
|
||||
"minecraft:netherite_leggings": {
|
||||
"id": "minecraft:chainmail_leggings",
|
||||
"id": "minecraft:diamond_leggings",
|
||||
"name": "1.16 Netherite Leggings"
|
||||
},
|
||||
"minecraft:netherite_boots": {
|
||||
"id": "minecraft:chainmail_boots",
|
||||
"id": "minecraft:diamond_boots",
|
||||
"name": "1.16 Netherite Boots"
|
||||
},
|
||||
"minecraft:crying_obsidian": {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"blockstates": {
|
||||
"minecraft:lantern[hanging=true,waterlogged=true]": "minecraft:lantern[hanging=true]",
|
||||
"minecraft:lantern[hanging=true,waterlogged=false]": "minecraft:lantern[hanging=true]",
|
||||
"minecraft:lantern[hanging=false,waterlogged=true]": "minecraft:lantern[hanging=false]",
|
||||
"minecraft:lantern[hanging=false,waterlogged=false]": "minecraft:lantern[hanging=false]",
|
||||
"minecraft:soul_lantern[hanging=true,waterlogged=true]": "minecraft:soul_lantern[hanging=true]",
|
||||
"minecraft:soul_lantern[hanging=true,waterlogged=false]": "minecraft:soul_lantern[hanging=true]",
|
||||
"minecraft:soul_lantern[hanging=false,waterlogged=true]": "minecraft:soul_lantern[hanging=false]",
|
||||
"minecraft:soul_lantern[hanging=false,waterlogged=false]": "minecraft:soul_lantern[hanging=false]",
|
||||
"minecraft:chain[axis=x,waterlogged=true]": "minecraft:chain[waterlogged=true]",
|
||||
"minecraft:chain[axis=x,waterlogged=false]": "minecraft:chain[waterlogged=true]",
|
||||
"minecraft:chain[axis=y,waterlogged=true]": "minecraft:chain[waterlogged=true]",
|
||||
"minecraft:chain[axis=y,waterlogged=false]": "minecraft:chain[waterlogged=true]",
|
||||
"minecraft:chain[axis=z,waterlogged=true]": "minecraft:chain[waterlogged=true]",
|
||||
"minecraft:chain[axis=z,waterlogged=false]": "minecraft:chain[waterlogged=true]"
|
||||
},
|
||||
"items": {
|
||||
"minecraft:piglin_brute_spawn_egg": {
|
||||
"id": "minecraft:piglin_spawn_egg",
|
||||
"name": "1.16.2 Piglin Brute Spawn Egg"
|
||||
}
|
||||
},
|
||||
"sounds": {
|
||||
"entity.parrot.imitate.piglin_brute": "entity.parrot.imitate.piglin",
|
||||
"entity.piglin_brute.ambient": "entity.piglin.ambient",
|
||||
"entity.piglin_brute.angry": "entity.piglin.angry",
|
||||
"entity.piglin_brute.death": "entity.piglin.death",
|
||||
"entity.piglin_brute.hurt": "entity.piglin.hurt",
|
||||
"entity.piglin_brute.step": "entity.piglin.step",
|
||||
"entity.piglin_brute.converted_to_zombified": "entity.piglin.converted_to_zombified"
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,44 @@
|
||||
{
|
||||
"1.16.2": {
|
||||
"multiplayer.disconnect.missing_tags": "Incomplete set of tags received from server.\nPlease contact server operator.",
|
||||
"chat.square_brackets": "[%s]",
|
||||
"disconnect.exceeded_packet_rate": "Kicked for exceeding packet rate limit",
|
||||
"item.minecraft.piglin_brute_spawn_egg": "Piglin Brute Spawn Egg",
|
||||
"entity.minecraft.piglin_brute": "Piglin Brute",
|
||||
"potion.withAmplifier": "%s %s",
|
||||
"potion.withDuration": "%s (%s)",
|
||||
"advancements.sad_label": ":(",
|
||||
"subtitles.entity.parrot.imitate.piglin_brute": "Parrot snorts mightily",
|
||||
"subtitles.entity.piglin_brute.ambient": "Piglin Brute snorts",
|
||||
"subtitles.entity.piglin_brute.angry": "Piglin Brute snorts angrily",
|
||||
"subtitles.entity.piglin_brute.death": "Piglin Brute dies",
|
||||
"subtitles.entity.piglin_brute.hurt": "Piglin Brute hurts",
|
||||
"subtitles.entity.piglin_brute.step": "Piglin Brute steps",
|
||||
"subtitles.entity.piglin_brute.converted_to_zombified": "Piglin Brute converts to Zombified Piglin",
|
||||
"command.context.parse_error": "%s at position %s: %s",
|
||||
"commands.list.nameAndId": "%s (%s)",
|
||||
"argument.angle.incomplete": "Incomplete (expected 1 angle)",
|
||||
"commands.summon.failed.uuid": "Unable to summon entity due to duplicate UUIDs"
|
||||
},
|
||||
"1.16": {
|
||||
"gui.recipebook.search_hint": "Search...",
|
||||
"selectWorld.edit.export_worldgen_settings": "Export World Generation Settings",
|
||||
"selectWorld.edit.export_worldgen_settings.success": "Exported",
|
||||
"selectWorld.edit.export_worldgen_settings.failure": "Export failed",
|
||||
"selectWorld.locked": "Locked by another running instance of Minecraft",
|
||||
"selectWorld.backupQuestion.experimental": "Worlds using Experimental Settings are not supported",
|
||||
"selectWorld.backupWarning.experimental": "This world uses experimental settings that could stop working at any time. We cannot guarantee it will load or work. Here be dragons!",
|
||||
"selectWorld.tooltip.experimental": "This world is using experimental settings",
|
||||
"selectWorld.access_failure": "Failed to access world",
|
||||
"selectWorld.delete_failure": "Failed to delete world",
|
||||
"selectWorld.data_read": "Reading world data...",
|
||||
"createWorld.preparing": "Preparing for world creation...",
|
||||
"datapackFailure.title": "Errors in currently selected datapacks prevented world from loading.\nYou can either try to load only with vanilla datapack (\"safe mode\") or go back to title screen and fix it manually.",
|
||||
"datapackFailure.safeMode": "Safe mode",
|
||||
"editGamerule.title": "Edit game rules",
|
||||
"datapackFailure.safeMode": "Safe Mode",
|
||||
"editGamerule.title": "Edit Game Rules",
|
||||
"editGamerule.default": "Default: %s",
|
||||
"selectWorld.gameRules": "Game Rules",
|
||||
"selectWorld.import_worldgen_settings": "Import settings",
|
||||
"selectWorld.dataPacks": "Data Packs",
|
||||
"selectWorld.import_worldgen_settings": "Import Settings",
|
||||
"selectWorld.import_worldgen_settings.select_file": "Select settings file (.json)",
|
||||
"selectWorld.import_worldgen_settings.failure": "Error importing settings",
|
||||
"selectWorld.import_worldgen_settings.experimental.title": "Warning! These settings are using experimental features",
|
||||
@@ -25,15 +49,46 @@
|
||||
"generator.custom": "Custom",
|
||||
"generator.single_biome_surface": "Single Biome",
|
||||
"generator.single_biome_caves": "Caves",
|
||||
"generator.single_biome_floating_islands": "Floating islands",
|
||||
"generator.single_biome_floating_islands": "Floating Islands",
|
||||
"multiplayer.status.ping": "%s ms",
|
||||
"chat.queue": "[+%s pending lines]",
|
||||
"options.entityDistanceScaling": "Entity Distance",
|
||||
"options.entityDistancePercent": "%s%%",
|
||||
"options.graphics.fabulous.tooltip": "%s graphics uses screen shaders for drawing weather, clouds and particles behind translucent blocks and water.\nThis may severely impact performance for portable devices and 4K displays.",
|
||||
"options.graphics.fabulous": "Fabulous!",
|
||||
"options.graphics.fancy.tooltip": "Fancy graphics balances performance and quality for the majority of machines.\nWeather, clouds and particles may not appear behind translucent blocks or water.",
|
||||
"options.graphics.fast.tooltip": "Fast graphics reduces the amount of visible rain and snow.\nTransparency effects are disabled for various blocks such as tree-leaves.",
|
||||
"options.graphics.warning.title": "Graphics Device Unsupported",
|
||||
"options.graphics.warning.message": "Your graphics device is detected as unsupported for the %s graphics option.\n\nYou may ignore this and continue, however support will not be provided for your device if you choose to use %s graphics.",
|
||||
"options.graphics.warning.renderer": "Renderer detected: [%s]",
|
||||
"options.graphics.warning.vendor": "Vendor detected: [%s]",
|
||||
"options.graphics.warning.version": "OpenGL Version detected: [%s]",
|
||||
"options.graphics.warning.accept": "Continue without support",
|
||||
"options.graphics.warning.cancel": "Take me back",
|
||||
"options.chat.line_spacing": "Line Spacing",
|
||||
"options.chat.delay_none": "Chat Delay: None",
|
||||
"options.chat.delay": "Chat Delay: %s seconds",
|
||||
"title.multiplayer.disabled": "Multiplayer is disabled, please check your launcher settings.",
|
||||
"key.swapOffhand": "Swap Item With Offhand",
|
||||
"pack.available.title": "Available",
|
||||
"pack.selected.title": "Selected",
|
||||
"pack.incompatible": "Incompatible",
|
||||
"pack.incompatible.old": "(Made for an older version of Minecraft)",
|
||||
"pack.incompatible.new": "(Made for a newer version of Minecraft)",
|
||||
"pack.incompatible.confirm.title": "Are you sure you want to load this pack?",
|
||||
"pack.incompatible.confirm.old": "This pack was made for an older version of Minecraft and may no longer work correctly.",
|
||||
"pack.incompatible.confirm.new": "This pack was made for a newer version of Minecraft and may no longer work correctly.",
|
||||
"pack.dropInfo": "Drag and drop files into this window to add packs",
|
||||
"pack.dropConfirm": "Do you want to add following packs to Minecraft?",
|
||||
"pack.copyFailure": "Failed to copy packs",
|
||||
"pack.nameAndSource": "%s (%s)",
|
||||
"pack.openFolder": "Open Pack Folder",
|
||||
"pack.folderInfo": "(Place pack files here)",
|
||||
"dataPack.title": "Select Data Packs",
|
||||
"dataPack.validation.working": "Validating selected data packs...",
|
||||
"dataPack.validation.failed": "Data pack validation failed!",
|
||||
"dataPack.validation.back": "Go Back",
|
||||
"dataPack.validation.reset": "Reset to Default",
|
||||
"block.minecraft.nether_gold_ore": "Nether Gold Ore",
|
||||
"block.minecraft.soul_torch": "Soul Torch",
|
||||
"block.minecraft.soul_wall_torch": "Soul Wall Torch",
|
||||
@@ -285,7 +340,7 @@
|
||||
"subtitles.entity.zombie.break_wooden_door": "Door breaks",
|
||||
"subtitles.entity.zombie.destroy_egg": "Turtle Egg stomped",
|
||||
"subtitles.entity.zombified_piglin.ambient": "Zombified Piglin grunts",
|
||||
"subtitles.entity.zombified_piglin.angry": "Zombified Piglin angers",
|
||||
"subtitles.entity.zombified_piglin.angry": "Zombified Piglin grunts angrily",
|
||||
"subtitles.entity.zombified_piglin.death": "Zombified Piglin dies",
|
||||
"subtitles.entity.zombified_piglin.hurt": "Zombified Piglin hurts",
|
||||
"subtitles.item.armor.equip_netherite": "Netherite armor clanks",
|
||||
@@ -298,8 +353,8 @@
|
||||
"subtitles.ui.stonecutter.take_result": "Stonecutter used",
|
||||
"debug.gamemodes.help": "F3 + F4 = Open game mode switcher",
|
||||
"debug.gamemodes.error": "Unable to open game mode switcher, no permission",
|
||||
"debug.gamemodes.press_f4": "F4",
|
||||
"debug.gamemodes.select_next": "Next",
|
||||
"debug.gamemodes.press_f4": "[ F4 ]",
|
||||
"debug.gamemodes.select_next": "%s Next",
|
||||
"advancements.adventure.bullseye.title": "Bullseye",
|
||||
"advancements.adventure.bullseye.description": "Hit the bullseye of a Target block from at least 30 meters away",
|
||||
"advancements.husbandry.netherite_hoe.title": "Serious Dedication",
|
||||
@@ -310,7 +365,7 @@
|
||||
"advancements.nether.netherite_armor.description": "Get a full suit of Netherite armor",
|
||||
"advancements.nether.use_lodestone.title": "Country Lode, Take Me Home",
|
||||
"advancements.nether.use_lodestone.description": "Use a Compass on a Lodestone",
|
||||
"advancements.nether.obtain_crying_obsidian.title": "Who Is Cutting Onions?",
|
||||
"advancements.nether.obtain_crying_obsidian.title": "Who is Cutting Onions?",
|
||||
"advancements.nether.obtain_crying_obsidian.description": "Obtain Crying Obsidian",
|
||||
"advancements.nether.charge_respawn_anchor.title": "Not Quite \"Nine\" Lives",
|
||||
"advancements.nether.charge_respawn_anchor.description": "Charge a Respawn Anchor to the maximum",
|
||||
@@ -338,8 +393,10 @@
|
||||
"commands.locatebiome.success": "The nearest %s is at %s (%s blocks away)",
|
||||
"commands.teleport.invalidPosition": "Invalid position for teleport",
|
||||
"commands.reload.failure": "Reload failed, keeping old data",
|
||||
"commands.locatebiome.notFound": "Could not find a biome of type %s within reasonable distance",
|
||||
"commands.locatebiome.invalid": "There is no biome named %s",
|
||||
"commands.datapack.modify.enable": "Enabling data pack %s",
|
||||
"commands.datapack.modify.disable": "Disabling data pack %s",
|
||||
"commands.locatebiome.notFound": "Could not find a biome of type \"%s\" within reasonable distance",
|
||||
"commands.locatebiome.invalid": "There is no biome with type \"%s\"",
|
||||
"commands.summon.invalidPosition": "Invalid position for summon",
|
||||
"biome.minecraft.nether_wastes": "Nether Wastes",
|
||||
"biome.minecraft.soul_sand_valley": "Soul Sand Valley",
|
||||
@@ -359,17 +416,19 @@
|
||||
"gamerule.doLimitedCrafting": "Require recipe for crafting",
|
||||
"gamerule.doLimitedCrafting.description": "If enabled, players will be able to craft only unlocked recipes",
|
||||
"gamerule.doMobLoot": "Drop mob loot",
|
||||
"gamerule.doMobLoot.description": "Controls resource drops, including experience orbs",
|
||||
"gamerule.doMobLoot.description": "Controls resource drops from mobs, including experience orbs",
|
||||
"gamerule.doMobSpawning": "Spawn mobs",
|
||||
"gamerule.doMobSpawning.description": "Some entities might have separate rules",
|
||||
"gamerule.doPatrolSpawning": "Spawn pillager patrols",
|
||||
"gamerule.doTileDrops": "Drop blocks",
|
||||
"gamerule.doTileDrops.description": "Controls resource drops, including experience orbs",
|
||||
"gamerule.doTileDrops.description": "Controls resource drops from blocks, including experience orbs",
|
||||
"gamerule.doTraderSpawning": "Spawn wandering traders",
|
||||
"gamerule.doWeatherCycle": "Update weather",
|
||||
"gamerule.drowningDamage": "Deal drowning damage",
|
||||
"gamerule.fallDamage": "Deal fall damage",
|
||||
"gamerule.fireDamage": "Deal fire damage",
|
||||
"gamerule.forgiveDeadPlayers": "Forgive dead players",
|
||||
"gamerule.forgiveDeadPlayers.description": "Angered neutral mobs stop being angry when the targeted player dies nearby.",
|
||||
"gamerule.keepInventory": "Keep inventory after death",
|
||||
"gamerule.logAdminCommands": "Broadcast admin commands",
|
||||
"gamerule.maxCommandChainLength": "Command chain size limit",
|
||||
@@ -384,13 +443,19 @@
|
||||
"gamerule.showDeathMessages": "Show death messages",
|
||||
"gamerule.spawnRadius": "Respawn location radius",
|
||||
"gamerule.spectatorsGenerateChunks": "Allow spectators to generate terrain",
|
||||
"gamerule.universalAnger": "Universal anger",
|
||||
"gamerule.universalAnger.description": "Angered neutral mobs attack any nearby player, not just the player that angered them. Works best if forgiveDeadPlayers is disabled.",
|
||||
"gamerule.category.chat": "Chat",
|
||||
"gamerule.category.spawning": "Spawning",
|
||||
"gamerule.category.updates": "World updates",
|
||||
"gamerule.category.drops": "Drops",
|
||||
"gamerule.category.mobs": "Mobs",
|
||||
"gamerule.category.player": "Player",
|
||||
"gamerule.category.misc": "Miscellaneous"
|
||||
"gamerule.category.misc": "Miscellaneous",
|
||||
"pack.source.builtin": "built-in",
|
||||
"pack.source.world": "world",
|
||||
"pack.source.local": "local",
|
||||
"pack.source.server": "server"
|
||||
},
|
||||
"1.15": {
|
||||
"narration.suggestion.tooltip": "Selected suggestion %d out of %d: %s (%s)",
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-fabric</artifactId>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.1.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<description>Allow older clients to join newer server versions.</description>
|
||||
@@ -65,7 +65,7 @@
|
||||
<dependency>
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<version>3.1.0-1.16.2-RC2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-sponge</artifactId>
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-velocity</artifactId>
|
||||
|
||||
Reference in new issue
Block a user