Compare commits

..

4 Commits

Author SHA1 Message Date
Nassim Jahnke
a7373b3ad9
Apply IJ code reformat 2024-05-13 10:24:53 +02:00
FlorianMichael
c066b91bba Rework logging inside protocols and rewriters 2024-05-12 22:42:28 +02:00
FlorianMichael
91a86174a3 Rename data, protocol and mapping classes
Syncs names with a2b7fc82e2
2024-05-12 22:42:28 +02:00
FlorianMichael
0b9d2abb84 Update Via API usage
Question to EntityPacketRewriter1_16_2: is it intended that the LOGIN handler doesn't copy the written dimensions tag or was that just forgotten?
2024-05-12 22:42:28 +02:00
80 changed files with 217 additions and 255 deletions

View File

@ -8,7 +8,7 @@ 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_imports_layout = *, |, $*
ij_java_generate_final_locals = true
ij_java_generate_final_parameters = true

View File

@ -10,13 +10,13 @@ allprojects {
}
val main = setOf(
projects.viabackwards,
projects.viabackwardsCommon,
projects.viabackwardsBukkit,
projects.viabackwardsBungee,
projects.viabackwardsFabric,
projects.viabackwardsSponge,
projects.viabackwardsVelocity
projects.viabackwards,
projects.viabackwardsCommon,
projects.viabackwardsBukkit,
projects.viabackwardsBungee,
projects.viabackwardsFabric,
projects.viabackwardsSponge,
projects.viabackwardsVelocity
).map { it.dependencyProject }
subprojects {

View File

@ -40,9 +40,9 @@ public class FireDamageListener extends ViaBukkitListener {
EntityDamageEvent.DamageCause cause = event.getCause();
if (cause != EntityDamageEvent.DamageCause.FIRE
&& cause != EntityDamageEvent.DamageCause.FIRE_TICK
&& cause != EntityDamageEvent.DamageCause.LAVA
&& cause != EntityDamageEvent.DamageCause.DROWNING) {
&& cause != EntityDamageEvent.DamageCause.FIRE_TICK
&& cause != EntityDamageEvent.DamageCause.LAVA
&& cause != EntityDamageEvent.DamageCause.DROWNING) {
return;
}

View File

@ -24,6 +24,7 @@ import java.net.URL;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
public class ViaBackwardsConfig extends Config implements com.viaversion.viabackwards.api.ViaBackwardsConfig {
@ -34,8 +35,8 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
private boolean fix1_13FormattedInventoryTitles;
private boolean handlePingsAsInvAcknowledgements;
public ViaBackwardsConfig(File configFile) {
super(configFile);
public ViaBackwardsConfig(File configFile, Logger logger) {
super(configFile, logger);
}
@Override

View File

@ -74,7 +74,7 @@ public interface ViaBackwardsPlatform {
* Initialize ViaBackwards.
*/
default void init(final File configFile) {
ViaBackwardsConfig config = new ViaBackwardsConfig(configFile);
ViaBackwardsConfig config = new ViaBackwardsConfig(configFile, getLogger());
config.reload();
Via.getManager().getConfigurationProvider().register(config);

View File

@ -17,13 +17,13 @@
*/
package com.viaversion.viabackwards.api.entities.storage;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.rewriters.EntityRewriterBase;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.util.ProtocolLogger;
import java.util.function.Supplier;
public class EntityPositionHandler {
@ -51,12 +51,13 @@ public class EntityPositionHandler {
StoredEntityData storedEntity = entityRewriter.tracker(wrapper.user()).entityData(entityId);
if (storedEntity == null) {
if (Via.getManager().isDebug()) { // There is too many plugins violating this out there, and reading seems to be hard! :>
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing at position: " + x + " - " + y + " - " + z + " in " + storageClass.getSimpleName());
ProtocolLogger logger = entityRewriter.protocol().getLogger();
logger.warning("Stored entity with id " + entityId + " missing at position: " + x + " - " + y + " - " + z + " in " + storageClass.getSimpleName());
if (entityId == -1 && x == 0 && y == 0 && z == 0) {
ViaBackwards.getPlatform().getLogger().warning("DO NOT REPORT THIS TO VIA, THIS IS A PLUGIN ISSUE");
logger.warning("DO NOT REPORT THIS TO VIA, THIS IS A PLUGIN ISSUE");
} else if (!warnedForMissingEntity) {
warnedForMissingEntity = true;
ViaBackwards.getPlatform().getLogger().warning("This is very likely caused by a plugin sending a teleport packet for an entity outside of the player's range.");
logger.warning("This is very likely caused by a plugin sending a teleport packet for an entity outside of the player's range.");
}
}
return;
@ -69,7 +70,7 @@ public class EntityPositionHandler {
} else {
positionStorage = storedEntity.get(storageClass);
if (positionStorage == null) {
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName());
entityRewriter.protocol().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName());
return;
}
}
@ -81,7 +82,7 @@ public class EntityPositionHandler {
StoredEntityData storedEntity = entityRewriter.tracker(user).entityData(entityId);
EntityPositionStorage entityStorage;
if (storedEntity == null || (entityStorage = storedEntity.get(EntityPositionStorage.class)) == null) {
ViaBackwards.getPlatform().getLogger().warning("Untracked entity with id " + entityId + " in " + storageClass.getSimpleName());
entityRewriter.protocol().getLogger().warning("Untracked entity with id " + entityId + " in " + storageClass.getSimpleName());
return null;
}
return entityStorage;

View File

@ -21,7 +21,7 @@ package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.MappedLegacyBlockItem;
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.data.BlockColors;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.data.BlockColors1_11_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
@ -121,7 +121,7 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
// Special block color handling
if (name != null && name.contains("%color%")) {
for (int i = from; i <= to; i++) {
mappings.put(IdAndData.toRawData(i, -1), new MappedLegacyBlockItem(id, data, name.replace("%color%", BlockColors.get(i - from)), type));
mappings.put(IdAndData.toRawData(i, -1), new MappedLegacyBlockItem(id, data, name.replace("%color%", BlockColors1_11_1.get(i - from)), type));
}
} else {
MappedLegacyBlockItem mappedBlockItem = new MappedLegacyBlockItem(id, data, name, type);
@ -202,7 +202,7 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
// Handle colors
String value = nameTag.getValue();
if (value.contains("%vb_color%")) {
display.putString("Name", value.replace("%vb_color%", BlockColors.get(originalData)));
display.putString("Name", value.replace("%vb_color%", BlockColors1_11_1.get(originalData)));
}
}
return item;
@ -382,7 +382,7 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
private record Pos(int x, short y, int z) {
public Pos( int x, int y, int z){
public Pos(int x, int y, int z) {
this(x, (short) y, z);
}
}

View File

@ -156,7 +156,7 @@ public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T ex
return wrapper -> {
ObjectType type = objectGetter.apply(wrapper.get(Types.BYTE, 0));
if (type == null) {
ViaBackwards.getPlatform().getLogger().warning("Could not find Entity Type" + wrapper.get(Types.BYTE, 0));
protocol.getLogger().warning("Could not find Entity Type" + wrapper.get(Types.BYTE, 0));
return;
}

View File

@ -55,7 +55,7 @@ public class TranslatableRewriter<C extends ClientboundPacketType> extends Compo
super(protocol, type);
final Map<String, String> translatableMappings = TRANSLATABLES.get(sectionIdentifier);
if (translatableMappings == null) {
ViaBackwards.getPlatform().getLogger().warning("Missing " + sectionIdentifier + " translatables!");
protocol.getLogger().warning("Missing " + sectionIdentifier + " translatables!");
this.translatables = new HashMap<>();
} else {
this.translatables = translatableMappings;

View File

@ -42,8 +42,8 @@ public class Protocol1_10To1_9_3 extends BackwardsProtocol<ClientboundPackets1_9
return (short) Math.round(inputValue * 63.5F);
}
};
private final EntityPacketRewriter1_10 entityPackets = new EntityPacketRewriter1_10(this);
private final BlockItemPacketRewriter1_10 blockItemPackets = new BlockItemPacketRewriter1_10(this);
private final EntityPacketRewriter1_10 entityRewriter = new EntityPacketRewriter1_10(this);
private final BlockItemPacketRewriter1_10 itemRewriter = new BlockItemPacketRewriter1_10(this);
public Protocol1_10To1_9_3() {
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
@ -51,8 +51,8 @@ public class Protocol1_10To1_9_3 extends BackwardsProtocol<ClientboundPackets1_9
@Override
protected void registerPackets() {
entityPackets.register();
blockItemPackets.register();
entityRewriter.register();
itemRewriter.register();
SoundRewriter<ClientboundPackets1_9_3> soundRewriter = new SoundRewriter<>(this);
registerClientbound(ClientboundPackets1_9_3.CUSTOM_SOUND, new PacketHandlers() {
@ -107,12 +107,12 @@ public class Protocol1_10To1_9_3 extends BackwardsProtocol<ClientboundPackets1_9
@Override
public EntityPacketRewriter1_10 getEntityRewriter() {
return entityPackets;
return entityRewriter;
}
@Override
public BlockItemPacketRewriter1_10 getItemRewriter() {
return blockItemPackets;
return itemRewriter;
}
@Override

View File

@ -30,19 +30,13 @@ import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPacke
public class Protocol1_11_1To1_11 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
private final EntityPacketRewriter1_11_1 entityPackets = new EntityPacketRewriter1_11_1(this);
private final EntityPacketRewriter1_11_1 entityRewriter = new EntityPacketRewriter1_11_1(this);
private final ItemPacketRewriter1_11_1 itemRewriter = new ItemPacketRewriter1_11_1(this);
public Protocol1_11_1To1_11() {
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
}
@Override
protected void registerPackets() {
entityPackets.register();
itemRewriter.register();
}
@Override
public void init(UserConnection user) {
if (!user.has(ClientWorld.class)) {
@ -54,7 +48,7 @@ public class Protocol1_11_1To1_11 extends BackwardsProtocol<ClientboundPackets1_
@Override
public EntityPacketRewriter1_11_1 getEntityRewriter() {
return entityPackets;
return entityRewriter;
}
@Override

View File

@ -23,7 +23,7 @@ import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.BlockItemPacketRewriter1_11;
import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.EntityPacketRewriter1_11;
import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.PlayerPacketRewriterRewriter1_11;
import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.PlayerPacketRewriter1_11;
import com.viaversion.viabackwards.protocol.v1_11to1_10.storage.WindowTracker;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
@ -35,8 +35,8 @@ import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPacke
public class Protocol1_11To1_10 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.11", "1.10");
private final EntityPacketRewriter1_11 entityPackets = new EntityPacketRewriter1_11(this);
private final BlockItemPacketRewriter1_11 blockItemPackets = new BlockItemPacketRewriter1_11(this);
private final EntityPacketRewriter1_11 entityRewriter = new EntityPacketRewriter1_11(this);
private final BlockItemPacketRewriter1_11 itemRewriter = new BlockItemPacketRewriter1_11(this);
public Protocol1_11To1_10() {
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
@ -44,9 +44,9 @@ public class Protocol1_11To1_10 extends BackwardsProtocol<ClientboundPackets1_9_
@Override
protected void registerPackets() {
blockItemPackets.register();
entityPackets.register();
PlayerPacketRewriterRewriter1_11.register(this);
entityRewriter.register();
itemRewriter.register();
PlayerPacketRewriter1_11.register(this);
SoundRewriter<ClientboundPackets1_9_3> soundRewriter = new SoundRewriter<>(this);
soundRewriter.registerNamedSound(ClientboundPackets1_9_3.CUSTOM_SOUND);
@ -73,12 +73,12 @@ public class Protocol1_11To1_10 extends BackwardsProtocol<ClientboundPackets1_9_
@Override
public EntityPacketRewriter1_11 getEntityRewriter() {
return entityPackets;
return entityRewriter;
}
@Override
public BlockItemPacketRewriter1_11 getItemRewriter() {
return blockItemPackets;
return itemRewriter;
}
@Override

View File

@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.v1_11to1_10.data;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
public class PotionSplashHandler {
public class SplashPotions1_10 {
private static final Int2IntMap DATA = new Int2IntOpenHashMap(14, 0.99F);

View File

@ -33,12 +33,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.Item;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.viaversion.protocols.v1_10to1_11.rewriter.EntityIdRewriter;
import com.viaversion.viaversion.protocols.v1_10to1_11.data.EntityNames1_11;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
import com.viaversion.viaversion.util.IdAndData;
@ -210,7 +209,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
// Handler Spawners
if (wrapper.get(Types.UNSIGNED_BYTE, 0) == 1) {
CompoundTag tag = wrapper.get(Types.NAMED_COMPOUND_TAG, 0);
EntityIdRewriter.toClientSpawner(tag, true);
EntityNames1_11.toClientSpawner(tag, true);
}
});
}
@ -281,7 +280,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
// Handle spawner block entity (map to itself with custom handler)
MappedLegacyBlockItem data = itemReplacements.computeIfAbsent(IdAndData.toRawData(52), s -> new MappedLegacyBlockItem(52));
data.setBlockEntityHandler((b, tag) -> {
EntityIdRewriter.toClientSpawner(tag, true);
EntityNames1_11.toClientSpawner(tag, true);
return tag;
});
@ -301,7 +300,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
if (tag == null) return item;
// Rewrite spawn eggs (id checks are done in the method itself)
EntityIdRewriter.toClientItem(item, true);
EntityNames1_11.toClientItem(item, true);
enchantmentRewriter.handleToClient(item);
return item;
@ -316,7 +315,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
if (tag == null) return item;
// Rewrite spawn eggs (id checks are done in the method itself)
EntityIdRewriter.toServerItem(item, true);
EntityNames1_11.toServerItem(item, true);
enchantmentRewriter.handleToServer(item);
return item;

View File

@ -18,11 +18,10 @@
package com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter;
import com.viaversion.viabackwards.api.entities.storage.EntityData;
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
import com.viaversion.viabackwards.protocol.v1_11to1_10.Protocol1_11To1_10;
import com.viaversion.viabackwards.protocol.v1_11to1_10.data.PotionSplashHandler;
import com.viaversion.viabackwards.protocol.v1_11to1_10.data.SplashPotions1_10;
import com.viaversion.viabackwards.protocol.v1_11to1_10.storage.ChestedHorseStorage;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
@ -30,7 +29,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_9;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
@ -58,7 +56,7 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
wrapper.set(Types.INT, 0, 2002);
}
int mappedData = PotionSplashHandler.getOldData(wrapper.get(Types.INT, 1));
int mappedData = SplashPotions1_10.getOldData(wrapper.get(Types.INT, 1));
if (mappedData != -1) {
wrapper.set(Types.INT, 1, mappedData);
}

View File

@ -22,7 +22,6 @@ import com.viaversion.viabackwards.protocol.v1_11to1_10.Protocol1_11To1_10;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject;
@ -30,7 +29,7 @@ import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPacke
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3;
import com.viaversion.viaversion.util.ComponentUtil;
public class PlayerPacketRewriterRewriter1_11 {
public class PlayerPacketRewriter1_11 {
private static final ValueTransformer<Short, Float> TO_NEW_FLOAT = new ValueTransformer<>(Types.FLOAT) {
@Override
public Float transform(PacketWrapper wrapper, Short inputValue) {

View File

@ -20,9 +20,9 @@ package com.viaversion.viabackwards.protocol.v1_12to1_11_1;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.data.ShoulderTracker;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.storage.ShoulderTracker;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter.BlockItemPacketRewriter1_12;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter.ChatPacketRewriter1_12;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter.ComponentRewriter1_12;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter.EntityPacketRewriter1_12;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter.SoundPacketRewriter1_12;
import com.viaversion.viaversion.api.connection.UserConnection;
@ -40,8 +40,8 @@ import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9;
public class Protocol1_12To1_11_1 extends BackwardsProtocol<ClientboundPackets1_12, ClientboundPackets1_9_3, ServerboundPackets1_12, ServerboundPackets1_9_3> {
private static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.12", "1.11");
private final EntityPacketRewriter1_12 entityPackets = new EntityPacketRewriter1_12(this);
private final BlockItemPacketRewriter1_12 blockItemPackets = new BlockItemPacketRewriter1_12(this);
private final EntityPacketRewriter1_12 entityRewriter = new EntityPacketRewriter1_12(this);
private final BlockItemPacketRewriter1_12 itemRewriter = new BlockItemPacketRewriter1_12(this);
public Protocol1_12To1_11_1() {
super(ClientboundPackets1_12.class, ClientboundPackets1_9_3.class, ServerboundPackets1_12.class, ServerboundPackets1_9_3.class);
@ -49,10 +49,10 @@ public class Protocol1_12To1_11_1 extends BackwardsProtocol<ClientboundPackets1_
@Override
protected void registerPackets() {
blockItemPackets.register();
entityPackets.register();
itemRewriter.register();
entityRewriter.register();
new SoundPacketRewriter1_12(this).register();
new ChatPacketRewriter1_12(this).register();
new ComponentRewriter1_12(this).register();
registerClientbound(ClientboundPackets1_12.SET_TITLES, wrapper -> {
int action = wrapper.passthrough(Types.VAR_INT);
@ -85,12 +85,12 @@ public class Protocol1_12To1_11_1 extends BackwardsProtocol<ClientboundPackets1_
@Override
public EntityPacketRewriter1_12 getEntityRewriter() {
return entityPackets;
return entityRewriter;
}
@Override
public BlockItemPacketRewriter1_12 getItemRewriter() {
return blockItemPackets;
return itemRewriter;
}
@Override

View File

@ -21,7 +21,7 @@ package com.viaversion.viabackwards.protocol.v1_12to1_11_1.data;
import java.util.HashMap;
import java.util.Map;
public class AdvancementTranslations {
public class AdvancementTranslations1_11_1 {
private static final Map<String, String> advancements = new HashMap<>();
static {

View File

@ -18,7 +18,7 @@
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.data;
public class BlockColors {
public class BlockColors1_11_1 {
private static final String[] COLORS = new String[16];
static {

View File

@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.v1_12to1_11_1.data;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
public class MapColorMapping {
public class MapColors1_11_1 {
private static final Int2IntMap MAPPING = new Int2IntOpenHashMap(64, 0.99F);
static {

View File

@ -20,15 +20,13 @@ package com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter;
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.data.MapColorMapping;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.data.MapColors1_11_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
import com.viaversion.nbt.tag.CompoundTag;
@ -76,7 +74,7 @@ public class BlockItemPacketRewriter1_12 extends LegacyBlockItemRewriter<Clientb
for (int i = 0; i < data.length; i++) {
short color = (short) (data[i] & 0xFF);
if (color > 143) {
color = (short) MapColorMapping.getNearestOldColor(color);
color = (short) MapColors1_11_1.getNearestOldColor(color);
data[i] = (byte) color;
}
}

View File

@ -19,17 +19,16 @@
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.data.AdvancementTranslations;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.data.AdvancementTranslations1_11_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.rewriter.RewriterBase;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
public class ChatPacketRewriter1_12 extends RewriterBase<Protocol1_12To1_11_1> {
public class ComponentRewriter1_12 extends RewriterBase<Protocol1_12To1_11_1> {
public static final ComponentRewriter<ClientboundPackets1_12> COMPONENT_REWRITER = new ComponentRewriter<>(null, ComponentRewriter.ReadType.JSON) {
@Override
@ -51,14 +50,14 @@ public class ChatPacketRewriter1_12 extends RewriterBase<Protocol1_12To1_11_1> {
@Override
protected void handleTranslate(JsonObject object, String translate) {
String text = AdvancementTranslations.get(translate);
String text = AdvancementTranslations1_11_1.get(translate);
if (text != null) {
object.addProperty("translate", text);
}
}
};
public ChatPacketRewriter1_12(Protocol1_12To1_11_1 protocol) {
public ComponentRewriter1_12(Protocol1_12To1_11_1 protocol) {
super(protocol);
}

View File

@ -20,8 +20,8 @@ package com.viaversion.viabackwards.protocol.v1_12to1_11_1.rewriter;
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.data.ParrotStorage;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.data.ShoulderTracker;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.storage.ParrotStorage;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.storage.ShoulderTracker;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
@ -29,7 +29,6 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_12;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_12;
import com.viaversion.viaversion.libs.gson.JsonElement;
@ -192,7 +191,7 @@ public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPa
filter().handler((event, meta) -> {
if (meta.metaType() == MetaType1_12.COMPONENT) {
ChatPacketRewriter1_12.COMPONENT_REWRITER.processText(event.user(), (JsonElement) meta.getValue());
ComponentRewriter1_12.COMPONENT_REWRITER.processText(event.user(), (JsonElement) meta.getValue());
}
});

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.data;
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.storage;
public class ParrotStorage {
private boolean tamed = true;

View File

@ -16,14 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.data;
package com.viaversion.viabackwards.protocol.v1_12to1_11_1.storage;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.protocol.v1_12to1_11_1.Protocol1_12To1_11_1;
import com.viaversion.viaversion.api.connection.StoredObject;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_11_1to1_12.packet.ClientboundPackets1_12;
import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9;

View File

@ -17,7 +17,6 @@
*/
package com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13;
import com.viaversion.viaversion.api.minecraft.Particle;
@ -26,7 +25,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_13;
import com.viaversion.viaversion.libs.gson.JsonElement;
@ -59,7 +57,7 @@ public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter<Clientbound
byte type = wrapper.get(Types.BYTE, 0);
EntityTypes1_13.EntityType entType = EntityTypes1_13.getTypeFromId(type, true);
if (entType == null) {
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13 entity type " + type);
protocol.getLogger().warning("Could not find entity type " + type);
return;
}

View File

@ -23,7 +23,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.data.BackwardsMappingData1_13;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.data.PaintingMapping;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.providers.BackwardsBlockEntityProvider;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.rewriter.BlockItemPacketRewriter1_13;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.rewriter.EntityPacketRewriter1_13;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.rewriter.PlayerPacketRewriter1_13;
@ -47,11 +47,13 @@ import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ServerboundPacke
import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.util.ComponentUtil;
import com.viaversion.viaversion.util.ProtocolLogger;
import org.checkerframework.checker.nullness.qual.Nullable;
public class Protocol1_13To1_12_2 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_12_1, ServerboundPackets1_13, ServerboundPackets1_12_1> {
public static final BackwardsMappingData1_13 MAPPINGS = new BackwardsMappingData1_13();
public static final ProtocolLogger LOGGER = new ProtocolLogger(Protocol1_13To1_12_2.class);
private final EntityPacketRewriter1_13 entityRewriter = new EntityPacketRewriter1_13(this);
private final BlockItemPacketRewriter1_13 blockItemPackets = new BlockItemPacketRewriter1_13(this);
private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON) {
@ -133,6 +135,11 @@ public class Protocol1_13To1_12_2 extends BackwardsProtocol<ClientboundPackets1_
return MAPPINGS;
}
@Override
public ProtocolLogger getLogger() {
return LOGGER;
}
@Override
public EntityPacketRewriter1_13 getEntityRewriter() {
return entityRewriter;

View File

@ -18,12 +18,11 @@
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.Protocol1_13To1_12_2;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.NumberTag;
import com.viaversion.nbt.tag.Tag;
public class BannerHandler implements BackwardsBlockEntityHandler {
private static final int WALL_BANNER_START = 7110; // 4 each
@ -44,7 +43,7 @@ public class BannerHandler implements BackwardsBlockEntityHandler {
int color = (blockId - WALL_BANNER_START) >> 2;
tag.putInt("Base", 15 - color);
} else {
ViaBackwards.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
Protocol1_13To1_12_2.LOGGER.warning("Why does this block have the banner block entity? :(" + tag);
}
// Invert colors

View File

@ -18,7 +18,7 @@
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.providers.BackwardsBlockEntityProvider;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider;
import com.viaversion.nbt.tag.CompoundTag;
public class BedHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {

View File

@ -18,7 +18,7 @@
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.providers.BackwardsBlockEntityProvider;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
import com.viaversion.nbt.tag.CompoundTag;

View File

@ -16,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.Protocol1_13To1_12_2;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.providers.BackwardsBlockEntityProvider;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.MappingDataLoader;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;

View File

@ -18,7 +18,7 @@
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
import com.viaversion.nbt.tag.CompoundTag;
public class SkullHandler implements BackwardsBlockEntityHandler {

View File

@ -18,8 +18,8 @@
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.data.EntityNameRewrites;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.providers.BackwardsBlockEntityProvider;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.data.EntityNames1_12_2;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.StringTag;
@ -31,7 +31,7 @@ public class SpawnerHandler implements BackwardsBlockEntityProvider.BackwardsBlo
if (dataTag != null) {
StringTag idTag = dataTag.getStringTag("id");
if (idTag != null) {
idTag.setValue(EntityNameRewrites.rewrite(idTag.getValue()));
idTag.setValue(EntityNames1_12_2.rewrite(idTag.getValue()));
}
}
return tag;

View File

@ -21,8 +21,9 @@ package com.viaversion.viabackwards.protocol.v1_13to1_12_2.data;
import com.viaversion.viaversion.util.Key;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
public class EntityNameRewrites {
public class EntityNames1_12_2 {
private static final Map<String, String> ENTITY_NAMES = new HashMap<>();
static {
@ -48,9 +49,6 @@ public class EntityNameRewrites {
public static String rewrite(String entName) {
String entityName = ENTITY_NAMES.get(Key.namespaced(entName));
if (entityName != null) {
return entityName;
} else
return entName;
return Objects.requireNonNullElse(entityName, entName);
}
}

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.providers;
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers.BannerHandler;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers.BedHandler;

View File

@ -24,7 +24,7 @@ import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter;
import com.viaversion.viabackwards.api.rewriters.EnchantmentRewriter;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.Protocol1_13To1_12_2;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers.FlowerPotHandler;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.providers.BackwardsBlockEntityProvider;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.storage.BackwardsBlockStorage;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.storage.NoteBlockStorage;
import com.viaversion.viaversion.api.Via;
@ -39,7 +39,6 @@ import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
@ -513,8 +512,8 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
if (originalId == 362) { // base/colorless shulker box
rawId = 0xe50000; // purple shulker box
} else {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
ViaBackwards.getPlatform().getLogger().warning("Failed to get 1.12 item for " + originalId);
if (!Via.getConfig().isSuppressConversionWarnings()) {
protocol.getLogger().warning("Failed to get new item for " + originalId);
}
rawId = 0x10000;
@ -659,7 +658,7 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
}
if (Via.getManager().isDebug()) {
ViaBackwards.getPlatform().getLogger().warning("Found unknown enchant: " + newId);
protocol.getLogger().warning("Found unknown enchant: " + newId);
}
continue;
} else {
@ -823,8 +822,8 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
} else if (protocol.getMappingData().getItemMappings().inverse().getNewId(rawId & ~0xF) != -1) {
rawId &= ~0xF; // Remove data
} else {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
ViaBackwards.getPlatform().getLogger().warning("Failed to get 1.13 item for " + item.identifier());
if (!Via.getConfig().isSuppressConversionWarnings()) {
protocol.getLogger().warning("Failed to get old item for " + item.identifier());
}
rawId = 16; // Stone
}

View File

@ -143,7 +143,7 @@ public class EntityPacketRewriter1_13 extends LegacyEntityRewriter<ClientboundPa
int oldId = EntityTypeMapping.getOldId(type);
if (oldId == -1) {
if (!hasData(entityType)) {
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.12 entity type for 1.13 entity type " + type + "/" + entityType);
protocol.getLogger().warning("Could not find entity type mapping " + type + "/" + entityType);
}
} else {
wrapper.set(Types.VAR_INT, 1, oldId);

View File

@ -103,8 +103,8 @@ public class PlayerPacketRewriter1_13 extends RewriterBase<Protocol1_13To1_12_2>
} else {
String oldChannel = ItemPacketRewriter1_13.getOldPluginChannelId(channel);
if (oldChannel == null) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
ViaBackwards.getPlatform().getLogger().warning("Ignoring clientbound plugin message with channel: " + channel);
if (!Via.getConfig().isSuppressConversionWarnings()) {
protocol.getLogger().warning("Ignoring clientbound plugin message with channel: " + channel);
}
wrapper.cancel();
return;
@ -118,8 +118,8 @@ public class PlayerPacketRewriter1_13 extends RewriterBase<Protocol1_13To1_12_2>
String rewritten = ItemPacketRewriter1_13.getOldPluginChannelId(s);
if (rewritten != null) {
rewrittenChannels.add(rewritten);
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in clientbound " + oldChannel + ": " + s);
} else if (!Via.getConfig().isSuppressConversionWarnings()) {
protocol.getLogger().warning("Ignoring plugin channel in clientbound " + oldChannel + ": " + s);
}
}
wrapper.write(Types.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
@ -394,7 +394,7 @@ public class PlayerPacketRewriter1_13 extends RewriterBase<Protocol1_13To1_12_2>
//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.SET_COMMAND_BLOCK);
wrapper.cancel();
ViaBackwards.getPlatform().getLogger().warning("Client send MC|AdvCmd custom payload to update command block, weird!");
protocol.getLogger().warning("Client send MC|AdvCmd custom payload to update command block, weird!");
} else if (type == 1) {
wrapper.setPacketType(ServerboundPackets1_13.SET_COMMAND_MINECART);
wrapper.write(Types.VAR_INT, wrapper.read(Types.INT)); //Entity Id
@ -482,8 +482,8 @@ public class PlayerPacketRewriter1_13 extends RewriterBase<Protocol1_13To1_12_2>
default -> {
String newChannel = ItemPacketRewriter1_13.getNewPluginChannelId(channel);
if (newChannel == null) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
ViaBackwards.getPlatform().getLogger().warning("Ignoring serverbound plugin message with channel: " + channel);
if (!Via.getConfig().isSuppressConversionWarnings()) {
protocol.getLogger().warning("Ignoring serverbound plugin message with channel: " + channel);
}
wrapper.cancel();
return;
@ -497,8 +497,8 @@ public class PlayerPacketRewriter1_13 extends RewriterBase<Protocol1_13To1_12_2>
String rewritten = ItemPacketRewriter1_13.getNewPluginChannelId(s);
if (rewritten != null) {
rewrittenChannels.add(rewritten);
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in serverbound " + Key.stripMinecraftNamespace(newChannel).toUpperCase(Locale.ROOT) + ": " + s);
} else if (!Via.getConfig().isSuppressConversionWarnings()) {
protocol.getLogger().warning("Ignoring plugin channel in serverbound " + Key.stripMinecraftNamespace(newChannel).toUpperCase(Locale.ROOT) + ": " + s);
}
}
if (!rewrittenChannels.isEmpty()) {

View File

@ -23,7 +23,7 @@ import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.data.CommandRewriter1_14;
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.rewriter.BlockItemPacketRewriter1_14;
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.rewriter.EntityPacketRewriter1_14;
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.rewriter.PlayerPacketRewriterRewriter1_14;
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.rewriter.PlayerPacketRewriter1_14;
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.rewriter.SoundPacketRewriter1_14;
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.storage.ChunkLightStorage;
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.storage.DifficultyStorage;
@ -44,7 +44,7 @@ public class Protocol1_14To1_13_2 extends BackwardsProtocol<ClientboundPackets1_
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.14", "1.13.2", Protocol1_13_2To1_14.class);
private final EntityPacketRewriter1_14 entityRewriter = new EntityPacketRewriter1_14(this);
private final BlockItemPacketRewriter1_14 blockItemPackets = new BlockItemPacketRewriter1_14(this);
private final BlockItemPacketRewriter1_14 itemRewriter = new BlockItemPacketRewriter1_14(this);
private final TranslatableRewriter<ClientboundPackets1_14> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
public Protocol1_14To1_13_2() {
@ -64,7 +64,7 @@ public class Protocol1_14To1_13_2 extends BackwardsProtocol<ClientboundPackets1_
translatableRewriter.registerPing();
new CommandRewriter1_14(this).registerDeclareCommands(ClientboundPackets1_14.COMMANDS);
new PlayerPacketRewriterRewriter1_14(this).register();
new PlayerPacketRewriter1_14(this).register();
new SoundPacketRewriter1_14(this).register();
new StatisticsRewriter<>(this).register(ClientboundPackets1_14.AWARD_STATS);
@ -187,7 +187,7 @@ public class Protocol1_14To1_13_2 extends BackwardsProtocol<ClientboundPackets1_
@Override
public BlockItemPacketRewriter1_14 getItemRewriter() {
return blockItemPackets;
return itemRewriter;
}
@Override

View File

@ -125,7 +125,7 @@ public class BlockItemPacketRewriter1_14 extends BackwardsItemRewriter<Clientbou
}
if (stringType == null) {
ViaBackwards.getPlatform().getLogger().warning("Can't open inventory for 1.13 player! Type: " + type);
protocol.getLogger().warning("Can't open inventory for player! Type: " + type);
wrapper.cancel();
return;
}

View File

@ -201,7 +201,7 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
if (oldId == -1) {
EntityData entityData = entityDataForType(entityType);
if (entityData == null) {
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13.2 entity type for 1.14 entity type " + type + "/" + entityType);
protocol.getLogger().warning("Could not find entity type mapping " + type + "/" + entityType);
wrapper.cancel();
} else {
wrapper.set(Types.VAR_INT, 1, entityData.replacementId());

View File

@ -22,14 +22,13 @@ import com.viaversion.viabackwards.protocol.v1_14to1_13_2.storage.DifficultyStor
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.rewriter.RewriterBase;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13;
import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ClientboundPackets1_14;
public class PlayerPacketRewriterRewriter1_14 extends RewriterBase<Protocol1_14To1_13_2> {
public class PlayerPacketRewriter1_14 extends RewriterBase<Protocol1_14To1_13_2> {
public PlayerPacketRewriterRewriter1_14(Protocol1_14To1_13_2 protocol) {
public PlayerPacketRewriter1_14(Protocol1_14To1_13_2 protocol) {
super(protocol);
}

View File

@ -55,7 +55,7 @@ public class SoundPacketRewriter1_14 extends RewriterBase<Protocol1_14To1_13_2>
StoredEntityData storedEntity = wrapper.user().getEntityTracker(protocol.getClass()).entityData(entityId);
EntityPositionStorage1_14 entityStorage;
if (storedEntity == null || (entityStorage = storedEntity.get(EntityPositionStorage1_14.class)) == null) {
ViaBackwards.getPlatform().getLogger().warning("Untracked entity with id " + entityId);
protocol.getLogger().warning("Untracked entity with id " + entityId);
return;
}

View File

@ -21,7 +21,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.v1_15to1_14_4.data.ImmediateRespawn;
import com.viaversion.viabackwards.protocol.v1_15to1_14_4.storage.ImmediateRespawnStorage;
import com.viaversion.viabackwards.protocol.v1_15to1_14_4.rewriter.BlockItemPacketRewriter1_15;
import com.viaversion.viabackwards.protocol.v1_15to1_14_4.rewriter.EntityPacketRewriter1_15;
import com.viaversion.viaversion.api.connection.UserConnection;
@ -102,7 +102,7 @@ public class Protocol1_15To1_14_4 extends BackwardsProtocol<ClientboundPackets1_
@Override
public void init(UserConnection user) {
user.put(new ImmediateRespawn());
user.put(new ImmediateRespawnStorage());
user.addEntityTracker(getClass(), new EntityTrackerBase(user, EntityTypes1_15.PLAYER));
}

View File

@ -1,29 +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.protocol.v1_15to1_14_4.data;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
public class EntityTypeMapping {
// There's only the bee, so not much to do here
public static int getOldEntityId(int entityId) {
if (entityId == 4) return EntityTypes1_14.PUFFERFISH.getId(); // Flying pufferfish!
return entityId >= 5 ? entityId - 1 : entityId;
}
}

View File

@ -19,14 +19,13 @@ package com.viaversion.viabackwards.protocol.v1_15to1_14_4.rewriter;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.v1_15to1_14_4.Protocol1_15To1_14_4;
import com.viaversion.viabackwards.protocol.v1_15to1_14_4.data.EntityTypeMapping;
import com.viaversion.viabackwards.protocol.v1_15to1_14_4.data.ImmediateRespawn;
import com.viaversion.viabackwards.protocol.v1_15to1_14_4.storage.ImmediateRespawnStorage;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_14;
import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ServerboundPackets1_14;
@ -44,7 +43,7 @@ public class EntityPacketRewriter1_15 extends EntityRewriter<ClientboundPackets1
protocol.registerClientbound(ClientboundPackets1_15.SET_HEALTH, wrapper -> {
float health = wrapper.passthrough(Types.FLOAT);
if (health > 0) return;
if (!wrapper.user().get(ImmediateRespawn.class).isImmediateRespawn()) return;
if (!wrapper.user().get(ImmediateRespawnStorage.class).isImmediateRespawn()) return;
// Instantly request respawn when 1.15 gamerule is set
PacketWrapper statusPacket = wrapper.create(ServerboundPackets1_14.CLIENT_COMMAND);
@ -59,7 +58,7 @@ public class EntityPacketRewriter1_15 extends EntityRewriter<ClientboundPackets1
map(Types.FLOAT);
handler(wrapper -> {
if (wrapper.get(Types.UNSIGNED_BYTE, 0) == 11) {
wrapper.user().get(ImmediateRespawn.class).setImmediateRespawn(wrapper.get(Types.FLOAT, 0) == 1);
wrapper.user().get(ImmediateRespawnStorage.class).setImmediateRespawn(wrapper.get(Types.FLOAT, 0) == 1);
}
});
}
@ -88,7 +87,7 @@ public class EntityPacketRewriter1_15 extends EntityRewriter<ClientboundPackets1
int type = wrapper.get(Types.VAR_INT, 1);
EntityType entityType = EntityTypes1_15.getTypeFromId(type);
tracker(wrapper.user()).addEntity(wrapper.get(Types.VAR_INT, 0), entityType);
wrapper.set(Types.VAR_INT, 1, EntityTypeMapping.getOldEntityId(type));
wrapper.set(Types.VAR_INT, 1, newEntityId(type));
});
}
});
@ -119,7 +118,7 @@ public class EntityPacketRewriter1_15 extends EntityRewriter<ClientboundPackets1
handler(wrapper -> {
boolean immediateRespawn = !wrapper.read(Types.BOOLEAN); // Inverted
wrapper.user().get(ImmediateRespawn.class).setImmediateRespawn(immediateRespawn);
wrapper.user().get(ImmediateRespawnStorage.class).setImmediateRespawn(immediateRespawn);
});
}
});
@ -223,6 +222,7 @@ public class EntityPacketRewriter1_15 extends EntityRewriter<ClientboundPackets1
@Override
public int newEntityId(final int newId) {
return EntityTypeMapping.getOldEntityId(newId);
if (newId == 4) return EntityTypes1_14.PUFFERFISH.getId(); // Flying pufferfish!
return newId >= 5 ? newId - 1 : newId;
}
}

View File

@ -15,11 +15,11 @@
* 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.v1_15to1_14_4.data;
package com.viaversion.viabackwards.protocol.v1_15to1_14_4.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
public class ImmediateRespawn implements StorableObject {
public class ImmediateRespawnStorage implements StorableObject {
private boolean immediateRespawn;
public boolean isImmediateRespawn() {

View File

@ -21,7 +21,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.data.CommandRewriter1_16_2;
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.CommandRewriter1_16_2;
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.BlockItemPacketRewriter1_16_2;
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.EntityPacketRewriter1_16_2;
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.storage.BiomeStorage;
@ -40,10 +40,12 @@ import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ServerboundPac
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
import com.viaversion.viaversion.util.ProtocolLogger;
public class Protocol1_16_2To1_16_1 extends BackwardsProtocol<ClientboundPackets1_16_2, ClientboundPackets1_16, ServerboundPackets1_16_2, ServerboundPackets1_16> {
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.16.2", "1.16", Protocol1_16_1To1_16_2.class);
public static final ProtocolLogger LOGGER = new ProtocolLogger(Protocol1_16_2To1_16_1.class);
private final EntityPacketRewriter1_16_2 entityRewriter = new EntityPacketRewriter1_16_2(this);
private final BlockItemPacketRewriter1_16_2 blockItemPackets = new BlockItemPacketRewriter1_16_2(this);
private final TranslatableRewriter<ClientboundPackets1_16_2> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
@ -134,6 +136,11 @@ public class Protocol1_16_2To1_16_1 extends BackwardsProtocol<ClientboundPackets
return MAPPINGS;
}
@Override
public ProtocolLogger getLogger() {
return LOGGER;
}
@Override
public EntityPacketRewriter1_16_2 getEntityRewriter() {
return entityRewriter;

View File

@ -19,6 +19,7 @@ package com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.data;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.Protocol1_16_2To1_16_1;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
@ -27,7 +28,7 @@ import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.util.Key;
import java.util.Map;
public final class BiomeMappings {
public final class BiomeMappings1_16_1 {
private static final Object2IntMap<String> MODERN_TO_LEGACY_ID = new Object2IntOpenHashMap<>();
private static final Object2IntMap<String> LEGACY_BIOMES = new Object2IntOpenHashMap<>();
@ -121,7 +122,7 @@ public final class BiomeMappings {
for (final Map.Entry<String, JsonElement> entry : mappings.entrySet()) {
final int legacyBiome = LEGACY_BIOMES.getInt(entry.getValue().getAsString());
if (legacyBiome == -1) {
ViaBackwards.getPlatform().getLogger().warning("Unknown legacy biome: " + entry.getValue().getAsString());
Protocol1_16_2To1_16_1.LOGGER.warning("Unknown legacy biome: " + entry.getValue().getAsString());
continue;
}
@ -137,7 +138,7 @@ public final class BiomeMappings {
final int legacyBiome = MODERN_TO_LEGACY_ID.getInt(Key.stripMinecraftNamespace(biome));
if (legacyBiome == -1) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaBackwards.getPlatform().getLogger().warning("Biome with id " + biome + " has no legacy biome mapping (custom datapack?)");
Protocol1_16_2To1_16_1.LOGGER.warning("Biome with id " + biome + " has no legacy biome mapping (custom datapack?)");
}
return 1; // Plains
}

View File

@ -15,7 +15,7 @@
* 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.v1_16_2to1_16_1.data;
package com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter;
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.Protocol1_16_2To1_16_1;
import com.viaversion.viaversion.api.type.Types;

View File

@ -26,10 +26,9 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_16;
import com.viaversion.viaversion.protocols.v1_15_2to1_16.rewriter.EntityPacketRewriter1_16;
import com.viaversion.viaversion.protocols.v1_15_2to1_16.data.DimensionRegistries1_16;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.NumberTag;
@ -86,11 +85,11 @@ public class EntityPacketRewriter1_16_2 extends EntityRewriter<ClientboundPacket
}
} else if (!warned) {
warned = true;
ViaBackwards.getPlatform().getLogger().warning("1.16 and 1.16.1 clients are only partially supported and may have wrong biomes displayed.");
protocol.getLogger().warning("1.16 and 1.16.1 clients are only partially supported and may have wrong biomes displayed.");
}
// Just screw the registry and write the defaults for 1.16 and 1.16.1 clients
wrapper.write(Types.NAMED_COMPOUND_TAG, EntityPacketRewriter1_16.DIMENSIONS_TAG);
wrapper.write(Types.NAMED_COMPOUND_TAG, DimensionRegistries1_16.getDimensionsTag());
CompoundTag dimensionData = wrapper.read(Types.NAMED_COMPOUND_TAG);
wrapper.write(Types.STRING, getDimensionFromData(dimensionData));

View File

@ -17,7 +17,7 @@
*/
package com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.storage;
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.data.BiomeMappings;
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.data.BiomeMappings1_16_1;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
@ -31,7 +31,7 @@ public final class BiomeStorage implements StorableObject {
}
public void addBiome(final String biome, final int id) {
modernToLegacyBiomes.put(id, BiomeMappings.toLegacyBiome(biome));
modernToLegacyBiomes.put(id, BiomeMappings1_16_1.toLegacyBiome(biome));
}
public int legacyBiome(final int biome) {

View File

@ -19,10 +19,10 @@ package com.viaversion.viabackwards.protocol.v1_16to1_15_2;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.chat.TranslatableRewriter1_16;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.TranslatableRewriter1_16;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.data.BackwardsMappingData1_16;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.data.CommandRewriter1_16;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.data.WorldNameTracker;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.CommandRewriter1_16;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.WorldNameTracker;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.BlockItemPacketRewriter1_16;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.EntityPacketRewriter1_16;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.PlayerSneakStorage;
@ -32,7 +32,6 @@ import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.libs.gson.JsonElement;

View File

@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.v1_16to1_15_2.data;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viaversion.protocols.v1_15_2to1_16.Protocol1_15_2To1_16;
import com.viaversion.viaversion.protocols.v1_15_2to1_16.data.AttributeMappings;
import com.viaversion.viaversion.protocols.v1_15_2to1_16.data.Attributes1_16;
import java.util.HashMap;
import java.util.Map;
@ -34,7 +34,7 @@ public class BackwardsMappingData1_16 extends BackwardsMappingData {
@Override
protected void loadExtras(final CompoundTag data) {
super.loadExtras(data);
for (Map.Entry<String, String> entry : AttributeMappings.attributeIdentifierMappings().entrySet()) {
for (Map.Entry<String, String> entry : Attributes1_16.attributeIdentifierMappings().entrySet()) {
attributeMappings.put(entry.getValue(), entry.getKey());
}
}

View File

@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.v1_16to1_15_2.data;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
public final class MapColorRewrites {
public final class MapColorMappings1_15_2 {
private static final Int2IntMap MAPPINGS = new Int2IntOpenHashMap();

View File

@ -22,7 +22,7 @@ import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter;
import com.viaversion.viabackwards.api.rewriters.EnchantmentRewriter;
import com.viaversion.viabackwards.api.rewriters.MapColorRewriter;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.Protocol1_16To1_15_2;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.data.MapColorRewrites;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.data.MapColorMappings1_15_2;
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.storage.BiomeStorage;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
@ -33,7 +33,6 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_15;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16;
@ -179,7 +178,7 @@ public class BlockItemPacketRewriter1_16 extends BackwardsItemRewriter<Clientbou
int biome = chunk.getBiomeData()[i];
int legacyBiome = biomeStorage.legacyBiome(biome);
if (legacyBiome == -1) {
ViaBackwards.getPlatform().getLogger().warning("Biome sent that does not exist in the biome registry: " + biome);
protocol.getLogger().warning("Biome sent that does not exist in the biome registry: " + biome);
legacyBiome = 1;
}
chunk.getBiomeData()[i] = legacyBiome;
@ -231,7 +230,7 @@ public class BlockItemPacketRewriter1_16 extends BackwardsItemRewriter<Clientbou
map(Types.BYTE); // Scale
map(Types.BOOLEAN); // Tracking Position
map(Types.BOOLEAN); // Locked
handler(MapColorRewriter.getRewriteHandler(MapColorRewrites::getMappedColor));
handler(MapColorRewriter.getRewriteHandler(MapColorMappings1_15_2::getMappedColor));
}
});

View File

@ -15,7 +15,7 @@
* 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.v1_16to1_15_2.data;
package com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.Protocol1_16To1_15_2;
import com.viaversion.viaversion.protocols.v1_15_2to1_16.packet.ClientboundPackets1_16;

View File

@ -19,7 +19,7 @@ package com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.Protocol1_16To1_15_2;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.data.WorldNameTracker;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.WorldNameTracker;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.WolfDataMaskStorage;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
@ -34,7 +34,6 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_14;
import com.viaversion.viaversion.api.type.types.version.Types1_16;

View File

@ -15,7 +15,7 @@
* 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.v1_16to1_15_2.chat;
package com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.v1_16to1_15_2.Protocol1_16To1_15_2;

View File

@ -15,7 +15,7 @@
* 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.v1_16to1_15_2.data;
package com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage;
import com.viaversion.viaversion.api.connection.StorableObject;

View File

@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.v1_17to1_16_4.data;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
public final class MapColorRewrites {
public final class MapColorMappings1_16_4 {
private static final Int2IntMap MAPPINGS = new Int2IntOpenHashMap();

View File

@ -21,7 +21,7 @@ import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter;
import com.viaversion.viabackwards.api.rewriters.MapColorRewriter;
import com.viaversion.viabackwards.protocol.v1_17to1_16_4.Protocol1_17To1_16_4;
import com.viaversion.viabackwards.protocol.v1_17to1_16_4.data.MapColorRewrites;
import com.viaversion.viabackwards.protocol.v1_17to1_16_4.data.MapColorMappings1_16_4;
import com.viaversion.viabackwards.protocol.v1_17to1_16_4.storage.PingRequests;
import com.viaversion.viabackwards.protocol.v1_17to1_16_4.storage.PlayerLastCursorItem;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
@ -33,7 +33,6 @@ import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16_2;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
@ -402,7 +401,7 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter<Cli
if (!hasMarkers) {
wrapper.write(Types.VAR_INT, 0); // Array size
} else {
MapColorRewriter.getRewriteHandler(MapColorRewrites::getMappedColor).handle(wrapper);
MapColorRewriter.getRewriteHandler(MapColorMappings1_16_4::getMappedColor).handle(wrapper);
}
});
}

View File

@ -207,7 +207,7 @@ public final class EntityPacketRewriter1_17 extends EntityRewriter<ClientboundPa
NumberTag logicalHeight = tag.getNumberTag("logical_height");
if (minY.asInt() != 0 || height.asInt() > 256 || logicalHeight.asInt() > 256) {
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");
protocol.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;
}

View File

@ -19,11 +19,10 @@ package com.viaversion.viabackwards.protocol.v1_18_2to1_18;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.protocol.v1_18_2to1_18.data.CommandRewriter1_18_2;
import com.viaversion.viabackwards.protocol.v1_18_2to1_18.rewriter.CommandRewriter1_18_2;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_16_4to1_17.packet.ServerboundPackets1_17;
import com.viaversion.nbt.tag.CompoundTag;
@ -46,7 +45,7 @@ public final class Protocol1_18_2To1_18 extends BackwardsProtocol<ClientboundPac
final int id = wrapper.read(Types.VAR_INT);
if ((byte) id != id) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
ViaBackwards.getPlatform().getLogger().warning("Cannot send entity effect id " + id + " to old client");
getLogger().warning("Cannot send entity effect id " + id + " to old client");
}
wrapper.cancel();
return;

View File

@ -15,10 +15,9 @@
* 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.v1_18_2to1_18.data;
package com.viaversion.viabackwards.protocol.v1_18_2to1_18.rewriter;
import com.viaversion.viabackwards.protocol.v1_18_2to1_18.Protocol1_18_2To1_18;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_17_1to1_18.packet.ClientboundPackets1_18;
import com.viaversion.viaversion.rewriter.CommandRewriter;

View File

@ -23,7 +23,7 @@ import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.viaversion.protocols.v1_17_1to1_18.Protocol1_17_1To1_18;
import com.viaversion.viaversion.protocols.v1_17_1to1_18.data.BlockEntities;
import com.viaversion.viaversion.protocols.v1_17_1to1_18.data.BlockEntities1_18;
public final class BackwardsMappingData1_18 extends BackwardsMappingData {
@ -37,7 +37,7 @@ public final class BackwardsMappingData1_18 extends BackwardsMappingData {
protected void loadExtras(final CompoundTag data) {
super.loadExtras(data);
for (final Object2IntMap.Entry<String> entry : BlockEntities.blockEntityIds().object2IntEntrySet()) {
for (final Object2IntMap.Entry<String> entry : BlockEntities1_18.blockEntityIds().object2IntEntrySet()) {
blockEntities.put(entry.getIntValue(), entry.getKey());
}
}

View File

@ -17,14 +17,15 @@
*/
package com.viaversion.viabackwards.protocol.v1_18to1_17_1.data;
import com.viaversion.viaversion.protocols.v1_17_1to1_18.data.BlockEntityIds1_18;
import java.util.Arrays;
public final class BlockEntityIds {
public final class BlockEntityIds1_17_1 {
private static final int[] IDS;
static {
final int[] ids = com.viaversion.viaversion.protocols.v1_17_1to1_18.data.BlockEntityIds.getIds();
final int[] ids = BlockEntityIds1_18.getIds();
IDS = new int[Arrays.stream(ids).max().getAsInt() + 1];
Arrays.fill(IDS, -1);
for (int i = 0; i < ids.length; i++) {

View File

@ -19,7 +19,7 @@ package com.viaversion.viabackwards.protocol.v1_18to1_17_1.rewriter;
import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter;
import com.viaversion.viabackwards.protocol.v1_18to1_17_1.Protocol1_18To1_17_1;
import com.viaversion.viabackwards.protocol.v1_18to1_17_1.data.BlockEntityIds;
import com.viaversion.viabackwards.protocol.v1_18to1_17_1.data.BlockEntityIds1_17_1;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.Position;
@ -31,7 +31,6 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
@ -132,7 +131,7 @@ public final class BlockItemPacketRewriter1_18 extends BackwardsItemRewriter<Cli
final int id = wrapper.read(Types.VAR_INT);
final CompoundTag tag = wrapper.read(Types.NAMED_COMPOUND_TAG);
final int mappedId = BlockEntityIds.mappedId(id);
final int mappedId = BlockEntityIds1_17_1.mappedId(id);
if (mappedId == -1) {
wrapper.cancel();
return;

View File

@ -34,6 +34,7 @@ import com.viaversion.viaversion.api.minecraft.signature.SignableCommandArgument
import com.viaversion.viaversion.api.minecraft.signature.model.DecoratableMessage;
import com.viaversion.viaversion.api.minecraft.signature.model.MessageMetadata;
import com.viaversion.viaversion.api.minecraft.signature.storage.ChatSession1_19_1;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -168,7 +169,7 @@ public final class Protocol1_19_1To1_19 extends BackwardsProtocol<ClientboundPac
final int chatTypeId = wrapper.read(Types.VAR_INT);
final JsonElement senderName = wrapper.read(Types.COMPONENT);
final JsonElement targetName = wrapper.read(Types.OPTIONAL_COMPONENT);
decoratedMessage = decorateChatMessage(wrapper.user().get(ChatRegistryStorage1_19_1.class), chatTypeId, senderName, targetName, message);
decoratedMessage = decorateChatMessage(this, wrapper.user().get(ChatRegistryStorage1_19_1.class), chatTypeId, senderName, targetName, message);
if (decoratedMessage == null) {
wrapper.cancel();
return;
@ -374,7 +375,7 @@ public final class Protocol1_19_1To1_19 extends BackwardsProtocol<ClientboundPac
data = new byte[]{1};
wrapper.set(Types.REMAINING_BYTES, 0, data);
} else {
ViaBackwards.getPlatform().getLogger().warning("Received unexpected data in velocity:player_info (length=" + data.length + ")");
getLogger().warning("Received unexpected data in velocity:player_info (length=" + data.length + ")");
}
}
});
@ -403,10 +404,12 @@ public final class Protocol1_19_1To1_19 extends BackwardsProtocol<ClientboundPac
return entityRewriter;
}
public static @Nullable JsonElement decorateChatMessage(final ChatRegistryStorage chatRegistryStorage, final int chatTypeId, final JsonElement senderName, @Nullable final JsonElement targetName, final JsonElement message) {
public static @Nullable JsonElement decorateChatMessage(final Protocol protocol, final ChatRegistryStorage chatRegistryStorage,
final int chatTypeId, final JsonElement senderName,
@Nullable final JsonElement targetName, final JsonElement message) {
CompoundTag chatType = chatRegistryStorage.chatType(chatTypeId);
if (chatType == null) {
ViaBackwards.getPlatform().getLogger().warning("Chat message has unknown chat type id " + chatTypeId + ". Message: " + message);
protocol.getLogger().warning("Chat message has unknown chat type id " + chatTypeId + ". Message: " + message);
return null;
}

View File

@ -330,7 +330,7 @@ public final class Protocol1_19_3To1_19_1 extends BackwardsProtocol<ClientboundP
final int chatTypeId = wrapper.read(Types.VAR_INT);
final JsonElement senderName = wrapper.read(Types.COMPONENT);
final JsonElement targetName = wrapper.read(Types.OPTIONAL_COMPONENT);
final JsonElement result = Protocol1_19_1To1_19.decorateChatMessage(wrapper.user().get(ChatTypeStorage1_19_3.class), chatTypeId, senderName, targetName, content);
final JsonElement result = Protocol1_19_1To1_19.decorateChatMessage(Protocol1_19_3To1_19_1.this, wrapper.user().get(ChatTypeStorage1_19_3.class), chatTypeId, senderName, targetName, content);
if (result == null) {
wrapper.cancel();
return;
@ -347,7 +347,7 @@ public final class Protocol1_19_3To1_19_1 extends BackwardsProtocol<ClientboundP
final int chatTypeId = wrapper.read(Types.VAR_INT);
final JsonElement senderName = wrapper.read(Types.COMPONENT);
final JsonElement targetName = wrapper.read(Types.OPTIONAL_COMPONENT);
final JsonElement result = Protocol1_19_1To1_19.decorateChatMessage(wrapper.user().get(ChatTypeStorage1_19_3.class), chatTypeId, senderName, targetName, content);
final JsonElement result = Protocol1_19_1To1_19.decorateChatMessage(this, wrapper.user().get(ChatTypeStorage1_19_3.class), chatTypeId, senderName, targetName, content);
if (result == null) {
wrapper.cancel();
return;

View File

@ -23,7 +23,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.v1_19to1_18_2.data.BackwardsMappingData1_19;
import com.viaversion.viabackwards.protocol.v1_19to1_18_2.data.CommandRewriter1_19;
import com.viaversion.viabackwards.protocol.v1_19to1_18_2.rewriter.CommandRewriter1_19;
import com.viaversion.viabackwards.protocol.v1_19to1_18_2.rewriter.BlockItemPacketRewriter1_19;
import com.viaversion.viabackwards.protocol.v1_19to1_18_2.rewriter.EntityPacketRewriter1_19;
import com.viaversion.viabackwards.protocol.v1_19to1_18_2.storage.DimensionRegistryStorage;
@ -39,7 +39,6 @@ import com.viaversion.viaversion.api.minecraft.signature.model.MessageMetadata;
import com.viaversion.viaversion.api.minecraft.signature.storage.ChatSession1_19_0;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.libs.gson.JsonElement;
@ -165,7 +164,7 @@ public final class Protocol1_19To1_18_2 extends BackwardsProtocol<ClientboundPac
final int argumentTypeId = wrapper.read(Types.VAR_INT);
String argumentType = MAPPINGS.getArgumentTypeMappings().identifier(argumentTypeId);
if (argumentType == null) {
ViaBackwards.getPlatform().getLogger().warning("Unknown command argument type id: " + argumentTypeId);
getLogger().warning("Unknown command argument type id: " + argumentTypeId);
argumentType = "minecraft:no";
}

View File

@ -15,7 +15,7 @@
* 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.v1_19to1_18_2.data;
package com.viaversion.viabackwards.protocol.v1_19to1_18_2.rewriter;
import com.viaversion.viabackwards.protocol.v1_19to1_18_2.Protocol1_19To1_18_2;
import com.viaversion.viaversion.api.type.Types;

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.v1_19to1_18_2.storage;
import com.viaversion.viabackwards.protocol.v1_19to1_18_2.Protocol1_19To1_18_2;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;

View File

@ -410,10 +410,10 @@ public final class Protocol1_20_3To1_20_2 extends BackwardsProtocol<ClientboundP
@Override
protected PacketTypesProvider<ClientboundPacket1_20_3, ClientboundPacket1_20_2, ServerboundPacket1_20_3, ServerboundPacket1_20_2> createPacketTypesProvider() {
return new SimplePacketTypesProvider<>(
packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_20_3.class, ClientboundConfigurationPackets1_20_3.class),
packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_20_2.class, ClientboundConfigurationPackets1_20_2.class),
packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_20_3.class, ServerboundConfigurationPackets1_20_2.class),
packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_20_2.class, ServerboundConfigurationPackets1_20_2.class)
packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_20_3.class, ClientboundConfigurationPackets1_20_3.class),
packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_20_2.class, ClientboundConfigurationPackets1_20_2.class),
packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_20_3.class, ServerboundConfigurationPackets1_20_2.class),
packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_20_2.class, ServerboundConfigurationPackets1_20_2.class)
);
}
}

View File

@ -82,7 +82,7 @@ public final class BlockItemPacketRewriter1_20_3 extends BackwardsItemRewriter<C
} else if (positionSourceType == 1) {
wrapper.write(Types.STRING, "minecraft:entity");
} else {
ViaBackwards.getPlatform().getLogger().warning("Unknown position source type: " + positionSourceType);
protocol.getLogger().warning("Unknown position source type: " + positionSourceType);
wrapper.cancel();
}
}

View File

@ -17,14 +17,13 @@
*/
package com.viaversion.viabackwards.protocol.v1_9_3to1_9_1;
import com.viaversion.viabackwards.protocol.v1_9_3to1_9_1.chunks.BlockEntity;
import com.viaversion.viabackwards.protocol.v1_9_3to1_9_1.data.BlockEntity1_9_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_1;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
@ -77,7 +76,7 @@ public class Protocol1_9_3To1_9_1 extends AbstractProtocol<ClientboundPackets1_9
Chunk chunk = wrapper.read(newType);
wrapper.write(oldType, chunk);
BlockEntity.handle(chunk.getBlockEntities(), wrapper.user());
BlockEntity1_9_1.handle(chunk.getBlockEntities(), wrapper.user());
});
registerClientbound(ClientboundPackets1_9_3.LOGIN, new PacketHandlers() {

View File

@ -15,12 +15,12 @@
* 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.v1_9_3to1_9_1.chunks;
package com.viaversion.viabackwards.protocol.v1_9_3to1_9_1.data;
import com.viaversion.viabackwards.protocol.v1_9_3to1_9_1.Protocol1_9_3To1_9_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
import com.viaversion.nbt.tag.CompoundTag;
@ -29,7 +29,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class BlockEntity {
public class BlockEntity1_9_1 {
private static final Map<String, Integer> TYPES = new HashMap<>();
static {

View File

@ -97,12 +97,12 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
});*/
registerMetaTypeHandler1_20_3(
Types1_20_5.META_TYPES.itemType,
Types1_20_5.META_TYPES.blockStateType,
Types1_20_5.META_TYPES.optionalBlockStateType,
Types1_20_5.META_TYPES.particleType,
Types1_20_5.META_TYPES.itemType,
Types1_20_5.META_TYPES.blockStateType,
Types1_20_5.META_TYPES.optionalBlockStateType,
Types1_20_5.META_TYPES.particleType,
null, Types1_20_5.META_TYPES.componentType,
Types1_20_5.META_TYPES.optionalComponentType
Types1_20_5.META_TYPES.optionalComponentType
);
filter().type(EntityTypes1_20_5.ABSTRACT_MINECART).index(11).handler((event, meta) -> {

View File

@ -37,8 +37,8 @@ if (!isRelease || isMainBranch) { // Only publish releases from the main branch
modrinth {
// val snapshotVersion = rootProject.parseMinecraftSnapshotVersion(project.version as String)
val mcVersions: List<String> = (property("mcVersions") as String)
.split(",")
.map { it.trim() }
.split(",")
.map { it.trim() }
//.let { if (snapshotVersion != null) it + snapshotVersion else it } // We're usually too fast for modrinth
token.set(System.getenv("MODRINTH_TOKEN"))

View File

@ -34,11 +34,11 @@ import java.nio.file.Path;
import java.util.logging.Logger;
@Plugin(id = "viabackwards",
name = "ViaBackwards",
version = VersionInfo.VERSION,
authors = {"Matsv", "kennytv", "Gerrygames", "creeper123123321", "ForceUpdate1", "EnZaXD"},
description = "Allows older Minecraft client versions to connect to newer server versions.",
dependencies = {@Dependency(id = "viaversion")}
name = "ViaBackwards",
version = VersionInfo.VERSION,
authors = {"Matsv", "kennytv", "Gerrygames", "creeper123123321", "ForceUpdate1", "EnZaXD"},
description = "Allows older Minecraft client versions to connect to newer server versions.",
dependencies = {@Dependency(id = "viaversion")}
)
public class VelocityPlugin implements ViaBackwardsPlatform {
private Logger logger;