3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20:24 +01:00
Dieser Commit ist enthalten in:
Nassim Jahnke 2023-08-10 13:35:47 +10:00
Ursprung d954e1745d
Commit c5e066e050
6 geänderte Dateien mit 127 neuen und 87 gelöschten Zeilen

Datei anzeigen

@ -84,7 +84,7 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_19_3 = register(761, "1.19.3");
public static final ProtocolVersion v1_19_4 = register(762, "1.19.4");
public static final ProtocolVersion v1_20 = register(763, "1.20/1.20.1", new VersionRange("1.20", 0, 1));
public static final ProtocolVersion v1_20_2 = register(764, 144, "1.20.2");
public static final ProtocolVersion v1_20_2 = register(764, 145, "1.20.2");
public static final ProtocolVersion unknown = register(-1, "UNKNOWN");
public static ProtocolVersion register(int version, String name) {

Datei anzeigen

@ -109,6 +109,15 @@ public final class Protocol1_20_2To1_20 extends AbstractProtocol<ClientboundPack
cancelClientbound(ClientboundPackets1_19_4.UPDATE_ENABLED_FEATURES); // TODO Sad emoji
cancelServerbound(ServerboundPackets1_20_2.CONFIGURATION_ACKNOWLEDGED);
cancelServerbound(ServerboundPackets1_20_2.CHUNK_BATCH_RECEIVED);
registerServerbound(ServerboundPackets1_20_2.PING_REQUEST, null, wrapper -> {
wrapper.cancel();
final long time = wrapper.read(Type.LONG);
final PacketWrapper responsePacket = wrapper.create(ClientboundPackets1_20_2.PONG_RESPONSE);
responsePacket.write(Type.LONG, time);
responsePacket.sendFuture(Protocol1_20_2To1_20.class);
});
}
private PacketHandler queueServerboundPacket(final ServerboundPackets1_20_2 packetType) {

Datei anzeigen

@ -74,66 +74,67 @@ public enum ClientboundPackets1_20_2 implements ClientboundPacketType {
OPEN_WINDOW, // 0x32
OPEN_SIGN_EDITOR, // 0x33
PING, // 0x34
CRAFT_RECIPE_RESPONSE, // 0x35
PLAYER_ABILITIES, // 0x36
PLAYER_CHAT, // 0x37
COMBAT_END, // 0x38
COMBAT_ENTER, // 0x39
COMBAT_KILL, // 0x3A
PLAYER_INFO_REMOVE, // 0x3B
PLAYER_INFO_UPDATE, // 0x3C
FACE_PLAYER, // 0x3D
PLAYER_POSITION, // 0x3E
UNLOCK_RECIPES, // 0x3F
REMOVE_ENTITIES, // 0x40
REMOVE_ENTITY_EFFECT, // 0x41
RESOURCE_PACK, // 0x42
RESPAWN, // 0x43
ENTITY_HEAD_LOOK, // 0x44
MULTI_BLOCK_CHANGE, // 0x45
SELECT_ADVANCEMENTS_TAB, // 0x46
SERVER_DATA, // 0x47
ACTIONBAR, // 0x48
WORLD_BORDER_CENTER, // 0x49
WORLD_BORDER_LERP_SIZE, // 0x4A
WORLD_BORDER_SIZE, // 0x4B
WORLD_BORDER_WARNING_DELAY, // 0x4C
WORLD_BORDER_WARNING_DISTANCE, // 0x4D
CAMERA, // 0x4E
HELD_ITEM_CHANGE, // 0x4F
UPDATE_VIEW_POSITION, // 0x50
UPDATE_VIEW_DISTANCE, // 0x51
SPAWN_POSITION, // 0x52
DISPLAY_SCOREBOARD, // 0x53
ENTITY_METADATA, // 0x54
ATTACH_ENTITY, // 0x55
ENTITY_VELOCITY, // 0x56
ENTITY_EQUIPMENT, // 0x57
SET_EXPERIENCE, // 0x58
UPDATE_HEALTH, // 0x59
SCOREBOARD_OBJECTIVE, // 0x5A
SET_PASSENGERS, // 0x5B
TEAMS, // 0x5C
UPDATE_SCORE, // 0x5D
SET_SIMULATION_DISTANCE, // 0x5E
TITLE_SUBTITLE, // 0x5F
TIME_UPDATE, // 0x60
TITLE_TEXT, // 0x61
TITLE_TIMES, // 0x62
ENTITY_SOUND, // 0x63
SOUND, // 0x64
START_CONFIGURATION, // 0x65
STOP_SOUND, // 0x66
SYSTEM_CHAT, // 0x67
TAB_LIST, // 0x68
NBT_QUERY, // 0x69
COLLECT_ITEM, // 0x6A
ENTITY_TELEPORT, // 0x6B
ADVANCEMENTS, // 0x6C
ENTITY_PROPERTIES, // 0x6D
ENTITY_EFFECT, // 0x6E
DECLARE_RECIPES, // 0x6F
TAGS; // 0x70
PONG_RESPONSE, // 0x35
CRAFT_RECIPE_RESPONSE, // 0x36
PLAYER_ABILITIES, // 0x37
PLAYER_CHAT, // 0x38
COMBAT_END, // 0x39
COMBAT_ENTER, // 0x3A
COMBAT_KILL, // 0x3B
PLAYER_INFO_REMOVE, // 0x3C
PLAYER_INFO_UPDATE, // 0x3D
FACE_PLAYER, // 0x3E
PLAYER_POSITION, // 0x3F
UNLOCK_RECIPES, // 0x40
REMOVE_ENTITIES, // 0x41
REMOVE_ENTITY_EFFECT, // 0x42
RESOURCE_PACK, // 0x43
RESPAWN, // 0x44
ENTITY_HEAD_LOOK, // 0x45
MULTI_BLOCK_CHANGE, // 0x46
SELECT_ADVANCEMENTS_TAB, // 0x47
SERVER_DATA, // 0x48
ACTIONBAR, // 0x49
WORLD_BORDER_CENTER, // 0x4A
WORLD_BORDER_LERP_SIZE, // 0x4B
WORLD_BORDER_SIZE, // 0x4C
WORLD_BORDER_WARNING_DELAY, // 0x4D
WORLD_BORDER_WARNING_DISTANCE, // 0x4E
CAMERA, // 0x4F
HELD_ITEM_CHANGE, // 0x50
UPDATE_VIEW_POSITION, // 0x51
UPDATE_VIEW_DISTANCE, // 0x52
SPAWN_POSITION, // 0x53
DISPLAY_SCOREBOARD, // 0x54
ENTITY_METADATA, // 0x55
ATTACH_ENTITY, // 0x56
ENTITY_VELOCITY, // 0x57
ENTITY_EQUIPMENT, // 0x58
SET_EXPERIENCE, // 0x59
UPDATE_HEALTH, // 0x5A
SCOREBOARD_OBJECTIVE, // 0x5B
SET_PASSENGERS, // 0x5C
TEAMS, // 0x5D
UPDATE_SCORE, // 0x5E
SET_SIMULATION_DISTANCE, // 0x5F
TITLE_SUBTITLE, // 0x60
TIME_UPDATE, // 0x61
TITLE_TEXT, // 0x62
TITLE_TIMES, // 0x63
ENTITY_SOUND, // 0x64
SOUND, // 0x65
START_CONFIGURATION, // 0x66
STOP_SOUND, // 0x67
SYSTEM_CHAT, // 0x68
TAB_LIST, // 0x69
NBT_QUERY, // 0x6A
COLLECT_ITEM, // 0x6B
ENTITY_TELEPORT, // 0x6C
ADVANCEMENTS, // 0x6D
ENTITY_PROPERTIES, // 0x6E
ENTITY_EFFECT, // 0x6F
DECLARE_RECIPES, // 0x70
TAGS; // 0x71
@Override
public int getId() {

Datei anzeigen

@ -50,30 +50,31 @@ public enum ServerboundPackets1_20_2 implements ServerboundPacketType {
VEHICLE_MOVE, // 0x1A
STEER_BOAT, // 0x1B
PICK_ITEM, // 0x1C
CRAFT_RECIPE_REQUEST, // 0x1D
PLAYER_ABILITIES, // 0x1E
PLAYER_DIGGING, // 0x1F
ENTITY_ACTION, // 0x20
STEER_VEHICLE, // 0x21
PONG, // 0x22
RECIPE_BOOK_DATA, // 0x23
SEEN_RECIPE, // 0x24
RENAME_ITEM, // 0x25
RESOURCE_PACK_STATUS, // 0x26
ADVANCEMENT_TAB, // 0x27
SELECT_TRADE, // 0x28
SET_BEACON_EFFECT, // 0x29
HELD_ITEM_CHANGE, // 0x2A
UPDATE_COMMAND_BLOCK, // 0x2B
UPDATE_COMMAND_BLOCK_MINECART, // 0x2C
CREATIVE_INVENTORY_ACTION, // 0x2D
UPDATE_JIGSAW_BLOCK, // 0x2E
UPDATE_STRUCTURE_BLOCK, // 0x2F
UPDATE_SIGN, // 0x30
ANIMATION, // 0x31
SPECTATE, // 0x32
PLAYER_BLOCK_PLACEMENT, // 0x33
USE_ITEM; // 0x34
PING_REQUEST, // 0x1D
CRAFT_RECIPE_REQUEST, // 0x1E
PLAYER_ABILITIES, // 0x1F
PLAYER_DIGGING, // 0x20
ENTITY_ACTION, // 0x21
STEER_VEHICLE, // 0x22
PONG, // 0x23
RECIPE_BOOK_DATA, // 0x24
SEEN_RECIPE, // 0x25
RENAME_ITEM, // 0x26
RESOURCE_PACK_STATUS, // 0x27
ADVANCEMENT_TAB, // 0x28
SELECT_TRADE, // 0x29
SET_BEACON_EFFECT, // 0x2A
HELD_ITEM_CHANGE, // 0x2B
UPDATE_COMMAND_BLOCK, // 0x2C
UPDATE_COMMAND_BLOCK_MINECART, // 0x2D
CREATIVE_INVENTORY_ACTION, // 0x2E
UPDATE_JIGSAW_BLOCK, // 0x2F
UPDATE_STRUCTURE_BLOCK, // 0x30
UPDATE_SIGN, // 0x31
ANIMATION, // 0x32
SPECTATE, // 0x33
PLAYER_BLOCK_PLACEMENT, // 0x34
USE_ITEM; // 0x35
@Override
public int getId() {

Datei anzeigen

@ -17,8 +17,13 @@
*/
package com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.ChunkPosition;
@ -34,6 +39,8 @@ import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.type.ChunkType1_
import com.viaversion.viaversion.protocols.protocol1_20to1_19_4.Protocol1_20To1_19_4;
import com.viaversion.viaversion.rewriter.ItemRewriter;
import com.viaversion.viaversion.util.MathUtil;
import javax.swing.border.CompoundBorder;
import org.checkerframework.checker.nullness.qual.Nullable;
public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<ClientboundPackets1_19_4, ServerboundPackets1_20_2, Protocol1_20_2To1_20> {
@ -57,7 +64,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
protocol.registerClientbound(ClientboundPackets1_19_4.BLOCK_ENTITY_DATA, wrapper -> {
wrapper.passthrough(Type.POSITION1_14); // Position
wrapper.passthrough(Type.VAR_INT); // Type
wrapper.write(Type.NAMELESS_NBT, wrapper.read(Type.NBT));
wrapper.write(Type.NAMELESS_NBT, handleBlockEntity(wrapper.read(Type.NBT)));
});
protocol.registerClientbound(ClientboundPackets1_19_4.CHUNK_DATA, wrapper -> {
@ -71,6 +78,10 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
MathUtil.ceilLog2(Protocol1_20To1_19_4.MAPPINGS.getBlockStateMappings().mappedSize()),
MathUtil.ceilLog2(tracker.biomesSent()));
wrapper.write(newChunkType, chunk);
for (final BlockEntity blockEntity : chunk.blockEntities()) {
handleBlockEntity(blockEntity.tag());
}
});
// Replace the NBT type everywhere
@ -294,4 +305,22 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
}
}.register(ClientboundPackets1_19_4.DECLARE_RECIPES);
}
private @Nullable CompoundTag handleBlockEntity(@Nullable final CompoundTag tag) {
if (tag == null) {
return null;
}
// TODO Weird disconnect when setting effect type in inventory, probably unrelated to this, but needs fixing
final IntTag primaryEffect = tag.remove("Primary");
if (primaryEffect != null) {
tag.put("primary_effect", new StringTag("minecraft:speed")); //TODO
}
final IntTag secondaryEffect = tag.remove("Secondary");
if (secondaryEffect != null) {
tag.put("secondary_effect", new StringTag("minecraft:speed")); //TODO
}
return tag;
}
}

Datei anzeigen

@ -1,5 +1,5 @@
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
projectVersion=4.8.0-23w31a-SNAPSHOT
projectVersion=4.8.0-23w32a-SNAPSHOT
# Gradle properties
org.gradle.daemon=true