Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-25 15:50:12 +01:00
Small cleanup
Dieser Commit ist enthalten in:
Ursprung
927ffaf20a
Commit
8af8319839
@ -71,7 +71,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public interface ViaBackwardsPlatform {
|
public interface ViaBackwardsPlatform {
|
||||||
|
|
||||||
String MINIMUM_VV_VERSION = "5.1.0";
|
String MINIMUM_VV_VERSION = "5.1.1";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize ViaBackwards.
|
* Initialize ViaBackwards.
|
||||||
|
@ -25,7 +25,6 @@ import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
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_14;
|
||||||
|
|
||||||
@ -105,14 +104,11 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerSpawnTracker(C packetType) {
|
public void registerSpawnTracker(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
protocol.registerClientbound(packetType, wrapper -> {
|
||||||
@Override
|
wrapper.passthrough(Types.VAR_INT); // Entity ID
|
||||||
public void register() {
|
wrapper.passthrough(Types.UUID); // Entity UUID
|
||||||
map(Types.VAR_INT); // 0 - Entity ID
|
wrapper.passthrough(Types.VAR_INT); // Entity Type
|
||||||
map(Types.UUID); // 1 - Entity UUID
|
trackAndMapEntity(wrapper);
|
||||||
map(Types.VAR_INT); // 2 - Entity Type
|
|
||||||
handler(wrapper -> trackAndMapEntity(wrapper));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import com.viaversion.viaversion.api.minecraft.SoundEvent;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
|
|
||||||
public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversion.viaversion.rewriter.SoundRewriter<C> {
|
public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversion.viaversion.rewriter.SoundRewriter<C> {
|
||||||
@ -36,22 +35,14 @@ public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversi
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerNamedSound(final C packetType) {
|
public void registerNamedSound(final C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
protocol.registerClientbound(packetType, wrapper -> {
|
||||||
@Override
|
wrapper.passthrough(Types.STRING); // Sound identifier
|
||||||
public void register() {
|
getNamedSoundHandler().handle(wrapper);
|
||||||
map(Types.STRING); // Sound identifier
|
|
||||||
handler(getNamedSoundHandler());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerStopSound(final C packetType) {
|
public void registerStopSound(final C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
protocol.registerClientbound(packetType, wrapper -> getStopSoundHandler().handle(wrapper));
|
||||||
@Override
|
|
||||||
public void register() {
|
|
||||||
handler(getStopSoundHandler());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketHandler getNamedSoundHandler() {
|
public PacketHandler getNamedSoundHandler() {
|
||||||
|
@ -18,16 +18,14 @@
|
|||||||
package com.viaversion.viabackwards.protocol.template;
|
package com.viaversion.viabackwards.protocol.template;
|
||||||
|
|
||||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||||
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
||||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
||||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2;
|
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.rewriter.RegistryDataRewriter;
|
||||||
|
|
||||||
// Replace if needed
|
// Replace if needed
|
||||||
// Types1_OLD
|
// Types1_OLD
|
||||||
@ -44,30 +42,23 @@ final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPacket1_2
|
|||||||
registerSetEntityData(ClientboundPackets1_21_2.SET_ENTITY_DATA, /*Types1_OLD.ENTITY_DATA_LIST, */Types1_20_5.ENTITY_DATA_LIST); // Specify old and new entity data list if changed
|
registerSetEntityData(ClientboundPackets1_21_2.SET_ENTITY_DATA, /*Types1_OLD.ENTITY_DATA_LIST, */Types1_20_5.ENTITY_DATA_LIST); // Specify old and new entity data list if changed
|
||||||
registerRemoveEntities(ClientboundPackets1_21_2.REMOVE_ENTITIES);
|
registerRemoveEntities(ClientboundPackets1_21_2.REMOVE_ENTITIES);
|
||||||
|
|
||||||
// TODO Item and sound id changes in registries, probably others as well
|
final RegistryDataRewriter registryDataRewriter = new RegistryDataRewriter(protocol);
|
||||||
protocol.registerClientbound(ClientboundConfigurationPackets1_21.REGISTRY_DATA, wrapper -> {
|
protocol.registerClientbound(ClientboundConfigurationPackets1_21.REGISTRY_DATA, registryDataRewriter::handle);
|
||||||
final String registryKey = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING));
|
|
||||||
final RegistryEntry[] entries = wrapper.passthrough(Types.REGISTRY_ENTRY_ARRAY);
|
|
||||||
handleRegistryData1_20_5(wrapper.user(), registryKey, entries); // Caches dimensions to access data like height later and tracks the amount of biomes sent for chunk data
|
|
||||||
});
|
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_21_2.LOGIN, new PacketHandlers() {
|
protocol.registerClientbound(ClientboundPackets1_21_2.LOGIN, wrapper -> {
|
||||||
@Override
|
final int entityId = wrapper.passthrough(Types.INT); // Entity id
|
||||||
public void register() {
|
wrapper.passthrough(Types.BOOLEAN); // Hardcore
|
||||||
map(Types.INT); // Entity id
|
wrapper.passthrough(Types.STRING_ARRAY); // World List
|
||||||
map(Types.BOOLEAN); // Hardcore
|
wrapper.passthrough(Types.VAR_INT); // Max players
|
||||||
map(Types.STRING_ARRAY); // World List
|
wrapper.passthrough(Types.VAR_INT); // View distance
|
||||||
map(Types.VAR_INT); // Max players
|
wrapper.passthrough(Types.VAR_INT); // Simulation distance
|
||||||
map(Types.VAR_INT); // View distance
|
wrapper.passthrough(Types.BOOLEAN); // Reduced debug info
|
||||||
map(Types.VAR_INT); // Simulation distance
|
wrapper.passthrough(Types.BOOLEAN); // Show death screen
|
||||||
map(Types.BOOLEAN); // Reduced debug info
|
wrapper.passthrough(Types.BOOLEAN); // Limited crafting
|
||||||
map(Types.BOOLEAN); // Show death screen
|
final int dimensionId = wrapper.passthrough(Types.VAR_INT);
|
||||||
map(Types.BOOLEAN); // Limited crafting
|
final String world = wrapper.passthrough(Types.STRING);
|
||||||
map(Types.VAR_INT); // Dimension key
|
trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world);
|
||||||
map(Types.STRING); // World
|
trackPlayer(wrapper.user(), entityId);
|
||||||
handler(worldDataTrackerHandlerByKey1_20_5(3)); // Tracks world height and name for chunk data and entity (un)tracking
|
|
||||||
handler(playerTrackerHandler());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_21_2.RESPAWN, wrapper -> {
|
protocol.registerClientbound(ClientboundPackets1_21_2.RESPAWN, wrapper -> {
|
||||||
|
@ -40,6 +40,7 @@ import com.viaversion.viaversion.protocols.v1_20_5to1_21.data.Paintings1_20_5;
|
|||||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacket1_21;
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacket1_21;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21;
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21;
|
||||||
|
import com.viaversion.viaversion.rewriter.RegistryDataRewriter;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
import com.viaversion.viaversion.util.KeyMappings;
|
import com.viaversion.viaversion.util.KeyMappings;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -64,6 +65,7 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
|
|||||||
registerSetEntityData(ClientboundPackets1_21.SET_ENTITY_DATA, Types1_21.ENTITY_DATA_LIST, Types1_20_5.ENTITY_DATA_LIST);
|
registerSetEntityData(ClientboundPackets1_21.SET_ENTITY_DATA, Types1_21.ENTITY_DATA_LIST, Types1_20_5.ENTITY_DATA_LIST);
|
||||||
registerRemoveEntities(ClientboundPackets1_21.REMOVE_ENTITIES);
|
registerRemoveEntities(ClientboundPackets1_21.REMOVE_ENTITIES);
|
||||||
|
|
||||||
|
final RegistryDataRewriter registryDataRewriter = new RegistryDataRewriter(protocol);
|
||||||
protocol.registerClientbound(ClientboundConfigurationPackets1_21.REGISTRY_DATA, wrapper -> {
|
protocol.registerClientbound(ClientboundConfigurationPackets1_21.REGISTRY_DATA, wrapper -> {
|
||||||
final String key = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING));
|
final String key = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING));
|
||||||
final RegistryEntry[] entries = wrapper.passthrough(Types.REGISTRY_ENTRY_ARRAY);
|
final RegistryEntry[] entries = wrapper.passthrough(Types.REGISTRY_ENTRY_ARRAY);
|
||||||
@ -99,7 +101,7 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
|
|||||||
|
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
} else {
|
} else {
|
||||||
handleRegistryData1_20_5(wrapper.user(), key, entries);
|
registryDataRewriter.trackDimensionAndBiomes(wrapper.user(), key, entries);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -215,4 +217,4 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
|
|||||||
|
|
||||||
private record PaintingData(PaintingVariant painting, int id) {
|
private record PaintingData(PaintingVariant painting, int id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ metadata.format.version = "1.1"
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
# ViaVersion
|
# ViaVersion
|
||||||
viaver = "5.1.0"
|
viaver = "5.1.1-SNAPSHOT"
|
||||||
|
|
||||||
# Common provided
|
# Common provided
|
||||||
netty = "4.0.20.Final"
|
netty = "4.0.20.Final"
|
||||||
|
@ -4,7 +4,6 @@ rootProject.name = "viabackwards-parent"
|
|||||||
|
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
|
||||||
maven("https://repo.viaversion.com")
|
maven("https://repo.viaversion.com")
|
||||||
maven("https://repo.papermc.io/repository/maven-public/")
|
maven("https://repo.papermc.io/repository/maven-public/")
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren