Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-27 16:40:12 +01:00
Merge branch 'master' into dev
# Conflicts: # common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java
Dieser Commit ist enthalten in:
Commit
bc03235f42
13
.editorconfig
Normale Datei
13
.editorconfig
Normale Datei
@ -0,0 +1,13 @@
|
|||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = false
|
||||||
|
tab_width = 4
|
||||||
|
|
||||||
|
[*.java]
|
||||||
|
ij_java_class_count_to_use_import_on_demand = 999999
|
||||||
|
ij_java_names_count_to_use_import_on_demand = 999999
|
||||||
|
ij_java_imports_layout = *,|,$*
|
||||||
|
ij_java_generate_final_locals = true
|
||||||
|
ij_java_generate_final_parameters = true
|
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
|
||||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.viaversion.viabackwards.api.exceptions;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class RemovedValueException extends IOException {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* May be cached since it is never actually printed, only checked.
|
|
||||||
*/
|
|
||||||
public static final RemovedValueException EX = new RemovedValueException() {
|
|
||||||
@Override
|
|
||||||
public Throwable fillInStackTrace() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
@ -21,7 +21,6 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
|||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
import com.viaversion.viaversion.util.ComponentUtil;
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
@ -57,10 +56,10 @@ public class EnchantmentRewriter {
|
|||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
if (tag == null) return;
|
if (tag == null) return;
|
||||||
|
|
||||||
if (tag.get("Enchantments") instanceof ListTag) {
|
if (tag.getListTag("Enchantments") != null) {
|
||||||
rewriteEnchantmentsToClient(tag, false);
|
rewriteEnchantmentsToClient(tag, false);
|
||||||
}
|
}
|
||||||
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
if (tag.getListTag("StoredEnchantments") != null) {
|
||||||
rewriteEnchantmentsToClient(tag, true);
|
rewriteEnchantmentsToClient(tag, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,17 +78,16 @@ public class EnchantmentRewriter {
|
|||||||
|
|
||||||
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
||||||
String key = storedEnchant ? "StoredEnchantments" : "Enchantments";
|
String key = storedEnchant ? "StoredEnchantments" : "Enchantments";
|
||||||
ListTag enchantments = tag.get(key);
|
ListTag enchantments = tag.getListTag(key);
|
||||||
List<Tag> loreToAdd = new ArrayList<>();
|
List<Tag> loreToAdd = new ArrayList<>();
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
Iterator<Tag> iterator = enchantments.iterator();
|
Iterator<Tag> iterator = enchantments.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
CompoundTag enchantmentEntry = (CompoundTag) iterator.next();
|
CompoundTag enchantmentEntry = (CompoundTag) iterator.next();
|
||||||
Tag idTag = enchantmentEntry.get("id");
|
StringTag idTag = enchantmentEntry.getStringTag("id");
|
||||||
if (!(idTag instanceof StringTag)) continue;
|
|
||||||
|
|
||||||
String enchantmentId = ((StringTag) idTag).getValue();
|
String enchantmentId = idTag.getValue();
|
||||||
String remappedName = enchantmentMappings.get(enchantmentId);
|
String remappedName = enchantmentMappings.get(enchantmentId);
|
||||||
if (remappedName != null) {
|
if (remappedName != null) {
|
||||||
if (!changed) {
|
if (!changed) {
|
||||||
@ -100,7 +98,8 @@ public class EnchantmentRewriter {
|
|||||||
|
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
|
||||||
int level = ((NumberTag) enchantmentEntry.get("lvl")).asInt();
|
NumberTag levelTag = enchantmentEntry.getNumberTag("lvl");
|
||||||
|
int level = levelTag != null ? levelTag.asInt() : 1;
|
||||||
String loreValue = remappedName + " " + getRomanNumber(level);
|
String loreValue = remappedName + " " + getRomanNumber(level);
|
||||||
if (jsonFormat) {
|
if (jsonFormat) {
|
||||||
loreValue = ComponentUtil.legacyToJsonString(loreValue);
|
loreValue = ComponentUtil.legacyToJsonString(loreValue);
|
||||||
@ -112,19 +111,19 @@ public class EnchantmentRewriter {
|
|||||||
|
|
||||||
if (!loreToAdd.isEmpty()) {
|
if (!loreToAdd.isEmpty()) {
|
||||||
// Add dummy enchant for the glow effect if there are no actual enchantments left
|
// Add dummy enchant for the glow effect if there are no actual enchantments left
|
||||||
if (!storedEnchant && enchantments.size() == 0) {
|
if (!storedEnchant && enchantments.isEmpty()) {
|
||||||
CompoundTag dummyEnchantment = new CompoundTag();
|
CompoundTag dummyEnchantment = new CompoundTag();
|
||||||
dummyEnchantment.put("id", new StringTag());
|
dummyEnchantment.putString("id", "");
|
||||||
dummyEnchantment.put("lvl", new ShortTag((short) 0));
|
dummyEnchantment.putShort("lvl", (short) 0);
|
||||||
enchantments.add(dummyEnchantment);
|
enchantments.add(dummyEnchantment);
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag display = tag.get("display");
|
CompoundTag display = tag.getCompoundTag("display");
|
||||||
if (display == null) {
|
if (display == null) {
|
||||||
tag.put("display", display = new CompoundTag());
|
tag.put("display", display = new CompoundTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
ListTag loreTag = display.get("Lore");
|
ListTag loreTag = display.getListTag("Lore");
|
||||||
if (loreTag == null) {
|
if (loreTag == null) {
|
||||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
||||||
} else {
|
} else {
|
||||||
|
@ -29,6 +29,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
|||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
@ -46,25 +47,23 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag display = item.tag() != null ? item.tag().get("display") : null;
|
CompoundTag display = item.tag() != null ? item.tag().getCompoundTag("display") : null;
|
||||||
if (protocol.getTranslatableRewriter() != null && display != null) {
|
if (protocol.getTranslatableRewriter() != null && display != null) {
|
||||||
// Handle name and lore components
|
// Handle name and lore components
|
||||||
Tag name = display.get("Name");
|
StringTag name = display.getStringTag("Name");
|
||||||
if (name instanceof StringTag) {
|
if (name != null) {
|
||||||
StringTag nameStringTag = (StringTag) name;
|
String newValue = protocol.getTranslatableRewriter().processText(name.getValue()).toString();
|
||||||
String newValue = protocol.getTranslatableRewriter().processText(nameStringTag.getValue()).toString();
|
|
||||||
if (!newValue.equals(name.getValue())) {
|
if (!newValue.equals(name.getValue())) {
|
||||||
saveStringTag(display, nameStringTag, "Name");
|
saveStringTag(display, name, "Name");
|
||||||
}
|
}
|
||||||
|
|
||||||
nameStringTag.setValue(newValue);
|
name.setValue(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag lore = display.get("Lore");
|
ListTag lore = display.getListTag("Lore");
|
||||||
if (lore instanceof ListTag) {
|
if (lore != null) {
|
||||||
ListTag loreListTag = (ListTag) lore;
|
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (Tag loreEntryTag : loreListTag) {
|
for (Tag loreEntryTag : lore) {
|
||||||
if (!(loreEntryTag instanceof StringTag)) {
|
if (!(loreEntryTag instanceof StringTag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -74,7 +73,7 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
|||||||
if (!changed && !newValue.equals(loreEntry.getValue())) {
|
if (!changed && !newValue.equals(loreEntry.getValue())) {
|
||||||
// Backup original lore before doing any modifications
|
// Backup original lore before doing any modifications
|
||||||
changed = true;
|
changed = true;
|
||||||
saveListTag(display, loreListTag, "Lore");
|
saveListTag(display, lore, "Lore");
|
||||||
}
|
}
|
||||||
|
|
||||||
loreEntry.setValue(newValue);
|
loreEntry.setValue(newValue);
|
||||||
@ -93,12 +92,12 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save original id, set remapped id
|
// Save original id, set remapped id
|
||||||
item.tag().put(nbtTagName + "|id", new IntTag(item.identifier()));
|
item.tag().putInt(nbtTagName + "|id", item.identifier());
|
||||||
item.setIdentifier(data.getId());
|
item.setIdentifier(data.getId());
|
||||||
|
|
||||||
// Add custom model data
|
// Add custom model data
|
||||||
if (data.customModelData() != null && !item.tag().contains("CustomModelData")) {
|
if (data.customModelData() != null && !item.tag().contains("CustomModelData")) {
|
||||||
item.tag().put("CustomModelData", new IntTag(data.customModelData()));
|
item.tag().putInt("CustomModelData", data.customModelData());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set custom name - only done if there is no original one
|
// Set custom name - only done if there is no original one
|
||||||
@ -118,9 +117,9 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
|||||||
|
|
||||||
super.handleItemToServer(item);
|
super.handleItemToServer(item);
|
||||||
if (item.tag() != null) {
|
if (item.tag() != null) {
|
||||||
IntTag originalId = item.tag().remove(nbtTagName + "|id");
|
Tag originalId = item.tag().remove(nbtTagName + "|id");
|
||||||
if (originalId != null) {
|
if (originalId instanceof IntTag) {
|
||||||
item.setIdentifier(originalId.asInt());
|
item.setIdentifier(((NumberTag) originalId).asInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
|
@ -35,7 +35,7 @@ public abstract class ItemRewriterBase<C extends ClientboundPacketType, S extend
|
|||||||
protected final String nbtTagName;
|
protected final String nbtTagName;
|
||||||
protected final boolean jsonNameFormat;
|
protected final boolean jsonNameFormat;
|
||||||
|
|
||||||
public ItemRewriterBase(T protocol, Type<Item> itemType, Type<Item[]> itemArrayType, boolean jsonNameFormat) {
|
protected ItemRewriterBase(T protocol, Type<Item> itemType, Type<Item[]> itemArrayType, boolean jsonNameFormat) {
|
||||||
super(protocol, itemType, itemArrayType);
|
super(protocol, itemType, itemArrayType);
|
||||||
this.jsonNameFormat = jsonNameFormat;
|
this.jsonNameFormat = jsonNameFormat;
|
||||||
nbtTagName = "VB|" + protocol.getClass().getSimpleName();
|
nbtTagName = "VB|" + protocol.getClass().getSimpleName();
|
||||||
@ -58,7 +58,7 @@ public abstract class ItemRewriterBase<C extends ClientboundPacketType, S extend
|
|||||||
// Multiple places might try to backup data
|
// Multiple places might try to backup data
|
||||||
String backupName = nbtTagName + "|o" + name;
|
String backupName = nbtTagName + "|o" + name;
|
||||||
if (!displayTag.contains(backupName)) {
|
if (!displayTag.contains(backupName)) {
|
||||||
displayTag.put(backupName, new StringTag(original.getValue()));
|
displayTag.putString(backupName, original.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ public abstract class ItemRewriterBase<C extends ClientboundPacketType, S extend
|
|||||||
protected void restoreDisplayTag(Item item) {
|
protected void restoreDisplayTag(Item item) {
|
||||||
if (item.tag() == null) return;
|
if (item.tag() == null) return;
|
||||||
|
|
||||||
CompoundTag display = item.tag().get("display");
|
CompoundTag display = item.tag().getCompoundTag("display");
|
||||||
if (display != null) {
|
if (display != null) {
|
||||||
// Remove custom name / restore original name
|
// Remove custom name / restore original name
|
||||||
if (display.remove(nbtTagName + "|customName") != null) {
|
if (display.remove(nbtTagName + "|customName") != null) {
|
||||||
@ -94,16 +94,16 @@ public abstract class ItemRewriterBase<C extends ClientboundPacketType, S extend
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void restoreStringTag(CompoundTag tag, String tagName) {
|
protected void restoreStringTag(CompoundTag tag, String tagName) {
|
||||||
StringTag original = tag.remove(nbtTagName + "|o" + tagName);
|
Tag original = tag.remove(nbtTagName + "|o" + tagName);
|
||||||
if (original != null) {
|
if (original instanceof StringTag) {
|
||||||
tag.put(tagName, new StringTag(original.getValue()));
|
tag.putString(tagName, ((StringTag) original).getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void restoreListTag(CompoundTag tag, String tagName) {
|
protected void restoreListTag(CompoundTag tag, String tagName) {
|
||||||
ListTag original = tag.remove(nbtTagName + "|o" + tagName);
|
Tag original = tag.remove(nbtTagName + "|o" + tagName);
|
||||||
if (original != null) {
|
if (original instanceof ListTag) {
|
||||||
tag.put(tagName, new ListTag(original.getValue()));
|
tag.put(tagName, new ListTag(((ListTag) original).getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,10 +38,8 @@ import com.viaversion.viaversion.libs.gson.JsonObject;
|
|||||||
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.util.ComponentUtil;
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -134,21 +132,22 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
|||||||
item.setTag(new CompoundTag());
|
item.setTag(new CompoundTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag display = item.tag().get("display");
|
CompoundTag display = item.tag().getCompoundTag("display");
|
||||||
if (display == null) {
|
if (display == null) {
|
||||||
item.tag().put("display", display = new CompoundTag());
|
item.tag().put("display", display = new CompoundTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
StringTag nameTag = display.get("Name");
|
StringTag nameTag = display.getStringTag("Name");
|
||||||
if (nameTag == null) {
|
if (nameTag == null) {
|
||||||
display.put("Name", nameTag = new StringTag(data.getName()));
|
nameTag = new StringTag(data.getName());
|
||||||
|
display.put("Name", nameTag);
|
||||||
display.put(nbtTagName + "|customName", new ByteTag());
|
display.put(nbtTagName + "|customName", new ByteTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle colors
|
// Handle colors
|
||||||
String value = nameTag.getValue();
|
String value = nameTag.getValue();
|
||||||
if (value.contains("%vb_color%")) {
|
if (value.contains("%vb_color%")) {
|
||||||
display.put("Name", new StringTag(value.replace("%vb_color%", BlockColors.get(originalData))));
|
display.putString("Name", value.replace("%vb_color%", BlockColors.get(originalData)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
@ -190,17 +189,16 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
|||||||
// Map Block Entities
|
// Map Block Entities
|
||||||
Map<Pos, CompoundTag> tags = new HashMap<>();
|
Map<Pos, CompoundTag> tags = new HashMap<>();
|
||||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||||
Tag xTag;
|
NumberTag xTag;
|
||||||
Tag yTag;
|
NumberTag yTag;
|
||||||
Tag zTag;
|
NumberTag zTag;
|
||||||
if ((xTag = tag.get("x")) == null || (yTag = tag.get("y")) == null || (zTag = tag.get("z")) == null) {
|
if ((xTag = tag.getNumberTag("x")) == null
|
||||||
|
|| (yTag = tag.getNumberTag("y")) == null
|
||||||
|
|| (zTag = tag.getNumberTag("z")) == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pos pos = new Pos(
|
Pos pos = new Pos(xTag.asInt() & 0xF, yTag.asInt(), zTag.asInt() & 0xF);
|
||||||
((NumberTag) xTag).asInt() & 0xF,
|
|
||||||
((NumberTag) yTag).asInt(),
|
|
||||||
((NumberTag) zTag).asInt() & 0xF);
|
|
||||||
tags.put(pos, tag);
|
tags.put(pos, tag);
|
||||||
|
|
||||||
// Handle given Block Entities
|
// Handle given Block Entities
|
||||||
@ -263,9 +261,9 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
|||||||
if (tags.containsKey(pos)) continue;
|
if (tags.containsKey(pos)) continue;
|
||||||
|
|
||||||
CompoundTag tag = new CompoundTag();
|
CompoundTag tag = new CompoundTag();
|
||||||
tag.put("x", new IntTag(x + (chunk.getX() << 4)));
|
tag.putInt("x", x + (chunk.getX() << 4));
|
||||||
tag.put("y", new IntTag(y + (i << 4)));
|
tag.putInt("y", y + (i << 4));
|
||||||
tag.put("z", new IntTag(z + (chunk.getZ() << 4)));
|
tag.putInt("z", z + (chunk.getZ() << 4));
|
||||||
|
|
||||||
settings.getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
settings.getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
||||||
chunk.getBlockEntities().add(tag);
|
chunk.getBlockEntities().add(tag);
|
||||||
@ -277,9 +275,10 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
|||||||
|
|
||||||
protected CompoundTag getNamedTag(String text) {
|
protected CompoundTag getNamedTag(String text) {
|
||||||
CompoundTag tag = new CompoundTag();
|
CompoundTag tag = new CompoundTag();
|
||||||
tag.put("display", new CompoundTag());
|
CompoundTag displayTag = new CompoundTag();
|
||||||
|
tag.put("display", displayTag);
|
||||||
text = "§r" + text;
|
text = "§r" + text;
|
||||||
((CompoundTag) tag.get("display")).put("Name", new StringTag(jsonNameFormat ? ComponentUtil.legacyToJsonString(text) : text));
|
displayTag.putString("Name", jsonNameFormat ? ComponentUtil.legacyToJsonString(text) : text);
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
|||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -48,18 +47,24 @@ public class LegacyEnchantmentRewriter {
|
|||||||
|
|
||||||
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
public void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
||||||
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
||||||
ListTag enchantments = tag.get(key);
|
ListTag enchantments = tag.getListTag(key);
|
||||||
ListTag remappedEnchantments = new ListTag(CompoundTag.class);
|
ListTag remappedEnchantments = new ListTag(CompoundTag.class);
|
||||||
List<Tag> lore = new ArrayList<>();
|
List<Tag> lore = new ArrayList<>();
|
||||||
for (Tag enchantmentEntry : enchantments.copy()) {
|
for (Tag enchantmentEntry : enchantments.copy()) {
|
||||||
Tag idTag = ((CompoundTag) enchantmentEntry).get("id");
|
if (!(enchantmentEntry instanceof CompoundTag)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag entryTag = (CompoundTag) enchantmentEntry;
|
||||||
|
NumberTag idTag = entryTag.getNumberTag("id");
|
||||||
if (idTag == null) continue;
|
if (idTag == null) continue;
|
||||||
|
|
||||||
short newId = ((NumberTag) idTag).asShort();
|
short newId = idTag.asShort();
|
||||||
String enchantmentName = enchantmentMappings.get(newId);
|
String enchantmentName = enchantmentMappings.get(newId);
|
||||||
if (enchantmentName != null) {
|
if (enchantmentName != null) {
|
||||||
enchantments.remove(enchantmentEntry);
|
enchantments.remove(enchantmentEntry);
|
||||||
short level = ((NumberTag) ((CompoundTag) enchantmentEntry).get("lvl")).asShort();
|
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
||||||
|
short level = levelTag != null ? levelTag.asShort() : 1;
|
||||||
if (hideLevelForEnchants != null && hideLevelForEnchants.contains(newId)) {
|
if (hideLevelForEnchants != null && hideLevelForEnchants.contains(newId)) {
|
||||||
lore.add(new StringTag(enchantmentName));
|
lore.add(new StringTag(enchantmentName));
|
||||||
} else {
|
} else {
|
||||||
@ -69,33 +74,32 @@ public class LegacyEnchantmentRewriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!lore.isEmpty()) {
|
if (!lore.isEmpty()) {
|
||||||
if (!storedEnchant && enchantments.size() == 0) {
|
if (!storedEnchant && enchantments.isEmpty()) {
|
||||||
CompoundTag dummyEnchantment = new CompoundTag();
|
CompoundTag dummyEnchantment = new CompoundTag();
|
||||||
dummyEnchantment.put("id", new ShortTag((short) 0));
|
dummyEnchantment.putShort("id", (short) 0);
|
||||||
dummyEnchantment.put("lvl", new ShortTag((short) 0));
|
dummyEnchantment.putShort("lvl", (short) 0);
|
||||||
enchantments.add(dummyEnchantment);
|
enchantments.add(dummyEnchantment);
|
||||||
|
|
||||||
tag.put(nbtTagName + "|dummyEnchant", new ByteTag());
|
tag.put(nbtTagName + "|dummyEnchant", new ByteTag());
|
||||||
|
|
||||||
IntTag hideFlags = tag.get("HideFlags");
|
NumberTag hideFlags = tag.getNumberTag("HideFlags");
|
||||||
if (hideFlags == null) {
|
if (hideFlags == null) {
|
||||||
hideFlags = new IntTag();
|
hideFlags = new IntTag();
|
||||||
} else {
|
} else {
|
||||||
tag.put(nbtTagName + "|oldHideFlags", new IntTag(hideFlags.asByte()));
|
tag.putInt(nbtTagName + "|oldHideFlags", hideFlags.asByte());
|
||||||
}
|
}
|
||||||
|
|
||||||
int flags = hideFlags.asByte() | 1;
|
int flags = hideFlags.asByte() | 1;
|
||||||
hideFlags.setValue(flags);
|
tag.putInt("HideFlags", flags);
|
||||||
tag.put("HideFlags", hideFlags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.put(nbtTagName + "|" + key, remappedEnchantments);
|
tag.put(nbtTagName + "|" + key, remappedEnchantments);
|
||||||
|
|
||||||
CompoundTag display = tag.get("display");
|
CompoundTag display = tag.getCompoundTag("display");
|
||||||
if (display == null) {
|
if (display == null) {
|
||||||
tag.put("display", display = new CompoundTag());
|
tag.put("display", display = new CompoundTag());
|
||||||
}
|
}
|
||||||
ListTag loreTag = display.get("Lore");
|
ListTag loreTag = display.getListTag("Lore");
|
||||||
if (loreTag == null) {
|
if (loreTag == null) {
|
||||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
||||||
}
|
}
|
||||||
@ -108,38 +112,45 @@ public class LegacyEnchantmentRewriter {
|
|||||||
public void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnchant) {
|
public void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnchant) {
|
||||||
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
String key = storedEnchant ? "StoredEnchantments" : "ench";
|
||||||
ListTag remappedEnchantments = tag.remove(nbtTagName + "|" + key);
|
ListTag remappedEnchantments = tag.remove(nbtTagName + "|" + key);
|
||||||
ListTag enchantments = tag.get(key);
|
ListTag enchantments = tag.getListTag(key);
|
||||||
if (enchantments == null) {
|
if (enchantments == null) {
|
||||||
enchantments = new ListTag(CompoundTag.class);
|
enchantments = new ListTag(CompoundTag.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!storedEnchant && tag.remove(nbtTagName + "|dummyEnchant") != null) {
|
if (!storedEnchant && tag.remove(nbtTagName + "|dummyEnchant") != null) {
|
||||||
for (Tag enchantment : enchantments.copy()) {
|
for (Tag enchantment : enchantments.copy()) {
|
||||||
short id = ((NumberTag) ((CompoundTag) enchantment).get("id")).asShort();
|
if (!(enchantment instanceof CompoundTag)) {
|
||||||
short level = ((NumberTag) ((CompoundTag) enchantment).get("lvl")).asShort();
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag entryTag = (CompoundTag) enchantment;
|
||||||
|
NumberTag idTag = entryTag.getNumberTag("id");
|
||||||
|
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
||||||
|
short id = idTag != null ? idTag.asShort() : 0;
|
||||||
|
short level = levelTag != null ? levelTag.asShort() : 0;
|
||||||
if (id == 0 && level == 0) {
|
if (id == 0 && level == 0) {
|
||||||
enchantments.remove(enchantment);
|
enchantments.remove(enchantment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IntTag hideFlags = tag.remove(nbtTagName + "|oldHideFlags");
|
Tag hideFlags = tag.remove(nbtTagName + "|oldHideFlags");
|
||||||
if (hideFlags != null) {
|
if (hideFlags instanceof IntTag) {
|
||||||
tag.put("HideFlags", new IntTag(hideFlags.asByte()));
|
tag.putInt("HideFlags", ((IntTag) hideFlags).asByte());
|
||||||
} else {
|
} else {
|
||||||
tag.remove("HideFlags");
|
tag.remove("HideFlags");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag display = tag.get("display");
|
CompoundTag display = tag.getCompoundTag("display");
|
||||||
// A few null checks just to be safe, though they shouldn't actually be
|
// A few null checks just to be safe, though they shouldn't actually be
|
||||||
ListTag lore = display != null ? display.get("Lore") : null;
|
ListTag lore = display != null ? display.getListTag("Lore") : null;
|
||||||
for (Tag enchantment : remappedEnchantments.copy()) {
|
for (Tag enchantment : remappedEnchantments.copy()) {
|
||||||
enchantments.add(enchantment);
|
enchantments.add(enchantment);
|
||||||
if (lore != null && lore.size() != 0) {
|
if (lore != null && !lore.isEmpty()) {
|
||||||
lore.remove(lore.get(0));
|
lore.remove(lore.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lore != null && lore.size() == 0) {
|
if (lore != null && lore.isEmpty()) {
|
||||||
display.remove("Lore");
|
display.remove("Lore");
|
||||||
if (display.isEmpty()) {
|
if (display.isEmpty()) {
|
||||||
tag.remove("display");
|
tag.remove("display");
|
||||||
|
@ -33,15 +33,11 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_11to1_10.EntityIdRewriter;
|
import com.viaversion.viaversion.protocols.protocol1_11to1_10.EntityIdRewriter;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||||
@ -181,12 +177,12 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
|||||||
|
|
||||||
// only patch it for signs for now
|
// only patch it for signs for now
|
||||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||||
Tag idTag = tag.get("id");
|
StringTag idTag = tag.getStringTag("id");
|
||||||
if (!(idTag instanceof StringTag)) continue;
|
if (idTag == null) continue;
|
||||||
|
|
||||||
String id = (String) idTag.getValue();
|
String id = idTag.getValue();
|
||||||
if (id.equals("minecraft:sign")) {
|
if (id.equals("minecraft:sign")) {
|
||||||
((StringTag) idTag).setValue("Sign");
|
idTag.setValue("Sign");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -327,10 +323,10 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
|||||||
// Rewrite spawn eggs (id checks are done in the method itself)
|
// Rewrite spawn eggs (id checks are done in the method itself)
|
||||||
EntityIdRewriter.toClientItem(item, true);
|
EntityIdRewriter.toClientItem(item, true);
|
||||||
|
|
||||||
if (tag.get("ench") instanceof ListTag) {
|
if (tag.getListTag("ench") != null) {
|
||||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, false);
|
enchantmentRewriter.rewriteEnchantmentsToClient(tag, false);
|
||||||
}
|
}
|
||||||
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
if (tag.getListTag("StoredEnchantments") != null) {
|
||||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, true);
|
enchantmentRewriter.rewriteEnchantmentsToClient(tag, true);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
@ -347,10 +343,10 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
|||||||
// Rewrite spawn eggs (id checks are done in the method itself)
|
// Rewrite spawn eggs (id checks are done in the method itself)
|
||||||
EntityIdRewriter.toServerItem(item, true);
|
EntityIdRewriter.toServerItem(item, true);
|
||||||
|
|
||||||
if (tag.contains(nbtTagName + "|ench")) {
|
if (tag.getListTag(nbtTagName + "|ench") != null) {
|
||||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, false);
|
enchantmentRewriter.rewriteEnchantmentsToServer(tag, false);
|
||||||
}
|
}
|
||||||
if (tag.contains(nbtTagName + "|StoredEnchantments")) {
|
if (tag.getListTag(nbtTagName + "|StoredEnchantments") != null) {
|
||||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, true);
|
enchantmentRewriter.rewriteEnchantmentsToServer(tag, true);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
|
@ -26,9 +26,9 @@ import com.viaversion.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_1
|
|||||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
|
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
|
||||||
import com.viaversion.viabackwards.utils.Block;
|
import com.viaversion.viabackwards.utils.Block;
|
||||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
|
@ -276,7 +276,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
|||||||
// Restore the removed long array tags
|
// Restore the removed long array tags
|
||||||
for (Map.Entry<String, Tag> entry : backupTag) {
|
for (Map.Entry<String, Tag> entry : backupTag) {
|
||||||
if (entry.getValue() instanceof CompoundTag) {
|
if (entry.getValue() instanceof CompoundTag) {
|
||||||
CompoundTag nestedTag = compoundTag.get(entry.getKey());
|
CompoundTag nestedTag = compoundTag.getCompoundTag(entry.getKey());
|
||||||
handleNbtToServer(nestedTag, (CompoundTag) entry.getValue());
|
handleNbtToServer(nestedTag, (CompoundTag) entry.getValue());
|
||||||
} else {
|
} else {
|
||||||
compoundTag.put(entry.getKey(), fromIntArrayTag((IntArrayTag) entry.getValue()));
|
compoundTag.put(entry.getKey(), fromIntArrayTag((IntArrayTag) entry.getValue()));
|
||||||
|
@ -24,11 +24,10 @@ import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ParrotStor
|
|||||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
|
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
|
||||||
import com.viaversion.viabackwards.utils.Block;
|
import com.viaversion.viabackwards.utils.Block;
|
||||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_12;
|
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_12;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
@ -271,8 +270,8 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
|||||||
if (tag.isEmpty() && tracker.getLeftShoulder() != null) {
|
if (tag.isEmpty() && tracker.getLeftShoulder() != null) {
|
||||||
tracker.setLeftShoulder(null);
|
tracker.setLeftShoulder(null);
|
||||||
tracker.update();
|
tracker.update();
|
||||||
} else if (tag.contains("id") && event.entityId() == tracker.getEntityId()) {
|
} else if (tag.getStringTag("id") != null && event.entityId() == tracker.getEntityId()) {
|
||||||
String id = (String) tag.get("id").getValue();
|
String id = tag.getStringTag("id").getValue();
|
||||||
if (tracker.getLeftShoulder() == null || !tracker.getLeftShoulder().equals(id)) {
|
if (tracker.getLeftShoulder() == null || !tracker.getLeftShoulder().equals(id)) {
|
||||||
tracker.setLeftShoulder(id);
|
tracker.setLeftShoulder(id);
|
||||||
tracker.update();
|
tracker.update();
|
||||||
@ -290,8 +289,8 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
|||||||
if (tag.isEmpty() && tracker.getRightShoulder() != null) {
|
if (tag.isEmpty() && tracker.getRightShoulder() != null) {
|
||||||
tracker.setRightShoulder(null);
|
tracker.setRightShoulder(null);
|
||||||
tracker.update();
|
tracker.update();
|
||||||
} else if (tag.contains("id") && event.entityId() == tracker.getEntityId()) {
|
} else if (tag.getStringTag("id") != null && event.entityId() == tracker.getEntityId()) {
|
||||||
String id = (String) tag.get("id").getValue();
|
String id = tag.getStringTag("id").getValue();
|
||||||
if (tracker.getRightShoulder() == null || !tracker.getRightShoulder().equals(id)) {
|
if (tracker.getRightShoulder() == null || !tracker.getRightShoulder().equals(id)) {
|
||||||
tracker.setRightShoulder(id);
|
tracker.setRightShoulder(id);
|
||||||
tracker.update();
|
tracker.update();
|
||||||
|
@ -20,8 +20,8 @@ package com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets;
|
|||||||
|
|
||||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||||
|
@ -25,7 +25,6 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
|||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||||
|
|
||||||
@ -97,10 +96,10 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
|
|||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
if (tag == null) return item;
|
if (tag == null) return item;
|
||||||
|
|
||||||
if (tag.get("ench") instanceof ListTag) {
|
if (tag.getListTag("ench") != null) {
|
||||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, false);
|
enchantmentRewriter.rewriteEnchantmentsToClient(tag, false);
|
||||||
}
|
}
|
||||||
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
if (tag.getListTag("StoredEnchantments") != null) {
|
||||||
enchantmentRewriter.rewriteEnchantmentsToClient(tag, true);
|
enchantmentRewriter.rewriteEnchantmentsToClient(tag, true);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
@ -114,10 +113,10 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
|
|||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
if (tag == null) return item;
|
if (tag == null) return item;
|
||||||
|
|
||||||
if (tag.contains(nbtTagName + "|ench")) {
|
if (tag.getListTag(nbtTagName + "|ench") != null) {
|
||||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, false);
|
enchantmentRewriter.rewriteEnchantmentsToServer(tag, false);
|
||||||
}
|
}
|
||||||
if (tag.contains(nbtTagName + "|StoredEnchantments")) {
|
if (tag.getListTag(nbtTagName + "|StoredEnchantments") != null) {
|
||||||
enchantmentRewriter.rewriteEnchantmentsToServer(tag, true);
|
enchantmentRewriter.rewriteEnchantmentsToServer(tag, true);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
|
@ -29,6 +29,7 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets.PlayerP
|
|||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets.SoundPackets1_13;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets.SoundPackets1_13;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||||
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.NoteBlockStorage;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerPositionStorage1_13;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerPositionStorage1_13;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
@ -124,6 +125,8 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
|||||||
if (ViaBackwards.getConfig().isFix1_13FacePlayer() && !user.has(PlayerPositionStorage1_13.class)) {
|
if (ViaBackwards.getConfig().isFix1_13FacePlayer() && !user.has(PlayerPositionStorage1_13.class)) {
|
||||||
user.put(new PlayerPositionStorage1_13());
|
user.put(new PlayerPositionStorage1_13());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user.put(new NoteBlockStorage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,10 +20,9 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_h
|
|||||||
|
|
||||||
import com.viaversion.viabackwards.ViaBackwards;
|
import com.viaversion.viabackwards.ViaBackwards;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
|
|
||||||
public class BannerHandler implements BackwardsBlockEntityHandler {
|
public class BannerHandler implements BackwardsBlockEntityHandler {
|
||||||
@ -34,28 +33,29 @@ public class BannerHandler implements BackwardsBlockEntityHandler {
|
|||||||
private static final int BANNER_STOP = 7109;
|
private static final int BANNER_STOP = 7109;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
public CompoundTag transform(int blockId, CompoundTag tag) {
|
||||||
// Normal banners
|
// Normal banners
|
||||||
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
|
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
|
||||||
int color = (blockId - BANNER_START) >> 4;
|
int color = (blockId - BANNER_START) >> 4;
|
||||||
tag.put("Base", new IntTag((15 - color)));
|
tag.putInt("Base", 15 - color);
|
||||||
}
|
}
|
||||||
// Wall banners
|
// Wall banners
|
||||||
else if (blockId >= WALL_BANNER_START && blockId <= WALL_BANNER_STOP) {
|
else if (blockId >= WALL_BANNER_START && blockId <= WALL_BANNER_STOP) {
|
||||||
int color = (blockId - WALL_BANNER_START) >> 2;
|
int color = (blockId - WALL_BANNER_START) >> 2;
|
||||||
tag.put("Base", new IntTag((15 - color)));
|
tag.putInt("Base", 15 - color);
|
||||||
} else {
|
} else {
|
||||||
ViaBackwards.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
|
ViaBackwards.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invert colors
|
// Invert colors
|
||||||
Tag patternsTag = tag.get("Patterns");
|
ListTag patternsTag = tag.getListTag("Patterns");
|
||||||
if (patternsTag instanceof ListTag) {
|
if (patternsTag != null) {
|
||||||
for (Tag pattern : (ListTag) patternsTag) {
|
for (Tag pattern : patternsTag) {
|
||||||
if (!(pattern instanceof CompoundTag)) continue;
|
if (!(pattern instanceof CompoundTag)) continue;
|
||||||
|
|
||||||
IntTag c = ((CompoundTag) pattern).get("Color");
|
CompoundTag patternTag = (CompoundTag) pattern;
|
||||||
c.setValue(15 - c.asInt()); // Invert color id
|
NumberTag colorTag = patternTag.getNumberTag("Color");
|
||||||
|
patternTag.putInt("Color", 15 - colorTag.asInt()); // Invert color id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,18 +19,16 @@
|
|||||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||||
|
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
|
||||||
|
|
||||||
public class BedHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
public class BedHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
public CompoundTag transform(int blockId, CompoundTag tag) {
|
||||||
int offset = blockId - 748;
|
int offset = blockId - 748;
|
||||||
int color = offset >> 4;
|
int color = offset >> 4;
|
||||||
|
|
||||||
tag.put("color", new IntTag(color));
|
tag.putInt("color", color);
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,9 @@
|
|||||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||||
|
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
|
||||||
import com.viaversion.viaversion.util.Pair;
|
import com.viaversion.viaversion.util.Pair;
|
||||||
|
|
||||||
public class FlowerPotHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
public class FlowerPotHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||||
@ -72,11 +69,11 @@ public class FlowerPotHandler implements BackwardsBlockEntityProvider.BackwardsB
|
|||||||
|
|
||||||
// TODO THIS IS NEVER CALLED BECAUSE ITS NO LONGER A BLOCK ENTITY :(
|
// TODO THIS IS NEVER CALLED BECAUSE ITS NO LONGER A BLOCK ENTITY :(
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
public CompoundTag transform(int blockId, CompoundTag tag) {
|
||||||
Pair<String, Byte> item = getOrDefault(blockId);
|
Pair<String, Byte> item = getOrDefault(blockId);
|
||||||
|
|
||||||
tag.put("Item", new StringTag(item.key()));
|
tag.putString("Item", item.key());
|
||||||
tag.put("Data", new IntTag(item.value()));
|
tag.putInt("Data", item.value());
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
@ -20,23 +20,23 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_h
|
|||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||||
|
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||||
|
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||||
|
|
||||||
private final Map<String, Integer> pistonIds = new HashMap<>();
|
private final Object2IntMap<String> pistonIds = new Object2IntOpenHashMap<>();
|
||||||
|
|
||||||
public PistonHandler() {
|
public PistonHandler() {
|
||||||
|
pistonIds.defaultReturnValue(-1);
|
||||||
if (Via.getConfig().isServersideBlockConnections()) {
|
if (Via.getConfig().isServersideBlockConnections()) {
|
||||||
Map<String, Integer> keyToId = ConnectionData.getKeyToId();
|
Map<String, Integer> keyToId = ConnectionData.getKeyToId();
|
||||||
for (Map.Entry<String, Integer> entry : keyToId.entrySet()) {
|
for (Map.Entry<String, Integer> entry : keyToId.entrySet()) {
|
||||||
@ -76,30 +76,30 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
public CompoundTag transform(int blockId, CompoundTag tag) {
|
||||||
CompoundTag blockState = tag.get("blockState");
|
CompoundTag blockState = tag.getCompoundTag("blockState");
|
||||||
if (blockState == null) return tag;
|
if (blockState == null) return tag;
|
||||||
|
|
||||||
String dataFromTag = getDataFromTag(blockState);
|
String dataFromTag = getDataFromTag(blockState);
|
||||||
if (dataFromTag == null) return tag;
|
if (dataFromTag == null) return tag;
|
||||||
|
|
||||||
Integer id = pistonIds.get(dataFromTag);
|
int id = pistonIds.getInt(dataFromTag);
|
||||||
if (id == null) {
|
if (id == -1) {
|
||||||
//TODO see why this could be null and if this is bad
|
//TODO see why this could be null and if this is bad
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.put("blockId", new IntTag(id >> 4));
|
tag.putInt("blockId", id >> 4);
|
||||||
tag.put("blockData", new IntTag(id & 15));
|
tag.putInt("blockData", id & 15);
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The type hasn't actually been updated in the blockstorage, so we need to construct it
|
// The type hasn't actually been updated in the blockstorage, so we need to construct it
|
||||||
private String getDataFromTag(CompoundTag tag) {
|
private String getDataFromTag(CompoundTag tag) {
|
||||||
StringTag name = tag.get("Name");
|
StringTag name = tag.getStringTag("Name");
|
||||||
if (name == null) return null;
|
if (name == null) return null;
|
||||||
|
|
||||||
CompoundTag properties = tag.get("Properties");
|
CompoundTag properties = tag.getCompoundTag("Properties");
|
||||||
if (properties == null) return name.getValue();
|
if (properties == null) return name.getValue();
|
||||||
|
|
||||||
StringJoiner joiner = new StringJoiner(",", name.getValue() + "[", "]");
|
StringJoiner joiner = new StringJoiner(",", name.getValue() + "[", "]");
|
||||||
|
@ -19,21 +19,19 @@
|
|||||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||||
|
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
|
||||||
public class SkullHandler implements BackwardsBlockEntityHandler {
|
public class SkullHandler implements BackwardsBlockEntityHandler {
|
||||||
private static final int SKULL_START = 5447;
|
private static final int SKULL_START = 5447;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
public CompoundTag transform(int blockId, CompoundTag tag) {
|
||||||
int diff = blockId - SKULL_START;
|
int diff = blockId - SKULL_START;
|
||||||
int pos = diff % 20;
|
int pos = diff % 20;
|
||||||
byte type = (byte) Math.floor(diff / 20f);
|
byte type = (byte) Math.floor(diff / 20f);
|
||||||
|
|
||||||
// Set type
|
// Set type
|
||||||
tag.put("SkullType", new ByteTag(type));
|
tag.putByte("SkullType", type);
|
||||||
|
|
||||||
// Remove wall skulls
|
// Remove wall skulls
|
||||||
if (pos < 4) {
|
if (pos < 4) {
|
||||||
@ -41,7 +39,7 @@ public class SkullHandler implements BackwardsBlockEntityHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add rotation for normal skulls
|
// Add rotation for normal skulls
|
||||||
tag.put("Rot", new ByteTag((byte) ((pos - 4) & 255)));
|
tag.putByte("Rot", (byte) ((pos - 4) & 255));
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
@ -20,22 +20,18 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_h
|
|||||||
|
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.EntityNameRewrites;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.EntityNameRewrites;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
|
||||||
|
|
||||||
public class SpawnerHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
public class SpawnerHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
public CompoundTag transform(int blockId, CompoundTag tag) {
|
||||||
Tag dataTag = tag.get("SpawnData");
|
CompoundTag dataTag = tag.getCompoundTag("SpawnData");
|
||||||
if (dataTag instanceof CompoundTag) {
|
if (dataTag != null) {
|
||||||
CompoundTag data = (CompoundTag) dataTag;
|
StringTag idTag = dataTag.getStringTag("id");
|
||||||
Tag idTag = data.get("id");
|
if (idTag != null) {
|
||||||
if (idTag instanceof StringTag) {
|
idTag.setValue(EntityNameRewrites.rewrite(idTag.getValue()));
|
||||||
StringTag s = (StringTag) idTag;
|
|
||||||
s.setValue(EntityNameRewrites.rewrite(s.getValue()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tag;
|
return tag;
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||||
|
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -25,6 +25,7 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2T
|
|||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.FlowerPotHandler;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.FlowerPotHandler;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||||
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.NoteBlockStorage;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||||
@ -45,7 +46,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
|||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||||
@ -56,6 +56,7 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.BlockIdData
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
|
||||||
import com.viaversion.viaversion.util.ComponentUtil;
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
import com.viaversion.viaversion.util.Pair;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -136,6 +137,17 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
else if (blockId >= 483 && blockId <= 498)
|
else if (blockId >= 483 && blockId <= 498)
|
||||||
blockId = blockId - 483 + 219;
|
blockId = blockId - 483 + 219;
|
||||||
|
|
||||||
|
if (blockId == 25) { // Note block
|
||||||
|
final NoteBlockStorage noteBlockStorage = wrapper.user().get(NoteBlockStorage.class);
|
||||||
|
|
||||||
|
final Position position = wrapper.get(Type.POSITION1_8, 0);
|
||||||
|
final Pair<Integer, Integer> update = noteBlockStorage.getNoteBlockUpdate(position);
|
||||||
|
if (update != null) { // Use values from block state update
|
||||||
|
wrapper.set(Type.UNSIGNED_BYTE, 0, update.key().shortValue());
|
||||||
|
wrapper.set(Type.UNSIGNED_BYTE, 1, update.value().shortValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wrapper.set(Type.VAR_INT, 0, blockId);
|
wrapper.set(Type.VAR_INT, 0, blockId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -189,6 +201,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
int blockState = wrapper.read(Type.VAR_INT);
|
int blockState = wrapper.read(Type.VAR_INT);
|
||||||
Position position = wrapper.get(Type.POSITION1_8, 0);
|
Position position = wrapper.get(Type.POSITION1_8, 0);
|
||||||
|
|
||||||
|
// Note block special treatment
|
||||||
|
if (blockState >= 249 && blockState <= 748) { // Note block states id range
|
||||||
|
wrapper.user().get(NoteBlockStorage.class).storeNoteBlockUpdate(position, blockState);
|
||||||
|
}
|
||||||
|
|
||||||
// Store blocks
|
// Store blocks
|
||||||
BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class);
|
BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class);
|
||||||
storage.checkAndStore(position, blockState);
|
storage.checkAndStore(position, blockState);
|
||||||
@ -265,15 +282,15 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
BackwardsBlockEntityProvider provider = Via.getManager().getProviders().get(BackwardsBlockEntityProvider.class);
|
BackwardsBlockEntityProvider provider = Via.getManager().getProviders().get(BackwardsBlockEntityProvider.class);
|
||||||
BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class);
|
BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class);
|
||||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||||
Tag idTag = tag.get("id");
|
StringTag idTag = tag.getStringTag("id");
|
||||||
if (idTag == null) continue;
|
if (idTag == null) continue;
|
||||||
|
|
||||||
String id = (String) idTag.getValue();
|
String id = idTag.getValue();
|
||||||
|
|
||||||
// Ignore if we don't handle it
|
// Ignore if we don't handle it
|
||||||
if (!provider.isHandled(id)) continue;
|
if (!provider.isHandled(id)) continue;
|
||||||
|
|
||||||
int sectionIndex = ((NumberTag) tag.get("y")).asInt() >> 4;
|
int sectionIndex = tag.getNumberTag("y").asInt() >> 4;
|
||||||
if (sectionIndex < 0 || sectionIndex > 15) {
|
if (sectionIndex < 0 || sectionIndex > 15) {
|
||||||
// 1.17 chunks
|
// 1.17 chunks
|
||||||
continue;
|
continue;
|
||||||
@ -281,9 +298,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
|
|
||||||
ChunkSection section = chunk.getSections()[sectionIndex];
|
ChunkSection section = chunk.getSections()[sectionIndex];
|
||||||
|
|
||||||
int x = ((NumberTag) tag.get("x")).asInt();
|
int x = tag.getNumberTag("x").asInt();
|
||||||
int y = ((NumberTag) tag.get("y")).asInt();
|
int y = tag.getNumberTag("y").asInt();
|
||||||
int z = ((NumberTag) tag.get("z")).asInt();
|
int z = tag.getNumberTag("z").asInt();
|
||||||
Position position = new Position(x, (short) y, z);
|
Position position = new Position(x, (short) y, z);
|
||||||
|
|
||||||
int block = section.palette(PaletteType.BLOCKS).idAt(x & 0xF, y & 0xF, z & 0xF);
|
int block = section.palette(PaletteType.BLOCKS).idAt(x & 0xF, y & 0xF, z & 0xF);
|
||||||
@ -489,7 +506,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
|
|
||||||
// Use tag to get original ID and data
|
// Use tag to get original ID and data
|
||||||
Tag originalIdTag;
|
Tag originalIdTag;
|
||||||
if (tag != null && (originalIdTag = tag.remove(extraNbtTag)) != null) {
|
if (tag != null && (originalIdTag = tag.remove(extraNbtTag)) instanceof NumberTag) {
|
||||||
rawId = ((NumberTag) originalIdTag).asInt();
|
rawId = ((NumberTag) originalIdTag).asInt();
|
||||||
gotRawIdFromTag = true;
|
gotRawIdFromTag = true;
|
||||||
}
|
}
|
||||||
@ -526,15 +543,15 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
if (isDamageable(item.identifier())) {
|
if (isDamageable(item.identifier())) {
|
||||||
Tag damageTag = tag.remove("Damage");
|
Tag damageTag = tag.remove("Damage");
|
||||||
if (!gotRawIdFromTag && damageTag instanceof IntTag) {
|
if (!gotRawIdFromTag && damageTag instanceof NumberTag) {
|
||||||
item.setData((short) (int) damageTag.getValue());
|
item.setData(((NumberTag) damageTag).asShort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.identifier() == 358) { // map
|
if (item.identifier() == 358) { // map
|
||||||
Tag mapTag = tag.remove("map");
|
Tag mapTag = tag.remove("map");
|
||||||
if (!gotRawIdFromTag && mapTag instanceof IntTag) {
|
if (!gotRawIdFromTag && mapTag instanceof NumberTag) {
|
||||||
item.setData((short) (int) mapTag.getValue());
|
item.setData(((NumberTag) mapTag).asShort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,11 +559,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
invertShieldAndBannerId(item, tag);
|
invertShieldAndBannerId(item, tag);
|
||||||
|
|
||||||
// Display Name now uses JSON
|
// Display Name now uses JSON
|
||||||
CompoundTag display = tag.get("display");
|
CompoundTag display = tag.getCompoundTag("display");
|
||||||
if (display != null) {
|
if (display != null) {
|
||||||
StringTag name = display.get("Name");
|
StringTag name = display.getStringTag("Name");
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
display.put(extraNbtTag + "|Name", new StringTag(name.getValue()));
|
display.putString(extraNbtTag + "|Name", name.getValue());
|
||||||
name.setValue(protocol.jsonToLegacy(name.getValue()));
|
name.setValue(protocol.jsonToLegacy(name.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -569,7 +586,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
}
|
}
|
||||||
if (!tag.contains("EntityTag")) {
|
if (!tag.contains("EntityTag")) {
|
||||||
CompoundTag entityTag = new CompoundTag();
|
CompoundTag entityTag = new CompoundTag();
|
||||||
entityTag.put("id", new StringTag(eggEntityId.get()));
|
entityTag.putString("id", eggEntityId.get());
|
||||||
tag.put("EntityTag", entityTag);
|
tag.put("EntityTag", entityTag);
|
||||||
}
|
}
|
||||||
return 0x17f0000; // 383 << 16;
|
return 0x17f0000; // 383 << 16;
|
||||||
@ -580,8 +597,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
|
|
||||||
private void rewriteCanPlaceToClient(CompoundTag tag, String tagName) {
|
private void rewriteCanPlaceToClient(CompoundTag tag, String tagName) {
|
||||||
// The tag was manually created incorrectly so ignore rewriting it
|
// The tag was manually created incorrectly so ignore rewriting it
|
||||||
if (!(tag.get(tagName) instanceof ListTag)) return;
|
ListTag blockTag = tag.getListTag(tagName);
|
||||||
ListTag blockTag = tag.get(tagName);
|
|
||||||
if (blockTag == null) return;
|
if (blockTag == null) return;
|
||||||
|
|
||||||
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
||||||
@ -604,7 +620,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
//TODO un-ugly all of this
|
//TODO un-ugly all of this
|
||||||
private void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnch) {
|
private void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnch) {
|
||||||
String key = storedEnch ? "StoredEnchantments" : "Enchantments";
|
String key = storedEnch ? "StoredEnchantments" : "Enchantments";
|
||||||
ListTag enchantments = tag.get(key);
|
ListTag enchantments = tag.getListTag(key);
|
||||||
if (enchantments == null) return;
|
if (enchantments == null) return;
|
||||||
|
|
||||||
ListTag noMapped = new ListTag(CompoundTag.class);
|
ListTag noMapped = new ListTag(CompoundTag.class);
|
||||||
@ -612,14 +628,18 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
List<Tag> lore = new ArrayList<>();
|
List<Tag> lore = new ArrayList<>();
|
||||||
boolean hasValidEnchants = false;
|
boolean hasValidEnchants = false;
|
||||||
for (Tag enchantmentEntryTag : enchantments.copy()) {
|
for (Tag enchantmentEntryTag : enchantments.copy()) {
|
||||||
CompoundTag enchantmentEntry = (CompoundTag) enchantmentEntryTag;
|
if (!(enchantmentEntryTag instanceof CompoundTag)) {
|
||||||
Tag idTag = enchantmentEntry.get("id");
|
|
||||||
if (!(idTag instanceof StringTag)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String newId = (String) idTag.getValue();
|
CompoundTag enchantmentEntry = (CompoundTag) enchantmentEntryTag;
|
||||||
NumberTag levelTag = enchantmentEntry.get("lvl");
|
StringTag idTag = enchantmentEntry.getStringTag("id");
|
||||||
|
if (idTag == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String newId = idTag.getValue();
|
||||||
|
NumberTag levelTag = enchantmentEntry.getNumberTag("lvl");
|
||||||
if (levelTag == null) {
|
if (levelTag == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -664,48 +684,47 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag newEntry = new CompoundTag();
|
CompoundTag newEntry = new CompoundTag();
|
||||||
newEntry.put("id", new ShortTag(oldId));
|
newEntry.putShort("id", oldId);
|
||||||
newEntry.put("lvl", new ShortTag(level));
|
newEntry.putShort("lvl", level);
|
||||||
newEnchantments.add(newEntry);
|
newEnchantments.add(newEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put here to hide empty enchantment from 1.14 rewrites
|
// Put here to hide empty enchantment from 1.14 rewrites
|
||||||
if (!storedEnch && !hasValidEnchants) {
|
if (!storedEnch && !hasValidEnchants) {
|
||||||
IntTag hideFlags = tag.get("HideFlags");
|
NumberTag hideFlags = tag.getNumberTag("HideFlags");
|
||||||
if (hideFlags == null) {
|
if (hideFlags == null) {
|
||||||
hideFlags = new IntTag();
|
hideFlags = new IntTag();
|
||||||
tag.put(extraNbtTag + "|DummyEnchant", new ByteTag());
|
tag.put(extraNbtTag + "|DummyEnchant", new ByteTag());
|
||||||
} else {
|
} else {
|
||||||
tag.put(extraNbtTag + "|OldHideFlags", new IntTag(hideFlags.asByte()));
|
tag.putInt(extraNbtTag + "|OldHideFlags", hideFlags.asByte());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newEnchantments.size() == 0) {
|
if (newEnchantments.isEmpty()) {
|
||||||
CompoundTag enchEntry = new CompoundTag();
|
CompoundTag enchEntry = new CompoundTag();
|
||||||
enchEntry.put("id", new ShortTag((short) 0));
|
enchEntry.putShort("id", (short) 0);
|
||||||
enchEntry.put("lvl", new ShortTag((short) 0));
|
enchEntry.putShort("lvl", (short) 0);
|
||||||
newEnchantments.add(enchEntry);
|
newEnchantments.add(enchEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
int value = hideFlags.asByte() | 1;
|
int value = hideFlags.asByte() | 1;
|
||||||
hideFlags.setValue(value);
|
tag.putInt("HideFlags", value);
|
||||||
tag.put("HideFlags", hideFlags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noMapped.size() != 0) {
|
if (!noMapped.isEmpty()) {
|
||||||
tag.put(extraNbtTag + "|" + key, noMapped);
|
tag.put(extraNbtTag + "|" + key, noMapped);
|
||||||
|
|
||||||
if (!lore.isEmpty()) {
|
if (!lore.isEmpty()) {
|
||||||
CompoundTag display = tag.get("display");
|
CompoundTag display = tag.getCompoundTag("display");
|
||||||
if (display == null) {
|
if (display == null) {
|
||||||
tag.put("display", display = new CompoundTag());
|
tag.put("display", display = new CompoundTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
ListTag loreTag = display.get("Lore");
|
ListTag loreTag = display.getListTag("Lore");
|
||||||
if (loreTag == null) {
|
if (loreTag == null) {
|
||||||
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
display.put("Lore", loreTag = new ListTag(StringTag.class));
|
||||||
tag.put(extraNbtTag + "|DummyLore", new ByteTag());
|
tag.put(extraNbtTag + "|DummyLore", new ByteTag());
|
||||||
} else if (loreTag.size() != 0) {
|
} else if (!loreTag.isEmpty()) {
|
||||||
ListTag oldLore = new ListTag(StringTag.class);
|
ListTag oldLore = new ListTag(StringTag.class);
|
||||||
for (Tag value : loreTag) {
|
for (Tag value : loreTag) {
|
||||||
oldLore.add(value.copy());
|
oldLore.add(value.copy());
|
||||||
@ -736,11 +755,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
// NBT Additions
|
// NBT Additions
|
||||||
if (isDamageable(item.identifier())) {
|
if (isDamageable(item.identifier())) {
|
||||||
if (tag == null) item.setTag(tag = new CompoundTag());
|
if (tag == null) item.setTag(tag = new CompoundTag());
|
||||||
tag.put("Damage", new IntTag(item.data()));
|
tag.putInt("Damage", item.data());
|
||||||
}
|
}
|
||||||
if (item.identifier() == 358) { // map
|
if (item.identifier() == 358) { // map
|
||||||
if (tag == null) item.setTag(tag = new CompoundTag());
|
if (tag == null) item.setTag(tag = new CompoundTag());
|
||||||
tag.put("map", new IntTag(item.data()));
|
tag.putInt("map", item.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
// NBT Changes
|
// NBT Changes
|
||||||
@ -749,13 +768,12 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
invertShieldAndBannerId(item, tag);
|
invertShieldAndBannerId(item, tag);
|
||||||
|
|
||||||
// Display Name now uses JSON
|
// Display Name now uses JSON
|
||||||
Tag display = tag.get("display");
|
CompoundTag display = tag.getCompoundTag("display");
|
||||||
if (display instanceof CompoundTag) {
|
if (display != null) {
|
||||||
CompoundTag displayTag = (CompoundTag) display;
|
StringTag name = display.getStringTag("Name");
|
||||||
StringTag name = displayTag.get("Name");
|
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
StringTag via = displayTag.remove(extraNbtTag + "|Name");
|
Tag via = display.remove(extraNbtTag + "|Name");
|
||||||
name.setValue(via != null ? via.getValue() : ComponentUtil.legacyToJsonString(name.getValue()));
|
name.setValue(via instanceof StringTag ? ((StringTag) via).getValue() : ComponentUtil.legacyToJsonString(name.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -768,9 +786,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
|
|
||||||
// Handle SpawnEggs
|
// Handle SpawnEggs
|
||||||
if (item.identifier() == 383) {
|
if (item.identifier() == 383) {
|
||||||
CompoundTag entityTag = tag.get("EntityTag");
|
CompoundTag entityTag = tag.getCompoundTag("EntityTag");
|
||||||
StringTag identifier;
|
StringTag identifier;
|
||||||
if (entityTag != null && (identifier = entityTag.get("id")) != null) {
|
if (entityTag != null && (identifier = entityTag.getStringTag("id")) != null) {
|
||||||
rawId = SpawnEggRewriter.getSpawnEggId(identifier.getValue());
|
rawId = SpawnEggRewriter.getSpawnEggId(identifier.getValue());
|
||||||
if (rawId == -1) {
|
if (rawId == -1) {
|
||||||
rawId = 25100288; // Bat fallback
|
rawId = 25100288; // Bat fallback
|
||||||
@ -804,8 +822,10 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
int newId = -1;
|
int newId = -1;
|
||||||
if (protocol.getMappingData().getItemMappings().inverse().getNewId(rawId) == -1) {
|
if (protocol.getMappingData().getItemMappings().inverse().getNewId(rawId) == -1) {
|
||||||
if (!isDamageable(item.identifier()) && item.identifier() != 358) { // Map
|
if (!isDamageable(item.identifier()) && item.identifier() != 358) { // Map
|
||||||
if (tag == null) item.setTag(tag = new CompoundTag());
|
if (tag == null) {
|
||||||
tag.put(extraNbtTag, new IntTag(originalId)); // Data will be lost, saving original id
|
item.setTag(tag = new CompoundTag());
|
||||||
|
}
|
||||||
|
tag.putInt(extraNbtTag, originalId); // Data will be lost, saving original id
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.identifier() == 229) { // purple shulker box
|
if (item.identifier() == 229) { // purple shulker box
|
||||||
@ -832,11 +852,12 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void rewriteCanPlaceToServer(CompoundTag tag, String tagName) {
|
private void rewriteCanPlaceToServer(CompoundTag tag, String tagName) {
|
||||||
if (!(tag.get(tagName) instanceof ListTag)) return;
|
if (tag.getListTag(tagName) == null) return;
|
||||||
|
|
||||||
ListTag blockTag = tag.remove(extraNbtTag + "|" + tagName);
|
ListTag blockTag = tag.remove(extraNbtTag + "|" + tagName);
|
||||||
if (blockTag != null) {
|
if (blockTag != null) {
|
||||||
tag.put(tagName, blockTag.copy());
|
tag.put(tagName, blockTag.copy());
|
||||||
} else if ((blockTag = tag.get(tagName)) != null) {
|
} else if ((blockTag = tag.getListTag(tagName)) != null) {
|
||||||
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
||||||
for (Tag oldTag : blockTag) {
|
for (Tag oldTag : blockTag) {
|
||||||
Object value = oldTag.getValue();
|
Object value = oldTag.getValue();
|
||||||
@ -863,15 +884,15 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
|
|
||||||
private void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnch) {
|
private void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnch) {
|
||||||
String key = storedEnch ? "StoredEnchantments" : "Enchantments";
|
String key = storedEnch ? "StoredEnchantments" : "Enchantments";
|
||||||
ListTag enchantments = tag.get(storedEnch ? key : "ench");
|
ListTag enchantments = tag.getListTag(storedEnch ? key : "ench");
|
||||||
if (enchantments == null) return;
|
if (enchantments == null) return;
|
||||||
|
|
||||||
ListTag newEnchantments = new ListTag(CompoundTag.class);
|
ListTag newEnchantments = new ListTag(CompoundTag.class);
|
||||||
boolean dummyEnchant = false;
|
boolean dummyEnchant = false;
|
||||||
if (!storedEnch) {
|
if (!storedEnch) {
|
||||||
IntTag hideFlags = tag.remove(extraNbtTag + "|OldHideFlags");
|
Tag hideFlags = tag.remove(extraNbtTag + "|OldHideFlags");
|
||||||
if (hideFlags != null) {
|
if (hideFlags instanceof IntTag) {
|
||||||
tag.put("HideFlags", new IntTag(hideFlags.asByte()));
|
tag.putInt("HideFlags", ((NumberTag) hideFlags).asByte());
|
||||||
dummyEnchant = true;
|
dummyEnchant = true;
|
||||||
} else if (tag.remove(extraNbtTag + "|DummyEnchant") != null) {
|
} else if (tag.remove(extraNbtTag + "|DummyEnchant") != null) {
|
||||||
tag.remove("HideFlags");
|
tag.remove("HideFlags");
|
||||||
@ -880,42 +901,50 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Tag enchEntry : enchantments) {
|
for (Tag enchEntry : enchantments) {
|
||||||
|
if (!(enchEntry instanceof CompoundTag)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag entryTag = (CompoundTag) enchEntry;
|
||||||
|
NumberTag idTag = entryTag.getNumberTag("id");
|
||||||
|
NumberTag levelTag = entryTag.getNumberTag("lvl");
|
||||||
CompoundTag enchantmentEntry = new CompoundTag();
|
CompoundTag enchantmentEntry = new CompoundTag();
|
||||||
short oldId = ((NumberTag) ((CompoundTag) enchEntry).get("id")).asShort();
|
short oldId = idTag != null ? idTag.asShort() : 0;
|
||||||
short level = ((NumberTag) ((CompoundTag) enchEntry).get("lvl")).asShort();
|
short level = levelTag != null ? levelTag.asShort() : 0;
|
||||||
if (dummyEnchant && oldId == 0 && level == 0) {
|
if (dummyEnchant && oldId == 0 && level == 0) {
|
||||||
continue; // Skip dummy enchatment
|
continue; // Skip dummy enchatment
|
||||||
}
|
}
|
||||||
|
|
||||||
String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId);
|
String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId);
|
||||||
if (newId == null) {
|
if (newId == null) {
|
||||||
newId = "viaversion:legacy/" + oldId;
|
newId = "viaversion:legacy/" + oldId;
|
||||||
}
|
}
|
||||||
enchantmentEntry.put("id", new StringTag(newId));
|
enchantmentEntry.putString("id", newId);
|
||||||
|
|
||||||
enchantmentEntry.put("lvl", new ShortTag(level));
|
enchantmentEntry.putShort("lvl", level);
|
||||||
newEnchantments.add(enchantmentEntry);
|
newEnchantments.add(enchantmentEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
ListTag noMapped = tag.remove(extraNbtTag + "|Enchantments");
|
Tag noMapped = tag.remove(extraNbtTag + "|Enchantments");
|
||||||
if (noMapped != null) {
|
if (noMapped instanceof ListTag) {
|
||||||
for (Tag value : noMapped) {
|
for (Tag value : ((ListTag) noMapped)) {
|
||||||
newEnchantments.add(value);
|
newEnchantments.add(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag display = tag.get("display");
|
CompoundTag display = tag.getCompoundTag("display");
|
||||||
if (display == null) {
|
if (display == null) {
|
||||||
tag.put("display", display = new CompoundTag());
|
tag.put("display", display = new CompoundTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
ListTag oldLore = tag.remove(extraNbtTag + "|OldLore");
|
Tag oldLore = tag.remove(extraNbtTag + "|OldLore");
|
||||||
if (oldLore != null) {
|
if (oldLore instanceof ListTag) {
|
||||||
ListTag lore = display.get("Lore");
|
ListTag lore = display.getListTag("Lore");
|
||||||
if (lore == null) {
|
if (lore == null) {
|
||||||
tag.put("Lore", lore = new ListTag());
|
tag.put("Lore", lore = new ListTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
lore.setValue(oldLore.getValue());
|
lore.setValue(((ListTag) oldLore).getValue());
|
||||||
} else if (tag.remove(extraNbtTag + "|DummyLore") != null) {
|
} else if (tag.remove(extraNbtTag + "|DummyLore") != null) {
|
||||||
display.remove("Lore");
|
display.remove("Lore");
|
||||||
if (display.isEmpty()) {
|
if (display.isEmpty()) {
|
||||||
@ -932,24 +961,22 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
private void invertShieldAndBannerId(Item item, CompoundTag tag) {
|
private void invertShieldAndBannerId(Item item, CompoundTag tag) {
|
||||||
if (item.identifier() != 442 && item.identifier() != 425) return;
|
if (item.identifier() != 442 && item.identifier() != 425) return;
|
||||||
|
|
||||||
Tag blockEntityTag = tag.get("BlockEntityTag");
|
CompoundTag blockEntityTag = tag.getCompoundTag("BlockEntityTag");
|
||||||
if (!(blockEntityTag instanceof CompoundTag)) return;
|
if (blockEntityTag == null) return;
|
||||||
|
|
||||||
CompoundTag blockEntityCompoundTag = (CompoundTag) blockEntityTag;
|
NumberTag base = blockEntityTag.getNumberTag("Base");
|
||||||
Tag base = blockEntityCompoundTag.get("Base");
|
if (base != null) {
|
||||||
if (base instanceof IntTag) {
|
blockEntityTag.putInt("Base", 15 - base.asInt()); // Invert color id
|
||||||
IntTag baseTag = (IntTag) base;
|
|
||||||
baseTag.setValue(15 - baseTag.asInt()); // invert color id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag patterns = blockEntityCompoundTag.get("Patterns");
|
ListTag patterns = blockEntityTag.getListTag("Patterns");
|
||||||
if (patterns instanceof ListTag) {
|
if (patterns != null) {
|
||||||
ListTag patternsTag = (ListTag) patterns;
|
for (Tag pattern : patterns) {
|
||||||
for (Tag pattern : patternsTag) {
|
|
||||||
if (!(pattern instanceof CompoundTag)) continue;
|
if (!(pattern instanceof CompoundTag)) continue;
|
||||||
|
|
||||||
IntTag colorTag = ((CompoundTag) pattern).get("Color");
|
CompoundTag patternTag = (CompoundTag) pattern;
|
||||||
colorTag.setValue(15 - colorTag.asInt()); // Invert color id
|
NumberTag colorTag = patternTag.getNumberTag("Color");
|
||||||
|
patternTag.putInt("Color", 15 - colorTag.asInt()); // Invert color id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.EntityType
|
|||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.ParticleMapping;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.ParticleMapping;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||||
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.NoteBlockStorage;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerPositionStorage1_13;
|
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerPositionStorage1_13;
|
||||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
@ -197,7 +198,10 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
|||||||
map(Type.INT); // 0 - Dimension ID
|
map(Type.INT); // 0 - Dimension ID
|
||||||
|
|
||||||
handler(getDimensionHandler(0));
|
handler(getDimensionHandler(0));
|
||||||
handler(wrapper -> wrapper.user().get(BackwardsBlockStorage.class).clear());
|
handler(wrapper -> {
|
||||||
|
wrapper.user().get(BackwardsBlockStorage.class).clear();
|
||||||
|
wrapper.user().get(NoteBlockStorage.class).clear();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -61,12 +61,10 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
|||||||
public void register() {
|
public void register() {
|
||||||
handler(packetWrapper -> {
|
handler(packetWrapper -> {
|
||||||
packetWrapper.cancel();
|
packetWrapper.cancel();
|
||||||
packetWrapper.create(0x02, new PacketHandler() { // Plugin response
|
// Plugin response
|
||||||
@Override
|
packetWrapper.create(0x02, wrapper -> {
|
||||||
public void handle(PacketWrapper newWrapper) throws Exception {
|
wrapper.write(Type.VAR_INT, packetWrapper.read(Type.VAR_INT)); // Packet id
|
||||||
newWrapper.write(Type.VAR_INT, packetWrapper.read(Type.VAR_INT)); // Packet id
|
wrapper.write(Type.BOOLEAN, false); // Success
|
||||||
newWrapper.write(Type.BOOLEAN, false); // Success
|
|
||||||
}
|
|
||||||
}).sendToServer(Protocol1_12_2To1_13.class);
|
}).sendToServer(Protocol1_12_2To1_13.class);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -392,7 +390,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
|||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
//Information from https://wiki.vg/index.php?title=Plugin_channels&oldid=14089
|
//Information from https://wiki.vg/index.php?title=Plugin_channels&oldid=14089
|
||||||
//The Notchain client only uses this for command block minecarts and uses MC|AutoCmd for blocks, but the Notchian server still accepts it for either.
|
//The Notchain client only uses this for command block minecarts and uses MC|AutoCmd for blocks, but the Notchian server still accepts it for either.
|
||||||
//Maybe older versions used this and we need to implement this? The issues is that we would have to save the command block types
|
//Maybe older versions used this and we need to implement this? The issue is that we would have to save the command block types
|
||||||
wrapper.setPacketType(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK);
|
wrapper.setPacketType(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK);
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
ViaBackwards.getPlatform().getLogger().warning("Client send MC|AdvCmd custom payload to update command block, weird!");
|
ViaBackwards.getPlatform().getLogger().warning("Client send MC|AdvCmd custom payload to update command block, weird!");
|
||||||
|
@ -29,9 +29,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import com.viaversion.viaversion.api.platform.providers.Provider;
|
import com.viaversion.viaversion.api.platform.providers.Provider;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -65,12 +63,12 @@ public class BackwardsBlockEntityProvider implements Provider {
|
|||||||
* @param tag The block entity tag
|
* @param tag The block entity tag
|
||||||
*/
|
*/
|
||||||
public CompoundTag transform(UserConnection user, Position position, CompoundTag tag) throws Exception {
|
public CompoundTag transform(UserConnection user, Position position, CompoundTag tag) throws Exception {
|
||||||
final Tag idTag = tag.get("id");
|
final StringTag idTag = tag.getStringTag("id");
|
||||||
if (!(idTag instanceof StringTag)) {
|
if (idTag == null) {
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
String id = (String) idTag.getValue();
|
String id = idTag.getValue();
|
||||||
BackwardsBlockEntityHandler handler = handlers.get(id);
|
BackwardsBlockEntityHandler handler = handlers.get(id);
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
return tag;
|
return tag;
|
||||||
@ -82,7 +80,7 @@ public class BackwardsBlockEntityProvider implements Provider {
|
|||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
return handler.transform(user, blockId, tag);
|
return handler.transform(blockId, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,15 +92,17 @@ public class BackwardsBlockEntityProvider implements Provider {
|
|||||||
*/
|
*/
|
||||||
public CompoundTag transform(UserConnection user, Position position, String id) throws Exception {
|
public CompoundTag transform(UserConnection user, Position position, String id) throws Exception {
|
||||||
CompoundTag tag = new CompoundTag();
|
CompoundTag tag = new CompoundTag();
|
||||||
tag.put("id", new StringTag(id));
|
tag.putString("id", id);
|
||||||
tag.put("x", new IntTag(Math.toIntExact(position.x())));
|
tag.putInt("x", Math.toIntExact(position.x()));
|
||||||
tag.put("y", new IntTag(Math.toIntExact(position.y())));
|
tag.putInt("y", Math.toIntExact(position.y()));
|
||||||
tag.put("z", new IntTag(Math.toIntExact(position.z())));
|
tag.putInt("z", Math.toIntExact(position.z()));
|
||||||
|
|
||||||
return this.transform(user, position, tag);
|
return this.transform(user, position, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
public interface BackwardsBlockEntityHandler {
|
public interface BackwardsBlockEntityHandler {
|
||||||
CompoundTag transform(UserConnection user, int blockId, CompoundTag tag);
|
|
||||||
|
CompoundTag transform(int blockId, CompoundTag tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import com.viaversion.viaversion.libs.fastutil.ints.IntOpenHashSet;
|
|||||||
import com.viaversion.viaversion.libs.fastutil.ints.IntSet;
|
import com.viaversion.viaversion.libs.fastutil.ints.IntSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class BackwardsBlockStorage implements StorableObject {
|
public class BackwardsBlockStorage implements StorableObject {
|
||||||
// This BlockStorage is very exclusive (;
|
// This BlockStorage is very exclusive (;
|
||||||
@ -77,11 +78,7 @@ public class BackwardsBlockStorage implements StorableObject {
|
|||||||
blocks.put(position, block);
|
blocks.put(position, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWelcome(int block) {
|
public @Nullable Integer get(Position position) {
|
||||||
return WHITELIST.contains(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer get(Position position) {
|
|
||||||
return blocks.get(position);
|
return blocks.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||||
|
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
|
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||||
|
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
||||||
|
import com.viaversion.viaversion.util.Pair;
|
||||||
|
|
||||||
|
public class NoteBlockStorage implements StorableObject {
|
||||||
|
|
||||||
|
private static final int MAX_NOTE_ID = 24;
|
||||||
|
|
||||||
|
private final Object2IntMap<Position> noteBlockUpdates = new Object2IntOpenHashMap<>();
|
||||||
|
|
||||||
|
public void storeNoteBlockUpdate(final Position position, final int blockStateId) {
|
||||||
|
noteBlockUpdates.put(position, blockStateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pair<Integer, Integer> getNoteBlockUpdate(final Position position) {
|
||||||
|
if (!noteBlockUpdates.containsKey(position)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int relativeBlockState = noteBlockUpdates.removeInt(position) - 249;
|
||||||
|
relativeBlockState = relativeBlockState / 2; // Get rid of powered state
|
||||||
|
|
||||||
|
return new Pair<>(relativeBlockState / MAX_NOTE_ID + 1, relativeBlockState % MAX_NOTE_ID + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
noteBlockUpdates.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -20,7 +20,4 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
|||||||
import com.viaversion.viabackwards.api.entities.storage.PlayerPositionStorage;
|
import com.viaversion.viabackwards.api.entities.storage.PlayerPositionStorage;
|
||||||
|
|
||||||
public class PlayerPositionStorage1_13 extends PlayerPositionStorage {
|
public class PlayerPositionStorage1_13 extends PlayerPositionStorage {
|
||||||
|
|
||||||
public PlayerPositionStorage1_13() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -472,8 +472,8 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
// Lore now uses JSON
|
// Lore now uses JSON
|
||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
CompoundTag display;
|
CompoundTag display;
|
||||||
if (tag != null && (display = tag.get("display")) != null) {
|
if (tag != null && (display = tag.getCompoundTag("display")) != null) {
|
||||||
ListTag lore = display.get("Lore");
|
ListTag lore = display.getListTag("Lore");
|
||||||
if (lore != null) {
|
if (lore != null) {
|
||||||
saveListTag(display, lore, "Lore");
|
saveListTag(display, lore, "Lore");
|
||||||
|
|
||||||
@ -500,9 +500,9 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
// Lore now uses JSON
|
// Lore now uses JSON
|
||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
CompoundTag display;
|
CompoundTag display;
|
||||||
if (tag != null && (display = tag.get("display")) != null) {
|
if (tag != null && (display = tag.getCompoundTag("display")) != null) {
|
||||||
// Transform to json if no backup tag is found (else process that in the super method)
|
// Transform to json if no backup tag is found (else process that in the super method)
|
||||||
ListTag lore = display.get("Lore");
|
ListTag lore = display.getListTag("Lore");
|
||||||
if (lore != null && !hasBackupTag(display, "Lore")) {
|
if (lore != null && !hasBackupTag(display, "Lore")) {
|
||||||
for (Tag loreEntry : lore) {
|
for (Tag loreEntry : lore) {
|
||||||
if (loreEntry instanceof StringTag) {
|
if (loreEntry instanceof StringTag) {
|
||||||
|
@ -21,8 +21,8 @@ import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
|||||||
import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
|
import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping;
|
import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn;
|
import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
|
@ -19,8 +19,8 @@ package com.viaversion.viabackwards.protocol.protocol1_14to1_14_1.packets;
|
|||||||
|
|
||||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1_14_1;
|
import com.viaversion.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1_14_1;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
@ -252,7 +252,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleBlockEntity(CompoundTag tag) {
|
private void handleBlockEntity(CompoundTag tag) {
|
||||||
StringTag idTag = tag.get("id");
|
StringTag idTag = tag.getStringTag("id");
|
||||||
if (idTag == null) return;
|
if (idTag == null) return;
|
||||||
|
|
||||||
String id = idTag.getValue();
|
String id = idTag.getValue();
|
||||||
@ -262,7 +262,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
|
|
||||||
// Target -> target_uuid
|
// Target -> target_uuid
|
||||||
UUID targetUuid = UUIDUtil.fromIntArray((int[]) targetUuidTag.getValue());
|
UUID targetUuid = UUIDUtil.fromIntArray((int[]) targetUuidTag.getValue());
|
||||||
tag.put("target_uuid", new StringTag(targetUuid.toString()));
|
tag.putString("target_uuid", targetUuid.toString());
|
||||||
} else if (id.equals("minecraft:skull")) {
|
} else if (id.equals("minecraft:skull")) {
|
||||||
Tag skullOwnerTag = tag.remove("SkullOwner");
|
Tag skullOwnerTag = tag.remove("SkullOwner");
|
||||||
if (!(skullOwnerTag instanceof CompoundTag)) return;
|
if (!(skullOwnerTag instanceof CompoundTag)) return;
|
||||||
@ -271,7 +271,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
Tag ownerUuidTag = skullOwnerCompoundTag.remove("Id");
|
Tag ownerUuidTag = skullOwnerCompoundTag.remove("Id");
|
||||||
if (ownerUuidTag instanceof IntArrayTag) {
|
if (ownerUuidTag instanceof IntArrayTag) {
|
||||||
UUID ownerUuid = UUIDUtil.fromIntArray((int[]) ownerUuidTag.getValue());
|
UUID ownerUuid = UUIDUtil.fromIntArray((int[]) ownerUuidTag.getValue());
|
||||||
skullOwnerCompoundTag.put("Id", new StringTag(ownerUuid.toString()));
|
skullOwnerCompoundTag.putString("Id", ownerUuid.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// SkullOwner -> Owner
|
// SkullOwner -> Owner
|
||||||
@ -297,22 +297,21 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
|
|
||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
if (item.identifier() == 771 && tag != null) {
|
if (item.identifier() == 771 && tag != null) {
|
||||||
Tag ownerTag = tag.get("SkullOwner");
|
CompoundTag ownerTag = tag.getCompoundTag("SkullOwner");
|
||||||
if (ownerTag instanceof CompoundTag) {
|
if (ownerTag != null) {
|
||||||
CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
|
IntArrayTag idTag = ownerTag.getIntArrayTag("Id");
|
||||||
Tag idTag = ownerCompundTag.get("Id");
|
if (idTag != null) {
|
||||||
if (idTag instanceof IntArrayTag) {
|
UUID ownerUuid = UUIDUtil.fromIntArray(idTag.getValue());
|
||||||
UUID ownerUuid = UUIDUtil.fromIntArray((int[]) idTag.getValue());
|
ownerTag.putString("Id", ownerUuid.toString());
|
||||||
ownerCompundTag.put("Id", new StringTag(ownerUuid.toString()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle hover event changes in written book pages
|
// Handle hover event changes in written book pages
|
||||||
if (item.identifier() == 759 && tag != null) {
|
if (item.identifier() == 759 && tag != null) {
|
||||||
Tag pagesTag = tag.get("pages");
|
ListTag pagesTag = tag.getListTag("pages");
|
||||||
if (pagesTag instanceof ListTag) {
|
if (pagesTag != null) {
|
||||||
for (Tag page : ((ListTag) pagesTag)) {
|
for (Tag page : pagesTag) {
|
||||||
if (!(page instanceof StringTag)) {
|
if (!(page instanceof StringTag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -338,13 +337,12 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
|
|
||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
if (identifier == 771 && tag != null) {
|
if (identifier == 771 && tag != null) {
|
||||||
Tag ownerTag = tag.get("SkullOwner");
|
CompoundTag ownerTag = tag.getCompoundTag("SkullOwner");
|
||||||
if (ownerTag instanceof CompoundTag) {
|
if (ownerTag != null) {
|
||||||
CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
|
StringTag idTag = ownerTag.getStringTag("Id");
|
||||||
Tag idTag = ownerCompundTag.get("Id");
|
if (idTag != null) {
|
||||||
if (idTag instanceof StringTag) {
|
UUID ownerUuid = UUID.fromString(idTag.getValue());
|
||||||
UUID ownerUuid = UUID.fromString((String) idTag.getValue());
|
ownerTag.put("Id", new IntArrayTag(UUIDUtil.toIntArray(ownerUuid)));
|
||||||
ownerCompundTag.put("Id", new IntArrayTag(UUIDUtil.toIntArray(ownerUuid)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
|||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
@ -104,9 +103,7 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
|
|||||||
public void register() {
|
public void register() {
|
||||||
map(Type.POSITION1_14);
|
map(Type.POSITION1_14);
|
||||||
map(Type.UNSIGNED_BYTE);
|
map(Type.UNSIGNED_BYTE);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> handleBlockEntity(wrapper.passthrough(Type.NAMED_COMPOUND_TAG)));
|
||||||
handleBlockEntity(wrapper.passthrough(Type.NAMED_COMPOUND_TAG));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -140,29 +137,28 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleBlockEntity(CompoundTag tag) {
|
private void handleBlockEntity(CompoundTag tag) {
|
||||||
StringTag idTag = tag.get("id");
|
StringTag idTag = tag.getStringTag("id");
|
||||||
if (idTag == null) return;
|
if (idTag == null) return;
|
||||||
if (idTag.getValue().equals("minecraft:skull")) {
|
if (idTag.getValue().equals("minecraft:skull")) {
|
||||||
// Workaround an old client bug: MC-68487
|
// Workaround an old client bug: MC-68487
|
||||||
Tag skullOwnerTag = tag.get("SkullOwner");
|
CompoundTag skullOwnerTag = tag.getCompoundTag("SkullOwner");
|
||||||
if (!(skullOwnerTag instanceof CompoundTag)) return;
|
if (skullOwnerTag == null) return;
|
||||||
|
|
||||||
CompoundTag skullOwnerCompoundTag = (CompoundTag) skullOwnerTag;
|
if (!skullOwnerTag.contains("Id")) return;
|
||||||
if (!skullOwnerCompoundTag.contains("Id")) return;
|
|
||||||
|
|
||||||
CompoundTag properties = skullOwnerCompoundTag.get("Properties");
|
CompoundTag properties = skullOwnerTag.getCompoundTag("Properties");
|
||||||
if (properties == null) return;
|
if (properties == null) return;
|
||||||
|
|
||||||
ListTag textures = properties.get("textures");
|
ListTag textures = properties.getListTag("textures");
|
||||||
if (textures == null) return;
|
if (textures == null) return;
|
||||||
|
|
||||||
CompoundTag first = textures.size() > 0 ? textures.get(0) : null;
|
CompoundTag first = !textures.isEmpty() ? textures.get(0) : null;
|
||||||
if (first == null) return;
|
if (first == null) return;
|
||||||
|
|
||||||
// Make the client cache the skinprofile over this uuid
|
// Make the client cache the skinprofile over this uuid
|
||||||
int hashCode = first.get("Value").getValue().hashCode();
|
int hashCode = first.get("Value").getValue().hashCode();
|
||||||
int[] uuidIntArray = {hashCode, 0, 0, 0}; //TODO split texture in 4 for a lower collision chance
|
int[] uuidIntArray = {hashCode, 0, 0, 0}; //TODO split texture in 4 for a lower collision chance
|
||||||
skullOwnerCompoundTag.put("Id", new IntArrayTag(uuidIntArray));
|
skullOwnerTag.put("Id", new IntArrayTag(uuidIntArray));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,13 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
|||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.*;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.EntityPackets;
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.EntityPackets;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2, Protocol1_16_1To1_16_2> {
|
public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2, Protocol1_16_1To1_16_2> {
|
||||||
|
@ -361,7 +361,7 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
|
|||||||
}
|
}
|
||||||
|
|
||||||
chunk.getBlockEntities().removeIf(compound -> {
|
chunk.getBlockEntities().removeIf(compound -> {
|
||||||
NumberTag tag = compound.get("y");
|
NumberTag tag = compound.getNumberTag("y");
|
||||||
return tag != null && (tag.asInt() < 0 || tag.asInt() > 255);
|
return tag != null && (tag.asInt() < 0 || tag.asInt() > 255);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -29,11 +29,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
|||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.*;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17;
|
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17;
|
||||||
|
|
||||||
@ -209,17 +205,17 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void reduceExtendedHeight(CompoundTag tag, boolean warn) {
|
private void reduceExtendedHeight(CompoundTag tag, boolean warn) {
|
||||||
IntTag minY = tag.get("min_y");
|
NumberTag minY = tag.getNumberTag("min_y");
|
||||||
IntTag height = tag.get("height");
|
NumberTag height = tag.getNumberTag("height");
|
||||||
IntTag logicalHeight = tag.get("logical_height");
|
NumberTag logicalHeight = tag.getNumberTag("logical_height");
|
||||||
if (minY.asInt() != 0 || height.asInt() > 256 || logicalHeight.asInt() > 256) {
|
if (minY.asInt() != 0 || height.asInt() > 256 || logicalHeight.asInt() > 256) {
|
||||||
if (warn && !warned) {
|
if (warn && !warned) {
|
||||||
ViaBackwards.getPlatform().getLogger().warning("Increased world height is NOT SUPPORTED for 1.16 players and below. They will see a void below y 0 and above 256");
|
ViaBackwards.getPlatform().getLogger().warning("Increased world height is NOT SUPPORTED for 1.16 players and below. They will see a void below y 0 and above 256");
|
||||||
warned = true;
|
warned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
height.setValue(Math.min(256, height.asInt()));
|
tag.putInt("height", Math.min(256, height.asInt()));
|
||||||
logicalHeight.setValue(Math.min(256, logicalHeight.asInt()));
|
tag.putInt("logical_height", Math.min(256, logicalHeight.asInt()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,6 @@ import com.viaversion.viaversion.api.type.Type;
|
|||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
|
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
||||||
@ -152,13 +150,13 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
|
|||||||
final Position pos = wrapper.get(Type.POSITION1_14, 0);
|
final Position pos = wrapper.get(Type.POSITION1_14, 0);
|
||||||
|
|
||||||
// The protocol converters downstream rely on this field, let's add it back
|
// The protocol converters downstream rely on this field, let's add it back
|
||||||
newTag.put("id", new StringTag(Key.namespaced(identifier)));
|
newTag.putString("id", Key.namespaced(identifier));
|
||||||
|
|
||||||
// Weird glitches happen with the 1.17 client and below if these fields are missing
|
// Weird glitches happen with the 1.17 client and below if these fields are missing
|
||||||
// Some examples are block entity models becoming invisible (e.g.: signs, banners)
|
// Some examples are block entity models becoming invisible (e.g.: signs, banners)
|
||||||
newTag.put("x", new IntTag(pos.x()));
|
newTag.putInt("x", pos.x());
|
||||||
newTag.put("y", new IntTag(pos.y()));
|
newTag.putInt("y", pos.y());
|
||||||
newTag.put("z", new IntTag(pos.z()));
|
newTag.putInt("z", pos.z());
|
||||||
|
|
||||||
handleSpawner(id, newTag);
|
handleSpawner(id, newTag);
|
||||||
wrapper.write(Type.UNSIGNED_BYTE, (short) mappedId);
|
wrapper.write(Type.UNSIGNED_BYTE, (short) mappedId);
|
||||||
@ -210,10 +208,10 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
|
|||||||
}
|
}
|
||||||
|
|
||||||
blockEntityTags.add(tag);
|
blockEntityTags.add(tag);
|
||||||
tag.put("x", new IntTag((oldChunk.getX() << 4) + blockEntity.sectionX()));
|
tag.putInt("x", (oldChunk.getX() << 4) + blockEntity.sectionX());
|
||||||
tag.put("y", new IntTag(blockEntity.y()));
|
tag.putInt("y", blockEntity.y());
|
||||||
tag.put("z", new IntTag((oldChunk.getZ() << 4) + blockEntity.sectionZ()));
|
tag.putInt("z", (oldChunk.getZ() << 4) + blockEntity.sectionZ());
|
||||||
tag.put("id", new StringTag(Key.namespaced(id)));
|
tag.putString("id", Key.namespaced(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
final Chunk chunk = new BaseChunk(oldChunk.getX(), oldChunk.getZ(), true, false, mask,
|
final Chunk chunk = new BaseChunk(oldChunk.getX(), oldChunk.getZ(), true, false, mask,
|
||||||
@ -250,9 +248,9 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
|
|||||||
|
|
||||||
private void handleSpawner(final int typeId, final CompoundTag tag) {
|
private void handleSpawner(final int typeId, final CompoundTag tag) {
|
||||||
if (typeId == 8) {
|
if (typeId == 8) {
|
||||||
final CompoundTag spawnData = tag.get("SpawnData");
|
final CompoundTag spawnData = tag.getCompoundTag("SpawnData");
|
||||||
final CompoundTag entity;
|
final CompoundTag entity;
|
||||||
if (spawnData != null && (entity = spawnData.get("entity")) != null) {
|
if (spawnData != null && (entity = spawnData.getCompoundTag("entity")) != null) {
|
||||||
tag.put("SpawnData", entity);
|
tag.put("SpawnData", entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,10 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
|||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.*;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
||||||
|
|
||||||
public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_18, Protocol1_17_1To1_18> {
|
public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_18, Protocol1_17_1To1_18> {
|
||||||
@ -68,8 +71,8 @@ public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The client just needs something
|
// The client just needs something
|
||||||
biomeCompound.put("depth", new FloatTag(0.125F));
|
biomeCompound.putFloat("depth", 0.125F);
|
||||||
biomeCompound.put("scale", new FloatTag(0.05F));
|
biomeCompound.putFloat("scale", 0.05F);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track amount of biomes sent
|
// Track amount of biomes sent
|
||||||
|
@ -105,8 +105,8 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
|
|||||||
ListTag pagesTag;
|
ListTag pagesTag;
|
||||||
StringTag titleTag = null;
|
StringTag titleTag = null;
|
||||||
// Sanity checks
|
// Sanity checks
|
||||||
if (tag == null || (pagesTag = tag.get("pages")) == null
|
if (tag == null || (pagesTag = tag.getListTag("pages")) == null
|
||||||
|| (signing && (titleTag = tag.get("title")) == null)) {
|
|| (signing && (titleTag = tag.getStringTag("title")) == null)) {
|
||||||
wrapper.write(Type.VAR_INT, 0); // Pages length
|
wrapper.write(Type.VAR_INT, 0); // Pages length
|
||||||
wrapper.write(Type.BOOLEAN, false); // Optional title
|
wrapper.write(Type.BOOLEAN, false); // Optional title
|
||||||
return;
|
return;
|
||||||
@ -131,10 +131,6 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
|
|||||||
// Write optional title
|
// Write optional title
|
||||||
wrapper.write(Type.BOOLEAN, signing);
|
wrapper.write(Type.BOOLEAN, signing);
|
||||||
if (signing) {
|
if (signing) {
|
||||||
if (titleTag == null) {
|
|
||||||
titleTag = tag.get("title");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Limit title length
|
// Limit title length
|
||||||
String title = titleTag.getValue();
|
String title = titleTag.getValue();
|
||||||
if (title.length() > MAX_TITLE_LENGTH) {
|
if (title.length() > MAX_TITLE_LENGTH) {
|
||||||
|
@ -56,7 +56,6 @@ import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
|||||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||||
import com.viaversion.viaversion.util.Pair;
|
import com.viaversion.viaversion.util.Pair;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -33,7 +33,11 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
|||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.*;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
|
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
|
||||||
|
|
||||||
@ -149,7 +153,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
|
|||||||
final ListTag biomes = biomeRegistry.get("value");
|
final ListTag biomes = biomeRegistry.get("value");
|
||||||
for (final Tag biome : biomes.getValue()) {
|
for (final Tag biome : biomes.getValue()) {
|
||||||
final CompoundTag biomeCompound = ((CompoundTag) biome).get("element");
|
final CompoundTag biomeCompound = ((CompoundTag) biome).get("element");
|
||||||
biomeCompound.put("category", new StringTag("none"));
|
biomeCompound.putString("category", "none");
|
||||||
}
|
}
|
||||||
tracker(wrapper.user()).setBiomesSent(biomes.size());
|
tracker(wrapper.user()).setBiomesSent(biomes.size());
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_3;
|
|||||||
import com.viaversion.viaversion.api.minecraft.signature.SignableCommandArgumentsProvider;
|
import com.viaversion.viaversion.api.minecraft.signature.SignableCommandArgumentsProvider;
|
||||||
import com.viaversion.viaversion.api.minecraft.signature.model.MessageMetadata;
|
import com.viaversion.viaversion.api.minecraft.signature.model.MessageMetadata;
|
||||||
import com.viaversion.viaversion.api.minecraft.signature.storage.ChatSession1_19_3;
|
import com.viaversion.viaversion.api.minecraft.signature.storage.ChatSession1_19_3;
|
||||||
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
@ -59,6 +60,7 @@ import com.viaversion.viaversion.util.ComponentUtil;
|
|||||||
import com.viaversion.viaversion.util.Pair;
|
import com.viaversion.viaversion.util.Pair;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundPackets1_19_3, ClientboundPackets1_19_1, ServerboundPackets1_19_3, ServerboundPackets1_19_1> {
|
public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundPackets1_19_3, ClientboundPackets1_19_1, ServerboundPackets1_19_3, ServerboundPackets1_19_1> {
|
||||||
|
|
||||||
@ -91,60 +93,19 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
|||||||
final SoundRewriter<ClientboundPackets1_19_3> soundRewriter = new SoundRewriter<>(this);
|
final SoundRewriter<ClientboundPackets1_19_3> soundRewriter = new SoundRewriter<>(this);
|
||||||
soundRewriter.registerStopSound(ClientboundPackets1_19_3.STOP_SOUND);
|
soundRewriter.registerStopSound(ClientboundPackets1_19_3.STOP_SOUND);
|
||||||
registerClientbound(ClientboundPackets1_19_3.SOUND, wrapper -> {
|
registerClientbound(ClientboundPackets1_19_3.SOUND, wrapper -> {
|
||||||
final int soundId = wrapper.read(Type.VAR_INT) - 1; // Normalize the id
|
final String mappedIdentifier = rewriteSound(wrapper);
|
||||||
if (soundId != -1) {
|
|
||||||
final int mappedId = MAPPINGS.getSoundMappings().getNewId(soundId);
|
|
||||||
if (mappedId == -1) {
|
|
||||||
wrapper.cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wrapper.write(Type.VAR_INT, mappedId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String soundIdentifier = wrapper.read(Type.STRING);
|
|
||||||
wrapper.read(Type.OPTIONAL_FLOAT); // Fixed range
|
|
||||||
final String mappedIdentifier = MAPPINGS.getMappedNamedSound(soundIdentifier);
|
|
||||||
if (mappedIdentifier != null) {
|
if (mappedIdentifier != null) {
|
||||||
if (mappedIdentifier.isEmpty()) {
|
wrapper.write(Type.STRING, mappedIdentifier);
|
||||||
wrapper.cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
soundIdentifier = mappedIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
wrapper.write(Type.STRING, soundIdentifier);
|
|
||||||
wrapper.setPacketType(ClientboundPackets1_19_1.NAMED_SOUND);
|
wrapper.setPacketType(ClientboundPackets1_19_1.NAMED_SOUND);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(ClientboundPackets1_19_3.ENTITY_SOUND, wrapper -> {
|
registerClientbound(ClientboundPackets1_19_3.ENTITY_SOUND, wrapper -> {
|
||||||
final int soundId = wrapper.read(Type.VAR_INT) - 1; // Normalize the id
|
final String mappedIdentifier = rewriteSound(wrapper);
|
||||||
if (soundId != -1) {
|
if (mappedIdentifier == null) {
|
||||||
final int mappedId = MAPPINGS.getSoundMappings().getNewId(soundId);
|
|
||||||
if (mappedId == -1) {
|
|
||||||
wrapper.cancel();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.write(Type.VAR_INT, mappedId);
|
final int mappedId = MAPPINGS.mappedSound(mappedIdentifier);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert the resource location to the corresponding integer id
|
|
||||||
String soundIdentifier = wrapper.read(Type.STRING);
|
|
||||||
wrapper.read(Type.OPTIONAL_FLOAT); // Fixed range
|
|
||||||
final String mappedIdentifier = MAPPINGS.getMappedNamedSound(soundIdentifier);
|
|
||||||
if (mappedIdentifier != null) {
|
|
||||||
if (mappedIdentifier.isEmpty()) {
|
|
||||||
wrapper.cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
soundIdentifier = mappedIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int mappedId = MAPPINGS.mappedSound(soundIdentifier);
|
|
||||||
if (mappedId == -1) {
|
if (mappedId == -1) {
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
return;
|
return;
|
||||||
@ -387,6 +348,35 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
|||||||
cancelServerbound(ServerboundPackets1_19_1.CHAT_ACK);
|
cancelServerbound(ServerboundPackets1_19_1.CHAT_ACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private @Nullable String rewriteSound(final PacketWrapper wrapper) throws Exception {
|
||||||
|
final int soundId = wrapper.read(Type.VAR_INT) - 1; // Normalize the id
|
||||||
|
if (soundId != -1) {
|
||||||
|
final int mappedId = MAPPINGS.getSoundMappings().getNewId(soundId);
|
||||||
|
if (mappedId == -1) {
|
||||||
|
wrapper.cancel();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.write(Type.VAR_INT, mappedId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert the resource location to the corresponding integer id
|
||||||
|
final String soundIdentifier = wrapper.read(Type.STRING);
|
||||||
|
wrapper.read(Type.OPTIONAL_FLOAT); // Fixed range
|
||||||
|
final String mappedIdentifier = MAPPINGS.getMappedNamedSound(soundIdentifier);
|
||||||
|
if (mappedIdentifier == null) {
|
||||||
|
return soundIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mappedIdentifier.isEmpty()) {
|
||||||
|
wrapper.cancel();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mappedIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(final UserConnection user) {
|
public void init(final UserConnection user) {
|
||||||
user.put(new ChatSessionStorage());
|
user.put(new ChatSessionStorage());
|
||||||
|
@ -39,10 +39,9 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1;
|
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
|
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3;
|
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
|
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets1_19_3, Protocol1_19_1To1_19_3> {
|
public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets1_19_3, Protocol1_19_1To1_19_3> {
|
||||||
|
|
||||||
@ -83,7 +82,7 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
|
|||||||
final ChatTypeStorage1_19_3 chatTypeStorage = wrapper.user().get(ChatTypeStorage1_19_3.class);
|
final ChatTypeStorage1_19_3 chatTypeStorage = wrapper.user().get(ChatTypeStorage1_19_3.class);
|
||||||
chatTypeStorage.clear();
|
chatTypeStorage.clear();
|
||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
final ListTag chatTypes = ((CompoundTag) registry.get("minecraft:chat_type")).get("value");
|
final ListTag chatTypes = registry.getCompoundTag("minecraft:chat_type").get("value");
|
||||||
for (final Tag chatType : chatTypes) {
|
for (final Tag chatType : chatTypes) {
|
||||||
final CompoundTag chatTypeCompound = (CompoundTag) chatType;
|
final CompoundTag chatTypeCompound = (CompoundTag) chatType;
|
||||||
final NumberTag idTag = chatTypeCompound.get("id");
|
final NumberTag idTag = chatTypeCompound.get("id");
|
||||||
|
@ -28,7 +28,10 @@ import com.viaversion.viaversion.api.type.Type;
|
|||||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_3;
|
import com.viaversion.viaversion.api.type.types.version.Types1_19_3;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_4;
|
import com.viaversion.viaversion.api.type.types.version.Types1_19_4;
|
||||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.*;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
|
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
||||||
|
|
||||||
@ -69,7 +72,7 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
|
|||||||
for (final Tag biomeTag : biomes) {
|
for (final Tag biomeTag : biomes) {
|
||||||
final CompoundTag biomeData = ((CompoundTag) biomeTag).get("element");
|
final CompoundTag biomeData = ((CompoundTag) biomeTag).get("element");
|
||||||
final NumberTag hasPrecipitation = biomeData.get("has_precipitation");
|
final NumberTag hasPrecipitation = biomeData.get("has_precipitation");
|
||||||
biomeData.put("precipitation", new StringTag(hasPrecipitation.asByte() == 1 ? "rain" : "none"));
|
biomeData.putString("precipitation", hasPrecipitation.asByte() == 1 ? "rain" : "none");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -158,15 +158,15 @@ public final class BlockItemPackets1_20 extends ItemRewriter<ClientboundPackets1
|
|||||||
super.handleItemToClient(item);
|
super.handleItemToClient(item);
|
||||||
|
|
||||||
// Remove new trim tags
|
// Remove new trim tags
|
||||||
final Tag trimTag;
|
final CompoundTag trimTag;
|
||||||
if (item.tag() != null && (trimTag = item.tag().get("Trim")) instanceof CompoundTag) {
|
final CompoundTag tag = item.tag();
|
||||||
final Tag patternTag = ((CompoundTag) trimTag).get("pattern");
|
if (tag != null && (trimTag = tag.getCompoundTag("Trim")) != null) {
|
||||||
if (patternTag instanceof StringTag) {
|
final StringTag patternTag = trimTag.getStringTag("pattern");
|
||||||
final StringTag patternStringTag = (StringTag) patternTag;
|
if (patternTag != null) {
|
||||||
final String pattern = Key.stripMinecraftNamespace(patternStringTag.getValue());
|
final String pattern = Key.stripMinecraftNamespace(patternTag.getValue());
|
||||||
if (NEW_TRIM_PATTERNS.contains(pattern)) {
|
if (NEW_TRIM_PATTERNS.contains(pattern)) {
|
||||||
item.tag().remove("Trim");
|
tag.remove("Trim");
|
||||||
item.tag().put(nbtTagName + "|Trim", trimTag);
|
tag.put(nbtTagName + "|Trim", trimTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,8 +183,9 @@ public final class BlockItemPackets1_20 extends ItemRewriter<ClientboundPackets1
|
|||||||
|
|
||||||
// Add back original trim tag
|
// Add back original trim tag
|
||||||
final Tag trimTag;
|
final Tag trimTag;
|
||||||
if (item.tag() != null && (trimTag = item.tag().remove(nbtTagName + "|Trim")) != null) {
|
final CompoundTag tag = item.tag();
|
||||||
item.tag().put("Trim", trimTag);
|
if (tag != null && (trimTag = tag.remove(nbtTagName + "|Trim")) != null) {
|
||||||
|
tag.put("Trim", trimTag);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@ -196,19 +197,20 @@ public final class BlockItemPackets1_20 extends ItemRewriter<ClientboundPackets1
|
|||||||
}
|
}
|
||||||
|
|
||||||
final CompoundTag tag = blockEntity.tag();
|
final CompoundTag tag = blockEntity.tag();
|
||||||
final CompoundTag frontText = tag.remove("front_text");
|
final Tag frontText = tag.remove("front_text");
|
||||||
tag.remove("back_text");
|
tag.remove("back_text");
|
||||||
|
|
||||||
if (frontText != null) {
|
if (frontText instanceof CompoundTag) {
|
||||||
writeMessages(frontText, tag, false);
|
final CompoundTag frontTextTag = (CompoundTag) frontText;
|
||||||
writeMessages(frontText, tag, true);
|
writeMessages(frontTextTag, tag, false);
|
||||||
|
writeMessages(frontTextTag, tag, true);
|
||||||
|
|
||||||
final Tag color = frontText.remove("color");
|
final Tag color = frontTextTag.remove("color");
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
tag.put("Color", color);
|
tag.put("Color", color);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Tag glowing = frontText.remove("has_glowing_text");
|
final Tag glowing = frontTextTag.remove("has_glowing_text");
|
||||||
if (glowing != null) {
|
if (glowing != null) {
|
||||||
tag.put("GlowingText", glowing);
|
tag.put("GlowingText", glowing);
|
||||||
}
|
}
|
||||||
@ -216,7 +218,7 @@ public final class BlockItemPackets1_20 extends ItemRewriter<ClientboundPackets1
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void writeMessages(final CompoundTag frontText, final CompoundTag tag, final boolean filtered) {
|
private void writeMessages(final CompoundTag frontText, final CompoundTag tag, final boolean filtered) {
|
||||||
final ListTag messages = frontText.get(filtered ? "filtered_messages" : "messages");
|
final ListTag messages = frontText.getListTag(filtered ? "filtered_messages" : "messages");
|
||||||
if (messages == null) {
|
if (messages == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
|||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_19_4, Protocol1_19_4To1_20> {
|
public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_19_4, Protocol1_19_4To1_20> {
|
||||||
@ -81,16 +80,18 @@ public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_
|
|||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
|
|
||||||
ListTag values;
|
final ListTag values;
|
||||||
// A 1.20 server can't send this element, and the 1.20 client still works, if the element is missing
|
// A 1.20 server can't send this element, and the 1.20 client still works, if the element is missing
|
||||||
// on a 1.19.4 client there is an exception, so in case the 1.20 server doesn't send the element we put in an original 1.20 element
|
// on a 1.19.4 client there is an exception, so in case the 1.20 server doesn't send the element we put in an original 1.20 element
|
||||||
if (registry.contains("minecraft:trim_pattern")) {
|
final CompoundTag trimPatternTag = registry.getCompoundTag("minecraft:trim_pattern");
|
||||||
values = ((CompoundTag) registry.get("minecraft:trim_pattern")).get("value");
|
if (trimPatternTag != null) {
|
||||||
|
values = trimPatternTag.getListTag("value");
|
||||||
} else {
|
} else {
|
||||||
final CompoundTag trimPatternRegistry = Protocol1_19_4To1_20.MAPPINGS.getTrimPatternRegistry().copy();
|
final CompoundTag trimPatternRegistry = Protocol1_19_4To1_20.MAPPINGS.getTrimPatternRegistry().copy();
|
||||||
registry.put("minecraft:trim_pattern", trimPatternRegistry);
|
registry.put("minecraft:trim_pattern", trimPatternRegistry);
|
||||||
values = trimPatternRegistry.get("value");
|
values = trimPatternRegistry.get("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Tag entry : values) {
|
for (final Tag entry : values) {
|
||||||
final CompoundTag element = ((CompoundTag) entry).get("element");
|
final CompoundTag element = ((CompoundTag) entry).get("element");
|
||||||
final StringTag templateItem = element.get("template_item");
|
final StringTag templateItem = element.get("template_item");
|
||||||
|
@ -103,7 +103,7 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
|||||||
chatTypeStorage.clear();
|
chatTypeStorage.clear();
|
||||||
|
|
||||||
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
|
||||||
final ListTag chatTypes = ((CompoundTag) registry.get("minecraft:chat_type")).get("value");
|
final ListTag chatTypes = registry.getCompoundTag("minecraft:chat_type").get("value");
|
||||||
for (final Tag chatType : chatTypes) {
|
for (final Tag chatType : chatTypes) {
|
||||||
final CompoundTag chatTypeCompound = (CompoundTag) chatType;
|
final CompoundTag chatTypeCompound = (CompoundTag) chatType;
|
||||||
final NumberTag idTag = chatTypeCompound.get("id");
|
final NumberTag idTag = chatTypeCompound.get("id");
|
||||||
@ -399,7 +399,7 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
chatType = chatType.<CompoundTag>get("element").get("chat");
|
chatType = chatType.getCompoundTag("element").getCompoundTag("chat");
|
||||||
if (chatType == null) {
|
if (chatType == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ package com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.packets;
|
|||||||
|
|
||||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1_19_1;
|
import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1_19_1;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1;
|
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1;
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.storage;
|
|||||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import com.viaversion.viaversion.libs.fastutil.Pair;
|
import com.viaversion.viaversion.libs.fastutil.Pair;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class SpawnPositionStorage implements StorableObject {
|
public class SpawnPositionStorage implements StorableObject {
|
||||||
|
@ -34,8 +34,8 @@ import com.viaversion.viaversion.api.type.Type;
|
|||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4;
|
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
|
||||||
@ -399,16 +399,16 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringTag primaryEffect = tag.remove("primary_effect");
|
final Tag primaryEffect = tag.remove("primary_effect");
|
||||||
if (primaryEffect != null) {
|
if (primaryEffect instanceof StringTag) {
|
||||||
final String effectKey = Key.stripMinecraftNamespace(primaryEffect.getValue());
|
final String effectKey = Key.stripMinecraftNamespace(((StringTag) primaryEffect).getValue());
|
||||||
tag.put("Primary", new IntTag(PotionEffects.keyToId(effectKey)));
|
tag.putInt("Primary", PotionEffects.keyToId(effectKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringTag secondaryEffect = tag.remove("secondary_effect");
|
final Tag secondaryEffect = tag.remove("secondary_effect");
|
||||||
if (secondaryEffect != null) {
|
if (secondaryEffect instanceof StringTag) {
|
||||||
final String effectKey = Key.stripMinecraftNamespace(secondaryEffect.getValue());
|
final String effectKey = Key.stripMinecraftNamespace(((StringTag) secondaryEffect).getValue());
|
||||||
tag.put("Secondary", new IntTag(PotionEffects.keyToId(effectKey)));
|
tag.putInt("Secondary", PotionEffects.keyToId(effectKey));
|
||||||
}
|
}
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_1;
|
|||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
||||||
@ -60,8 +59,8 @@ public class Protocol1_9_1_2To1_9_3_4 extends AbstractProtocol<ClientboundPacket
|
|||||||
wrapper.write(Type.POSITION1_8, position); // Position
|
wrapper.write(Type.POSITION1_8, position); // Position
|
||||||
for (int i = 1; i < 5; i++) {
|
for (int i = 1; i < 5; i++) {
|
||||||
// Should technically be written as COMPONENT, but left as String for simplification/to remove redundant wrapping for VR
|
// Should technically be written as COMPONENT, but left as String for simplification/to remove redundant wrapping for VR
|
||||||
Tag textTag = tag.get("Text" + i);
|
StringTag textTag = tag.getStringTag("Text" + i);
|
||||||
String line = textTag instanceof StringTag ? ((StringTag) textTag).getValue() : "";
|
String line = textTag != null ? textTag.getValue() : "";
|
||||||
wrapper.write(Type.STRING, line); // Sign line
|
wrapper.write(Type.STRING, line); // Sign line
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,60 +18,56 @@
|
|||||||
package com.viaversion.viabackwards.protocol.protocol1_9_1_2to1_9_3_4.chunks;
|
package com.viaversion.viabackwards.protocol.protocol1_9_1_2to1_9_3_4.chunks;
|
||||||
|
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2To1_9_3_4;
|
import com.viaversion.viabackwards.protocol.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2To1_9_3_4;
|
||||||
import com.viaversion.viaversion.api.Via;
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class BlockEntity {
|
public class BlockEntity {
|
||||||
private static final Map<String, Integer> types = new HashMap<>();
|
private static final Map<String, Integer> TYPES = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
types.put("MobSpawner", 1);
|
TYPES.put("MobSpawner", 1);
|
||||||
types.put("Control", 2);
|
TYPES.put("Control", 2);
|
||||||
types.put("Beacon", 3);
|
TYPES.put("Beacon", 3);
|
||||||
types.put("Skull", 4);
|
TYPES.put("Skull", 4);
|
||||||
types.put("FlowerPot", 5);
|
TYPES.put("FlowerPot", 5);
|
||||||
types.put("Banner", 6);
|
TYPES.put("Banner", 6);
|
||||||
types.put("UNKNOWN", 7);
|
TYPES.put("UNKNOWN", 7);
|
||||||
types.put("EndGateway", 8);
|
TYPES.put("EndGateway", 8);
|
||||||
types.put("Sign", 9);
|
TYPES.put("Sign", 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handle(List<CompoundTag> tags, UserConnection connection) {
|
public static void handle(List<CompoundTag> tags, UserConnection connection) throws Exception {
|
||||||
for (CompoundTag tag : tags) {
|
for (CompoundTag tag : tags) {
|
||||||
try {
|
StringTag idTag = tag.getStringTag("id");
|
||||||
if (!tag.contains("id"))
|
if (idTag == null) {
|
||||||
throw new Exception("NBT tag not handled because the id key is missing");
|
|
||||||
|
|
||||||
String id = (String) tag.get("id").getValue();
|
|
||||||
if (!types.containsKey(id))
|
|
||||||
throw new Exception("Not handled id: " + id);
|
|
||||||
|
|
||||||
int newId = types.get(id);
|
|
||||||
if (newId == -1)
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int x = ((NumberTag) tag.get("x")).asInt();
|
String id = idTag.getValue();
|
||||||
int y = ((NumberTag) tag.get("y")).asInt();
|
if (!TYPES.containsKey(id)) {
|
||||||
int z = ((NumberTag) tag.get("z")).asInt();
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newId = TYPES.get(id);
|
||||||
|
if (newId == -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int x = tag.getNumberTag("x").asInt();
|
||||||
|
int y = tag.getNumberTag("y").asInt();
|
||||||
|
int z = tag.getNumberTag("z").asInt();
|
||||||
|
|
||||||
Position pos = new Position(x, (short) y, z);
|
Position pos = new Position(x, (short) y, z);
|
||||||
|
|
||||||
updateBlockEntity(pos, (short) newId, tag, connection);
|
updateBlockEntity(pos, (short) newId, tag, connection);
|
||||||
} catch (Exception e) {
|
|
||||||
if (Via.getManager().isDebug()) {
|
|
||||||
Via.getPlatform().getLogger().warning("Block Entity: " + e.getMessage() + ": " + tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
|||||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||||
import com.viaversion.viabackwards.utils.Block;
|
import com.viaversion.viabackwards.utils.Block;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
|
@ -27,11 +27,6 @@ public class Block {
|
|||||||
this.data = (short) data;
|
this.data = (short) data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block(int id) {
|
|
||||||
this.id = id;
|
|
||||||
this.data = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import java.util.Objects;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class ChatUtil {
|
public final class ChatUtil {
|
||||||
private static final Pattern UNUSED_COLOR_PATTERN = Pattern.compile("(?>(?>§[0-fk-or])*(§r|\\Z))|(?>(?>§[0-f])*(§[0-f]))");
|
private static final Pattern UNUSED_COLOR_PATTERN = Pattern.compile("(?>(?>§[0-fk-or])*(§r|\\Z))|(?>(?>§[0-f])*(§[0-f]))");
|
||||||
private static final Pattern UNUSED_COLOR_PATTERN_PREFIX = Pattern.compile("(?>(?>§[0-fk-or])*(§r))|(?>(?>§[0-f])*(§[0-f]))");
|
private static final Pattern UNUSED_COLOR_PATTERN_PREFIX = Pattern.compile("(?>(?>§[0-fk-or])*(§r))|(?>(?>§[0-f])*(§[0-f]))");
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ package com.viaversion.viabackwards;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
|
||||||
import com.viaversion.viaversion.sponge.util.LoggerWrapper;
|
import com.viaversion.viaversion.sponge.util.LoggerWrapper;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@ -39,7 +38,6 @@ public class SpongePlugin implements ViaBackwardsPlatform {
|
|||||||
@ConfigDir(sharedRoot = false)
|
@ConfigDir(sharedRoot = false)
|
||||||
private Path configPath;
|
private Path configPath;
|
||||||
|
|
||||||
@SuppressWarnings("SpongeInjection")
|
|
||||||
@Inject
|
@Inject
|
||||||
SpongePlugin(final org.apache.logging.log4j.Logger logger) {
|
SpongePlugin(final org.apache.logging.log4j.Logger logger) {
|
||||||
this.logger = new LoggerWrapper(logger);
|
this.logger = new LoggerWrapper(logger);
|
||||||
|
@ -70,7 +70,7 @@ public final class Protocol1_98To1_99 extends BackwardsProtocol<ClientboundPacke
|
|||||||
soundRewriter.registerStopSound(ClientboundPackets1_20_5.STOP_SOUND);
|
soundRewriter.registerStopSound(ClientboundPackets1_20_5.STOP_SOUND);
|
||||||
|
|
||||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_20_5.STATISTICS);
|
new StatisticsRewriter<>(this).register(ClientboundPackets1_20_5.STATISTICS);
|
||||||
new AttributeRewriter<>(this).register1_20_5(ClientboundPackets1_20_5.ENTITY_PROPERTIES);
|
//new AttributeRewriter<>(this).register1_20_5(ClientboundPackets1_20_5.ENTITY_PROPERTIES);
|
||||||
|
|
||||||
// Registers translatable mappings (missing a whole bunch still)
|
// Registers translatable mappings (missing a whole bunch still)
|
||||||
//translatableRewriter.registerOpenWindow(ClientboundPackets1_20_5.OPEN_WINDOW); // Handled by registerOpenWindow in item rewriters
|
//translatableRewriter.registerOpenWindow(ClientboundPackets1_20_5.OPEN_WINDOW); // Handled by registerOpenWindow in item rewriters
|
||||||
|
@ -28,7 +28,6 @@ import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
|||||||
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||||
import com.viaversion.viabackwards.utils.VersionInfo;
|
import com.viaversion.viabackwards.utils.VersionInfo;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
|
||||||
import com.viaversion.viaversion.velocity.util.LoggerWrapper;
|
import com.viaversion.viaversion.velocity.util.LoggerWrapper;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren