Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-27 00:22:53 +01:00
Small cleanups
Dieser Commit ist enthalten in:
Ursprung
9241213fb5
Commit
b60464296b
@ -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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
@ -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;
|
||||||
@ -118,7 +119,7 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
|||||||
if (item.tag() != null) {
|
if (item.tag() != null) {
|
||||||
Tag originalId = item.tag().remove(nbtTagName + "|id");
|
Tag originalId = item.tag().remove(nbtTagName + "|id");
|
||||||
if (originalId instanceof IntTag) {
|
if (originalId instanceof IntTag) {
|
||||||
item.setIdentifier(((IntTag) 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();
|
||||||
|
@ -20,7 +20,6 @@ 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.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;
|
||||||
@ -34,7 +33,7 @@ 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;
|
||||||
|
@ -19,13 +19,12 @@
|
|||||||
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;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
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;
|
||||||
@ -70,7 +69,7 @@ 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.putString("Item", item.key());
|
tag.putString("Item", item.key());
|
||||||
|
@ -20,7 +20,6 @@ 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.Object2IntMap;
|
||||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
||||||
@ -77,7 +76,7 @@ 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.getCompoundTag("blockState");
|
CompoundTag blockState = tag.getCompoundTag("blockState");
|
||||||
if (blockState == null) return tag;
|
if (blockState == null) return tag;
|
||||||
|
|
||||||
|
@ -19,14 +19,13 @@
|
|||||||
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.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);
|
||||||
|
@ -20,14 +20,13 @@ 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;
|
||||||
|
|
||||||
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) {
|
||||||
CompoundTag dataTag = tag.getCompoundTag("SpawnData");
|
CompoundTag dataTag = tag.getCompoundTag("SpawnData");
|
||||||
if (dataTag != null) {
|
if (dataTag != null) {
|
||||||
StringTag idTag = dataTag.getStringTag("id");
|
StringTag idTag = dataTag.getStringTag("id");
|
||||||
|
@ -711,7 +711,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
|||||||
tag.putInt("HideFlags", value);
|
tag.putInt("HideFlags", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noMapped.size() != 0) {
|
if (!noMapped.isEmpty()) {
|
||||||
tag.put(extraNbtTag + "|" + key, noMapped);
|
tag.put(extraNbtTag + "|" + key, noMapped);
|
||||||
|
|
||||||
if (!lore.isEmpty()) {
|
if (!lore.isEmpty()) {
|
||||||
|
@ -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!");
|
||||||
|
@ -80,7 +80,7 @@ public class BackwardsBlockEntityProvider implements Provider {
|
|||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
return handler.transform(user, blockId, tag);
|
return handler.transform(blockId, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,6 +102,7 @@ public class BackwardsBlockEntityProvider implements Provider {
|
|||||||
|
|
||||||
@FunctionalInterface
|
@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -103,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));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -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());
|
||||||
|
@ -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);
|
||||||
|
@ -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