Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 00:00:28 +01:00
Merge pull request #1236 from ViaVersion/master
merge master into dev
Dieser Commit ist enthalten in:
Commit
aecf9fb9b1
@ -1,6 +1,5 @@
|
|||||||
package us.myles.ViaVersion.bungee.handlers;
|
package us.myles.ViaVersion.bungee.handlers;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||||
@ -29,8 +28,11 @@ import java.lang.reflect.Field;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class BungeeServerHandler implements Listener {
|
public class BungeeServerHandler implements Listener {
|
||||||
private static Method getHandshake;
|
private static Method getHandshake;
|
||||||
@ -152,23 +154,28 @@ public class BungeeServerHandler implements Listener {
|
|||||||
String channel = plMsg.getTag();
|
String channel = plMsg.getTag();
|
||||||
int id1_13 = ProtocolVersion.v1_13.getId();
|
int id1_13 = ProtocolVersion.v1_13.getId();
|
||||||
if (previousServerProtocol != -1) {
|
if (previousServerProtocol != -1) {
|
||||||
|
String oldChannel = channel;
|
||||||
if (previousServerProtocol < id1_13 && protocolId >= id1_13) {
|
if (previousServerProtocol < id1_13 && protocolId >= id1_13) {
|
||||||
channel = InventoryPackets.getNewPluginChannelId(channel);
|
channel = InventoryPackets.getNewPluginChannelId(channel);
|
||||||
if (channel.equals("minecraft:register")) {
|
if (channel == null) {
|
||||||
String[] channels = new String(plMsg.getData(), StandardCharsets.UTF_8).split("\0");
|
throw new RuntimeException(oldChannel + " found in relayMessages");
|
||||||
for (int i = 0; i < channels.length; i++) {
|
|
||||||
channels[i] = InventoryPackets.getNewPluginChannelId(channels[i]);
|
|
||||||
}
|
}
|
||||||
plMsg.setData(Joiner.on('\0').join(channels).getBytes(StandardCharsets.UTF_8));
|
if (channel.equals("minecraft:register")) {
|
||||||
|
plMsg.setData(Arrays.stream(new String(plMsg.getData(), StandardCharsets.UTF_8).split("\0"))
|
||||||
|
.map(InventoryPackets::getNewPluginChannelId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.joining("\0")).getBytes(StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
} else if (previousServerProtocol >= id1_13 && protocolId < id1_13) {
|
} else if (previousServerProtocol >= id1_13 && protocolId < id1_13) {
|
||||||
channel = InventoryPackets.getOldPluginChannelId(channel);
|
channel = InventoryPackets.getOldPluginChannelId(channel);
|
||||||
if (channel.equals("REGISTER")) {
|
if (channel == null) {
|
||||||
String[] channels = new String(plMsg.getData(), StandardCharsets.UTF_8).split("\0");
|
throw new RuntimeException(oldChannel + " found in relayMessages");
|
||||||
for (int i = 0; i < channels.length; i++) {
|
|
||||||
channels[i] = InventoryPackets.getOldPluginChannelId(channels[i]);
|
|
||||||
}
|
}
|
||||||
plMsg.setData(Joiner.on('\0').join(channels).getBytes(StandardCharsets.UTF_8));
|
if (channel.equals("REGISTER")) {
|
||||||
|
plMsg.setData(Arrays.stream(new String(plMsg.getData(), StandardCharsets.UTF_8).split("\0"))
|
||||||
|
.map(InventoryPackets::getOldPluginChannelId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.joining("\0")).getBytes(StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package us.myles.ViaVersion.api.type.types.minecraft;
|
package us.myles.ViaVersion.api.type.types.minecraft;
|
||||||
|
|
||||||
import com.github.steveice10.opennbt.NBTIO;
|
import com.github.steveice10.opennbt.NBTIO;
|
||||||
|
import com.github.steveice10.opennbt.tag.TagRegistry;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
@ -14,6 +15,13 @@ import java.io.DataOutput;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
||||||
public class NBTType extends Type<CompoundTag> {
|
public class NBTType extends Type<CompoundTag> {
|
||||||
|
static {
|
||||||
|
// We don't need them
|
||||||
|
TagRegistry.unregister(60);
|
||||||
|
TagRegistry.unregister(61);
|
||||||
|
TagRegistry.unregister(65);
|
||||||
|
}
|
||||||
|
|
||||||
public NBTType() {
|
public NBTType() {
|
||||||
super(CompoundTag.class);
|
super(CompoundTag.class);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import lombok.Getter;
|
|||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.minecraft.BlockFace;
|
import us.myles.ViaVersion.api.minecraft.BlockFace;
|
||||||
import us.myles.ViaVersion.api.minecraft.Position;
|
import us.myles.ViaVersion.api.minecraft.Position;
|
||||||
|
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||||
|
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -47,10 +49,11 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler {
|
|||||||
|
|
||||||
protected byte getStates(UserConnection user, Position position, int blockState) {
|
protected byte getStates(UserConnection user, Position position, int blockState) {
|
||||||
byte states = 0;
|
byte states = 0;
|
||||||
if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)))) states |= 1;
|
boolean pre1_12 = user.get(ProtocolInfo.class).getServerProtocolVersion() < ProtocolVersion.v1_12.getId();
|
||||||
if (connects(BlockFace.NORTH, getBlockData(user, position.getRelative(BlockFace.NORTH)))) states |= 2;
|
if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)), pre1_12)) states |= 1;
|
||||||
if (connects(BlockFace.SOUTH, getBlockData(user, position.getRelative(BlockFace.SOUTH)))) states |= 4;
|
if (connects(BlockFace.NORTH, getBlockData(user, position.getRelative(BlockFace.NORTH)), pre1_12)) states |= 2;
|
||||||
if (connects(BlockFace.WEST, getBlockData(user, position.getRelative(BlockFace.WEST)))) states |= 8;
|
if (connects(BlockFace.SOUTH, getBlockData(user, position.getRelative(BlockFace.SOUTH)), pre1_12)) states |= 4;
|
||||||
|
if (connects(BlockFace.WEST, getBlockData(user, position.getRelative(BlockFace.WEST)), pre1_12)) states |= 8;
|
||||||
return states;
|
return states;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +68,9 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler {
|
|||||||
return newBlockState == null ? blockState : newBlockState;
|
return newBlockState == null ? blockState : newBlockState;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean connects(BlockFace side, int blockState) {
|
protected boolean connects(BlockFace side, int blockState, boolean pre1_12) {
|
||||||
return blockStates.contains(blockState) || blockConnections != null && ConnectionData.blockConnectionData.containsKey(blockState) && ConnectionData.blockConnectionData.get(blockState).connectsTo(blockConnections, side.opposite());
|
return blockStates.contains(blockState) || blockConnections != null
|
||||||
|
&& ConnectionData.blockConnectionData.containsKey(blockState)
|
||||||
|
&& ConnectionData.blockConnectionData.get(blockState).connectsTo(blockConnections, side.opposite(), pre1_12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,20 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class BlockData {
|
public class BlockData {
|
||||||
private Map<String, Boolean[]> connectData = new HashMap<>();
|
private Map<String, boolean[]> connectData = new HashMap<>();
|
||||||
|
|
||||||
public void put(String key, Boolean[] booleans) {
|
public void put(String key, boolean[] booleans) {
|
||||||
connectData.put(key, booleans);
|
connectData.put(key, booleans);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean connectsTo(String blockConnection, BlockFace face) {
|
public boolean connectsTo(String blockConnection, BlockFace face, boolean pre1_12AbstractFence) {
|
||||||
final Boolean[] booleans = connectData.get(blockConnection);
|
boolean[] booleans = null;
|
||||||
|
if (pre1_12AbstractFence) {
|
||||||
|
booleans = connectData.get("allFalseIfStairPre1_12"); // https://minecraft.gamepedia.com/Java_Edition_1.12
|
||||||
|
}
|
||||||
|
if (booleans == null) {
|
||||||
|
booleans = connectData.get(blockConnection);
|
||||||
|
}
|
||||||
return booleans != null && booleans[face.ordinal()];
|
return booleans != null && booleans[face.ordinal()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,11 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections;
|
|||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.minecraft.BlockFace;
|
import us.myles.ViaVersion.api.minecraft.BlockFace;
|
||||||
import us.myles.ViaVersion.api.minecraft.Position;
|
import us.myles.ViaVersion.api.minecraft.Position;
|
||||||
|
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||||
|
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ChorusPlantConnectionHandler extends AbstractFenceConnectionHandler {
|
public class ChorusPlantConnectionHandler extends AbstractFenceConnectionHandler {
|
||||||
private int endstone;
|
private int endstone;
|
||||||
@ -46,13 +47,13 @@ public class ChorusPlantConnectionHandler extends AbstractFenceConnectionHandler
|
|||||||
@Override
|
@Override
|
||||||
protected byte getStates(UserConnection user, Position position, int blockState) {
|
protected byte getStates(UserConnection user, Position position, int blockState) {
|
||||||
byte states = super.getStates(user, position, blockState);
|
byte states = super.getStates(user, position, blockState);
|
||||||
if (connects(BlockFace.TOP, getBlockData(user, position.getRelative(BlockFace.TOP)))) states |= 16;
|
if (connects(BlockFace.TOP, getBlockData(user, position.getRelative(BlockFace.TOP)), false)) states |= 16;
|
||||||
if (connects(BlockFace.BOTTOM, getBlockData(user, position.getRelative(BlockFace.BOTTOM)))) states |= 32;
|
if (connects(BlockFace.BOTTOM, getBlockData(user, position.getRelative(BlockFace.BOTTOM)), false)) states |= 32;
|
||||||
return states;
|
return states;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean connects(BlockFace side, int blockState) {
|
protected boolean connects(BlockFace side, int blockState, boolean pre1_12) {
|
||||||
return getBlockStates().contains(blockState) || (side == BlockFace.BOTTOM && blockState == endstone);
|
return getBlockStates().contains(blockState) || (side == BlockFace.BOTTOM && blockState == endstone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,17 +212,18 @@ public class ConnectionData {
|
|||||||
for (Entry<String, JsonElement> type : entry.getValue().getAsJsonObject().entrySet()) {
|
for (Entry<String, JsonElement> type : entry.getValue().getAsJsonObject().entrySet()) {
|
||||||
String name = type.getKey();
|
String name = type.getKey();
|
||||||
JsonObject object = type.getValue().getAsJsonObject();
|
JsonObject object = type.getValue().getAsJsonObject();
|
||||||
Boolean[] data = new Boolean[6];
|
boolean[] data = new boolean[6];
|
||||||
for (BlockFace value : BlockFace.values()) {
|
for (BlockFace value : BlockFace.values()) {
|
||||||
String face = value.toString().toLowerCase();
|
String face = value.toString().toLowerCase();
|
||||||
if (object.has(face)) {
|
if (object.has(face)) {
|
||||||
data[value.ordinal()] = object.getAsJsonPrimitive(face).getAsBoolean();
|
data[value.ordinal()] = object.getAsJsonPrimitive(face).getAsBoolean();
|
||||||
} else {
|
|
||||||
data[value.ordinal()] = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blockData.put(name, data);
|
blockData.put(name, data);
|
||||||
}
|
}
|
||||||
|
if (entry.getKey().contains("stairs")) {
|
||||||
|
blockData.put("allFalseIfStairPre1_12", new boolean[6]);
|
||||||
|
}
|
||||||
blockConnectionData.put(id, blockData);
|
blockConnectionData.put(id, blockData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,6 @@ public class RedstoneConnectionHandler extends ConnectionHandler {
|
|||||||
|
|
||||||
private boolean connects(BlockFace side, int blockState) {
|
private boolean connects(BlockFace side, int blockState) {
|
||||||
final BlockData blockData = ConnectionData.blockConnectionData.get(blockState);
|
final BlockData blockData = ConnectionData.blockConnectionData.get(blockState);
|
||||||
return blockData != null && blockData.connectsTo("redstoneConnections", side.opposite());
|
return blockData != null && blockData.connectsTo("redstoneConnections", side.opposite(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import java.util.Map;
|
|||||||
public class BlockIdData {
|
public class BlockIdData {
|
||||||
public static Map<String, String[]> blockIdMapping;
|
public static Map<String, String[]> blockIdMapping;
|
||||||
public static Map<String, String[]> fallbackReverseMapping;
|
public static Map<String, String[]> fallbackReverseMapping;
|
||||||
|
public static Map<Integer, String> numberIdToString;
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
InputStream stream = MappingData.class.getClassLoader()
|
InputStream stream = MappingData.class.getClassLoader()
|
||||||
@ -39,5 +40,22 @@ public class BlockIdData {
|
|||||||
// Ignored
|
// Ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InputStream blockS = MappingData.class.getClassLoader()
|
||||||
|
.getResourceAsStream("assets/viaversion/data/blockNumberToString1.12.json");
|
||||||
|
InputStreamReader blockR = new InputStreamReader(blockS);
|
||||||
|
try {
|
||||||
|
numberIdToString = new HashMap<>((Map<Integer, String>) GsonUtil.getGson().fromJson(
|
||||||
|
blockR,
|
||||||
|
new TypeToken<Map<Integer, String>>() {
|
||||||
|
}.getType()
|
||||||
|
));
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
blockR.close();
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import com.github.steveice10.opennbt.conversion.ConverterRegistry;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.*;
|
import com.github.steveice10.opennbt.tag.builtin.*;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.io.BaseEncoding;
|
import com.google.common.primitives.Ints;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
@ -159,8 +159,12 @@ public class InventoryPackets {
|
|||||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
String old = channel;
|
||||||
channel = getNewPluginChannelId(channel);
|
channel = getNewPluginChannelId(channel);
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
|
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
|
||||||
|
Via.getPlatform().getLogger().warning("Ignoring outgoing plugin message with channel: " + old);
|
||||||
|
}
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
return;
|
return;
|
||||||
} else if (channel.equals("minecraft:register") || channel.equals("minecraft:unregister")) {
|
} else if (channel.equals("minecraft:register") || channel.equals("minecraft:unregister")) {
|
||||||
@ -171,7 +175,7 @@ public class InventoryPackets {
|
|||||||
if (rewritten != null) {
|
if (rewritten != null) {
|
||||||
rewrittenChannels.add(rewritten);
|
rewrittenChannels.add(rewritten);
|
||||||
} else if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
|
} else if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
|
||||||
Via.getPlatform().getLogger().warning("Ignoring plugin channel in REGISTER: " + channels[i]);
|
Via.getPlatform().getLogger().warning("Ignoring plugin channel in outgoing REGISTER: " + channels[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
|
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
|
||||||
@ -238,8 +242,12 @@ public class InventoryPackets {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
String channel = wrapper.get(Type.STRING, 0);
|
String channel = wrapper.get(Type.STRING, 0);
|
||||||
|
String old = channel;
|
||||||
channel = getOldPluginChannelId(channel);
|
channel = getOldPluginChannelId(channel);
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
|
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
|
||||||
|
Via.getPlatform().getLogger().warning("Ignoring incoming plugin message with channel: " + old);
|
||||||
|
}
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
return;
|
return;
|
||||||
} else if (channel.equals("REGISTER") || channel.equals("UNREGISTER")) {
|
} else if (channel.equals("REGISTER") || channel.equals("UNREGISTER")) {
|
||||||
@ -250,7 +258,7 @@ public class InventoryPackets {
|
|||||||
if (rewritten != null) {
|
if (rewritten != null) {
|
||||||
rewrittenChannels.add(rewritten);
|
rewrittenChannels.add(rewritten);
|
||||||
} else if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
|
} else if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
|
||||||
Via.getPlatform().getLogger().warning("Ignoring plugin channel in REGISTER: " + channels[i]);
|
Via.getPlatform().getLogger().warning("Ignoring plugin channel in incoming REGISTER: " + channels[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
|
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
|
||||||
@ -381,15 +389,18 @@ public class InventoryPackets {
|
|||||||
tag.put(ConverterRegistry.convertToTag(NBT_TAG_NAME + "|CanPlaceOn", ConverterRegistry.convertToValue(old))); // There will be data losing
|
tag.put(ConverterRegistry.convertToTag(NBT_TAG_NAME + "|CanPlaceOn", ConverterRegistry.convertToValue(old))); // There will be data losing
|
||||||
for (Tag oldTag : old) {
|
for (Tag oldTag : old) {
|
||||||
Object value = oldTag.getValue();
|
Object value = oldTag.getValue();
|
||||||
String[] newValues = BlockIdData.blockIdMapping.get(value instanceof String
|
String oldId = value.toString().replace("minecraft:", "");
|
||||||
? ((String) value).replace("minecraft:", "")
|
String numberConverted = BlockIdData.numberIdToString.get(Ints.tryParse(oldId));
|
||||||
: null);
|
if (numberConverted != null) {
|
||||||
|
oldId = numberConverted;
|
||||||
|
}
|
||||||
|
String[] newValues = BlockIdData.blockIdMapping.get(oldId);
|
||||||
if (newValues != null) {
|
if (newValues != null) {
|
||||||
for (String newValue : newValues) {
|
for (String newValue : newValues) {
|
||||||
newCanPlaceOn.add(new StringTag("", newValue));
|
newCanPlaceOn.add(new StringTag("", newValue));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newCanPlaceOn.add(oldTag);
|
newCanPlaceOn.add(new StringTag("", oldId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tag.put(newCanPlaceOn);
|
tag.put(newCanPlaceOn);
|
||||||
@ -400,15 +411,18 @@ public class InventoryPackets {
|
|||||||
tag.put(ConverterRegistry.convertToTag(NBT_TAG_NAME + "|CanDestroy", ConverterRegistry.convertToValue(old))); // There will be data losing
|
tag.put(ConverterRegistry.convertToTag(NBT_TAG_NAME + "|CanDestroy", ConverterRegistry.convertToValue(old))); // There will be data losing
|
||||||
for (Tag oldTag : old) {
|
for (Tag oldTag : old) {
|
||||||
Object value = oldTag.getValue();
|
Object value = oldTag.getValue();
|
||||||
String[] newValues = BlockIdData.blockIdMapping.get(value instanceof String
|
String oldId = value.toString().replace("minecraft:", "");
|
||||||
? ((String) value).replace("minecraft:", "")
|
String numberConverted = BlockIdData.numberIdToString.get(Ints.tryParse(oldId));
|
||||||
: null);
|
if (numberConverted != null) {
|
||||||
|
oldId = numberConverted;
|
||||||
|
}
|
||||||
|
String[] newValues = BlockIdData.blockIdMapping.get(oldId);
|
||||||
if (newValues != null) {
|
if (newValues != null) {
|
||||||
for (String newValue : newValues) {
|
for (String newValue : newValues) {
|
||||||
newCanDestroy.add(new StringTag("", newValue));
|
newCanDestroy.add(new StringTag("", newValue));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newCanDestroy.add(oldTag);
|
newCanDestroy.add(new StringTag("", oldId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tag.put(newCanDestroy);
|
tag.put(newCanDestroy);
|
||||||
@ -488,9 +502,7 @@ public class InventoryPackets {
|
|||||||
return "wdl:request";
|
return "wdl:request";
|
||||||
default:
|
default:
|
||||||
return old.matches("([0-9a-z_-]*:)?[0-9a-z_/.-]*") // Identifier regex
|
return old.matches("([0-9a-z_-]*:)?[0-9a-z_/.-]*") // Identifier regex
|
||||||
? old
|
? old : null;
|
||||||
: "viaversion:legacy/" + BaseEncoding.base32().lowerCase().withPadChar('-').encode(
|
|
||||||
old.getBytes(StandardCharsets.UTF_8));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,14 +722,8 @@ public class InventoryPackets {
|
|||||||
case "wdl:request":
|
case "wdl:request":
|
||||||
return "WDL|REQUEST";
|
return "WDL|REQUEST";
|
||||||
default:
|
default:
|
||||||
return newId.startsWith("viaversion:legacy/") // Our format :)
|
return newId.matches("([0-9a-z_-]*:)?[0-9a-z_/.-]*") // Identifier regex
|
||||||
? new String(BaseEncoding.base32().lowerCase().withPadChar('-').decode(
|
? newId : null;
|
||||||
newId.substring(18)), StandardCharsets.UTF_8)
|
|
||||||
: newId.startsWith("legacy:")
|
|
||||||
? newId.substring(7) // Rewrite BungeeCord's format. It will only prevent kicks, plugins will still be broken because of case-sensitivity *plays sad violin*
|
|
||||||
: newId.startsWith("bungeecord:legacy/")
|
|
||||||
? newId.substring(18)
|
|
||||||
: newId;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,256 @@
|
|||||||
|
{
|
||||||
|
"0": "air",
|
||||||
|
"1": "stone",
|
||||||
|
"2": "grass",
|
||||||
|
"3": "dirt",
|
||||||
|
"4": "cobblestone",
|
||||||
|
"5": "planks",
|
||||||
|
"6": "sapling",
|
||||||
|
"7": "bedrock",
|
||||||
|
"8": "flowing_water",
|
||||||
|
"9": "water",
|
||||||
|
"10": "flowing_lava",
|
||||||
|
"11": "lava",
|
||||||
|
"12": "sand",
|
||||||
|
"13": "gravel",
|
||||||
|
"14": "gold_ore",
|
||||||
|
"15": "iron_ore",
|
||||||
|
"16": "coal_ore",
|
||||||
|
"17": "log",
|
||||||
|
"18": "leaves",
|
||||||
|
"19": "sponge",
|
||||||
|
"20": "glass",
|
||||||
|
"21": "lapis_ore",
|
||||||
|
"22": "lapis_block",
|
||||||
|
"23": "dispenser",
|
||||||
|
"24": "sandstone",
|
||||||
|
"25": "noteblock",
|
||||||
|
"26": "bed",
|
||||||
|
"27": "golden_rail",
|
||||||
|
"28": "detector_rail",
|
||||||
|
"29": "sticky_piston",
|
||||||
|
"30": "web",
|
||||||
|
"31": "tallgrass",
|
||||||
|
"32": "deadbush",
|
||||||
|
"33": "piston",
|
||||||
|
"34": "piston_head",
|
||||||
|
"35": "wool",
|
||||||
|
"36": "piston_extension",
|
||||||
|
"37": "yellow_flower",
|
||||||
|
"38": "red_flower",
|
||||||
|
"39": "brown_mushroom",
|
||||||
|
"40": "red_mushroom",
|
||||||
|
"41": "gold_block",
|
||||||
|
"42": "iron_block",
|
||||||
|
"43": "double_stone_slab",
|
||||||
|
"44": "stone_slab",
|
||||||
|
"45": "brick_block",
|
||||||
|
"46": "tnt",
|
||||||
|
"47": "bookshelf",
|
||||||
|
"48": "mossy_cobblestone",
|
||||||
|
"49": "obsidian",
|
||||||
|
"50": "torch",
|
||||||
|
"51": "fire",
|
||||||
|
"52": "mob_spawner",
|
||||||
|
"53": "oak_stairs",
|
||||||
|
"54": "chest",
|
||||||
|
"55": "redstone_wire",
|
||||||
|
"56": "diamond_ore",
|
||||||
|
"57": "diamond_block",
|
||||||
|
"58": "crafting_table",
|
||||||
|
"59": "wheat",
|
||||||
|
"60": "farmland",
|
||||||
|
"61": "furnace",
|
||||||
|
"62": "lit_furnace",
|
||||||
|
"63": "standing_sign",
|
||||||
|
"64": "wooden_door",
|
||||||
|
"65": "ladder",
|
||||||
|
"66": "rail",
|
||||||
|
"67": "stone_stairs",
|
||||||
|
"68": "wall_sign",
|
||||||
|
"69": "lever",
|
||||||
|
"70": "stone_pressure_plate",
|
||||||
|
"71": "iron_door",
|
||||||
|
"72": "wooden_pressure_plate",
|
||||||
|
"73": "redstone_ore",
|
||||||
|
"74": "lit_redstone_ore",
|
||||||
|
"75": "unlit_redstone_torch",
|
||||||
|
"76": "redstone_torch",
|
||||||
|
"77": "stone_button",
|
||||||
|
"78": "snow_layer",
|
||||||
|
"79": "ice",
|
||||||
|
"80": "snow",
|
||||||
|
"81": "cactus",
|
||||||
|
"82": "clay",
|
||||||
|
"83": "reeds",
|
||||||
|
"84": "jukebox",
|
||||||
|
"85": "fence",
|
||||||
|
"86": "pumpkin",
|
||||||
|
"87": "netherrack",
|
||||||
|
"88": "soul_sand",
|
||||||
|
"89": "glowstone",
|
||||||
|
"90": "portal",
|
||||||
|
"91": "lit_pumpkin",
|
||||||
|
"92": "cake",
|
||||||
|
"93": "unpowered_repeater",
|
||||||
|
"94": "powered_repeater",
|
||||||
|
"95": "stained_glass",
|
||||||
|
"96": "trapdoor",
|
||||||
|
"97": "monster_egg",
|
||||||
|
"98": "stonebrick",
|
||||||
|
"99": "brown_mushroom_block",
|
||||||
|
"100": "red_mushroom_block",
|
||||||
|
"101": "iron_bars",
|
||||||
|
"102": "glass_pane",
|
||||||
|
"103": "melon_block",
|
||||||
|
"104": "pumpkin_stem",
|
||||||
|
"105": "melon_stem",
|
||||||
|
"106": "vine",
|
||||||
|
"107": "fence_gate",
|
||||||
|
"108": "brick_stairs",
|
||||||
|
"109": "stone_brick_stairs",
|
||||||
|
"110": "mycelium",
|
||||||
|
"111": "waterlily",
|
||||||
|
"112": "nether_brick",
|
||||||
|
"113": "nether_brick_fence",
|
||||||
|
"114": "nether_brick_stairs",
|
||||||
|
"115": "nether_wart",
|
||||||
|
"116": "enchanting_table",
|
||||||
|
"117": "brewing_stand",
|
||||||
|
"118": "cauldron",
|
||||||
|
"119": "end_portal",
|
||||||
|
"120": "end_portal_frame",
|
||||||
|
"121": "end_stone",
|
||||||
|
"122": "dragon_egg",
|
||||||
|
"123": "redstone_lamp",
|
||||||
|
"124": "lit_redstone_lamp",
|
||||||
|
"125": "double_wooden_slab",
|
||||||
|
"126": "wooden_slab",
|
||||||
|
"127": "cocoa",
|
||||||
|
"128": "sandstone_stairs",
|
||||||
|
"129": "emerald_ore",
|
||||||
|
"130": "ender_chest",
|
||||||
|
"131": "tripwire_hook",
|
||||||
|
"132": "tripwire",
|
||||||
|
"133": "emerald_block",
|
||||||
|
"134": "spruce_stairs",
|
||||||
|
"135": "birch_stairs",
|
||||||
|
"136": "jungle_stairs",
|
||||||
|
"137": "command_block",
|
||||||
|
"138": "beacon",
|
||||||
|
"139": "cobblestone_wall",
|
||||||
|
"140": "flower_pot",
|
||||||
|
"141": "carrots",
|
||||||
|
"142": "potatoes",
|
||||||
|
"143": "wooden_button",
|
||||||
|
"144": "skull",
|
||||||
|
"145": "anvil",
|
||||||
|
"146": "trapped_chest",
|
||||||
|
"147": "light_weighted_pressure_plate",
|
||||||
|
"148": "heavy_weighted_pressure_plate",
|
||||||
|
"149": "unpowered_comparator",
|
||||||
|
"150": "powered_comparator",
|
||||||
|
"151": "daylight_detector",
|
||||||
|
"152": "redstone_block",
|
||||||
|
"153": "quartz_ore",
|
||||||
|
"154": "hopper",
|
||||||
|
"155": "quartz_block",
|
||||||
|
"156": "quartz_stairs",
|
||||||
|
"157": "activator_rail",
|
||||||
|
"158": "dropper",
|
||||||
|
"159": "stained_hardened_clay",
|
||||||
|
"160": "stained_glass_pane",
|
||||||
|
"161": "leaves2",
|
||||||
|
"162": "log2",
|
||||||
|
"163": "acacia_stairs",
|
||||||
|
"164": "dark_oak_stairs",
|
||||||
|
"165": "slime",
|
||||||
|
"166": "barrier",
|
||||||
|
"167": "iron_trapdoor",
|
||||||
|
"168": "prismarine",
|
||||||
|
"169": "sea_lantern",
|
||||||
|
"170": "hay_block",
|
||||||
|
"171": "carpet",
|
||||||
|
"172": "hardened_clay",
|
||||||
|
"173": "coal_block",
|
||||||
|
"174": "packed_ice",
|
||||||
|
"175": "double_plant",
|
||||||
|
"176": "standing_banner",
|
||||||
|
"177": "wall_banner",
|
||||||
|
"178": "daylight_detector_inverted",
|
||||||
|
"179": "red_sandstone",
|
||||||
|
"180": "red_sandstone_stairs",
|
||||||
|
"181": "double_stone_slab2",
|
||||||
|
"182": "stone_slab2",
|
||||||
|
"183": "spruce_fence_gate",
|
||||||
|
"184": "birch_fence_gate",
|
||||||
|
"185": "jungle_fence_gate",
|
||||||
|
"186": "dark_oak_fence_gate",
|
||||||
|
"187": "acacia_fence_gate",
|
||||||
|
"188": "spruce_fence",
|
||||||
|
"189": "birch_fence",
|
||||||
|
"190": "jungle_fence",
|
||||||
|
"191": "dark_oak_fence",
|
||||||
|
"192": "acacia_fence",
|
||||||
|
"193": "spruce_door",
|
||||||
|
"194": "birch_door",
|
||||||
|
"195": "jungle_door",
|
||||||
|
"196": "acacia_door",
|
||||||
|
"197": "dark_oak_door",
|
||||||
|
"198": "end_rod",
|
||||||
|
"199": "chorus_plant",
|
||||||
|
"200": "chorus_flower",
|
||||||
|
"201": "purpur_block",
|
||||||
|
"202": "purpur_pillar",
|
||||||
|
"203": "purpur_stairs",
|
||||||
|
"204": "purpur_double_slab",
|
||||||
|
"205": "purpur_slab",
|
||||||
|
"206": "end_bricks",
|
||||||
|
"207": "beetroots",
|
||||||
|
"208": "grass_path",
|
||||||
|
"209": "end_gateway",
|
||||||
|
"210": "repeating_command_block",
|
||||||
|
"211": "chain_command_block",
|
||||||
|
"212": "frosted_ice",
|
||||||
|
"213": "magma",
|
||||||
|
"214": "nether_wart_block",
|
||||||
|
"215": "red_nether_brick",
|
||||||
|
"216": "bone_block",
|
||||||
|
"217": "structure_void",
|
||||||
|
"218": "observer",
|
||||||
|
"219": "white_shulker_box",
|
||||||
|
"220": "orange_shulker_box",
|
||||||
|
"221": "magenta_shulker_box",
|
||||||
|
"222": "light_blue_shulker_box",
|
||||||
|
"223": "yellow_shulker_box",
|
||||||
|
"224": "lime_shulker_box",
|
||||||
|
"225": "pink_shulker_box",
|
||||||
|
"226": "gray_shulker_box",
|
||||||
|
"227": "silver_shulker_box",
|
||||||
|
"228": "cyan_shulker_box",
|
||||||
|
"229": "purple_shulker_box",
|
||||||
|
"230": "blue_shulker_box",
|
||||||
|
"231": "brown_shulker_box",
|
||||||
|
"232": "green_shulker_box",
|
||||||
|
"233": "red_shulker_box",
|
||||||
|
"234": "black_shulker_box",
|
||||||
|
"235": "white_glazed_terracotta",
|
||||||
|
"236": "orange_glazed_terracotta",
|
||||||
|
"237": "magenta_glazed_terracotta",
|
||||||
|
"238": "light_blue_glazed_terracotta",
|
||||||
|
"239": "yellow_glazed_terracotta",
|
||||||
|
"240": "lime_glazed_terracotta",
|
||||||
|
"241": "pink_glazed_terracotta",
|
||||||
|
"242": "gray_glazed_terracotta",
|
||||||
|
"243": "silver_glazed_terracotta",
|
||||||
|
"244": "cyan_glazed_terracotta",
|
||||||
|
"245": "purple_glazed_terracotta",
|
||||||
|
"246": "blue_glazed_terracotta",
|
||||||
|
"247": "brown_glazed_terracotta",
|
||||||
|
"248": "green_glazed_terracotta",
|
||||||
|
"249": "red_glazed_terracotta",
|
||||||
|
"250": "black_glazed_terracotta",
|
||||||
|
"251": "concrete",
|
||||||
|
"252": "concrete_powder",
|
||||||
|
"255": "structure_block"
|
||||||
|
}
|
2
pom.xml
2
pom.xml
@ -81,7 +81,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.steveice10</groupId>
|
<groupId>com.github.steveice10</groupId>
|
||||||
<artifactId>opennbt</artifactId>
|
<artifactId>opennbt</artifactId>
|
||||||
<version>1.1-SNAPSHOT</version>
|
<version>1.2-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -155,15 +155,20 @@ public class VelocityServerHandler {
|
|||||||
if (previousServerProtocol < id1_13 && protocolId >= id1_13) {
|
if (previousServerProtocol < id1_13 && protocolId >= id1_13) {
|
||||||
ArrayList<String> newChannels = new ArrayList<>();
|
ArrayList<String> newChannels = new ArrayList<>();
|
||||||
for (String oldChannel : knownChannels) {
|
for (String oldChannel : knownChannels) {
|
||||||
newChannels.add(InventoryPackets.getNewPluginChannelId(oldChannel));
|
String transformed = InventoryPackets.getNewPluginChannelId(oldChannel);
|
||||||
|
if (transformed != null) {
|
||||||
|
newChannels.add(transformed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
knownChannels.clear();
|
knownChannels.clear();
|
||||||
knownChannels.addAll(newChannels);
|
knownChannels.addAll(newChannels);
|
||||||
|
|
||||||
} else if (previousServerProtocol >= id1_13 && protocolId < id1_13) {
|
} else if (previousServerProtocol >= id1_13 && protocolId < id1_13) {
|
||||||
ArrayList<String> newChannels = new ArrayList<>();
|
ArrayList<String> newChannels = new ArrayList<>();
|
||||||
for (String oldChannel : knownChannels) {
|
for (String oldChannel : knownChannels) {
|
||||||
newChannels.add(InventoryPackets.getOldPluginChannelId(oldChannel));
|
String transformed = InventoryPackets.getOldPluginChannelId(oldChannel);
|
||||||
|
if (transformed != null) {
|
||||||
|
newChannels.add(transformed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
knownChannels.clear();
|
knownChannels.clear();
|
||||||
knownChannels.addAll(newChannels);
|
knownChannels.addAll(newChannels);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren