3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 00:00:33 +01:00

Rename Position

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-05-21 13:12:18 +02:00
Ursprung d7f550fc4f
Commit 0618037a0e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
18 geänderte Dateien mit 61 neuen und 62 gelöschten Zeilen

Datei anzeigen

@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter;
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13;
import com.viaversion.viaversion.api.minecraft.BlockFace;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types;
@ -59,7 +59,7 @@ public class WorldPacketRewriter1_13_1 {
} else if (id == 2000) { // Smoke
switch (data) { // Down
case 0, 1 -> { // Up
Position pos = wrapper.get(Types.BLOCK_POSITION1_8, 0);
BlockPosition pos = wrapper.get(Types.BLOCK_POSITION1_8, 0);
BlockFace relative = data == 0 ? BlockFace.BOTTOM : BlockFace.TOP;
wrapper.set(Types.BLOCK_POSITION1_8, 0, pos.getRelative(relative)); // Y Offset
wrapper.set(Types.INT, 1, 4); // Self

Datei anzeigen

@ -26,7 +26,7 @@ import com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers.
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers.SpawnerHandler;
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.storage.BackwardsBlockStorage;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.api.platform.providers.Provider;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.StringTag;
@ -62,7 +62,7 @@ public class BackwardsBlockEntityProvider implements Provider {
* @param position The position of the block entity
* @param tag The block entity tag
*/
public CompoundTag transform(UserConnection user, Position position, CompoundTag tag) {
public CompoundTag transform(UserConnection user, BlockPosition position, CompoundTag tag) {
final StringTag idTag = tag.getStringTag("id");
if (idTag == null) {
return tag;
@ -90,7 +90,7 @@ public class BackwardsBlockEntityProvider implements Provider {
* @param position The position of the block entity
* @param id The block entity id
*/
public CompoundTag transform(UserConnection user, Position position, String id) {
public CompoundTag transform(UserConnection user, BlockPosition position, String id) {
CompoundTag tag = new CompoundTag();
tag.putString("id", id);
tag.putInt("x", Math.toIntExact(position.x()));

Datei anzeigen

@ -31,7 +31,7 @@ import com.viaversion.viaversion.api.Via;
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.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
@ -142,7 +142,7 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
if (blockId == 25) { // Note block
final NoteBlockStorage noteBlockStorage = wrapper.user().get(NoteBlockStorage.class);
final Position position = wrapper.get(Types.BLOCK_POSITION1_8, 0);
final BlockPosition position = wrapper.get(Types.BLOCK_POSITION1_8, 0);
final Pair<Integer, Integer> update = noteBlockStorage.getNoteBlockUpdate(position);
if (update != null) { // Use values from block state update
wrapper.set(Types.UNSIGNED_BYTE, 0, update.key().shortValue());
@ -187,7 +187,7 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
int chunkMaxZ = chunkMinZ + 15;
BackwardsBlockStorage blockStorage = wrapper.user().get(BackwardsBlockStorage.class);
blockStorage.getBlocks().entrySet().removeIf(entry -> {
Position position = entry.getKey();
BlockPosition position = entry.getKey();
return position.x() >= chunkMinX && position.z() >= chunkMinZ
&& position.x() <= chunkMaxX && position.z() <= chunkMaxZ;
});
@ -201,7 +201,7 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
handler(wrapper -> {
int blockState = wrapper.read(Types.VAR_INT);
Position position = wrapper.get(Types.BLOCK_POSITION1_8, 0);
BlockPosition position = wrapper.get(Types.BLOCK_POSITION1_8, 0);
// Note block special treatment
if (blockState >= 249 && blockState <= 748) { // Note block states id range
@ -234,7 +234,7 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
int chunkX = wrapper.get(Types.INT, 0);
int chunkZ = wrapper.get(Types.INT, 1);
int block = record.getBlockId();
Position position = new Position(
BlockPosition position = new BlockPosition(
record.getSectionX() + (chunkX * 16),
record.getY(),
record.getSectionZ() + (chunkZ * 16));
@ -306,9 +306,9 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
ChunkSection section = chunk.getSections()[sectionIndex];
int x = tag.getNumberTag("x").asInt();
int y = tag.getNumberTag("y").asInt();
short y = tag.getNumberTag("y").asShort();
int z = tag.getNumberTag("z").asInt();
Position position = new Position(x, (short) y, z);
BlockPosition position = new BlockPosition(x, y, z);
int block = section.palette(PaletteType.BLOCKS).idAt(x & 0xF, y & 0xF, z & 0xF);
storage.checkAndStore(position, block);
@ -332,7 +332,7 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
// Check if the block is a flower
if (FlowerPotHandler.isFlowah(block)) {
Position pos = new Position(
BlockPosition pos = new BlockPosition(
(x + (chunk.getX() << 4)),
(short) (y + (i << 4)),
(z + (chunk.getZ() << 4))
@ -964,7 +964,7 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
}
// TODO find a less hacky way to do this (https://bugs.mojang.com/browse/MC-74231)
private static void flowerPotSpecialTreatment(UserConnection user, int blockState, Position position) {
private static void flowerPotSpecialTreatment(UserConnection user, int blockState, BlockPosition position) {
if (FlowerPotHandler.isFlowah(blockState)) {
BackwardsBlockEntityProvider beProvider = Via.getManager().getProviders().get(BackwardsBlockEntityProvider.class);

Datei anzeigen

@ -24,7 +24,7 @@ import com.viaversion.viabackwards.protocol.v1_13to1_12_2.data.ParticleIdMapping
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.storage.TabCompleteStorage;
import com.viaversion.viabackwards.utils.ChatUtil;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.State;
@ -411,7 +411,7 @@ public class PlayerPacketRewriter1_13 extends RewriterBase<Protocol1_13To1_12_2>
int y = wrapper.read(Types.INT);
int z = wrapper.read(Types.INT);
wrapper.write(Types.BLOCK_POSITION1_8, new Position(x, (short) y, z));
wrapper.write(Types.BLOCK_POSITION1_8, new BlockPosition(x, (short) y, z));
wrapper.passthrough(Types.STRING); //Command
@ -433,7 +433,7 @@ public class PlayerPacketRewriter1_13 extends RewriterBase<Protocol1_13To1_12_2>
int x = wrapper.read(Types.INT);
int y = wrapper.read(Types.INT);
int z = wrapper.read(Types.INT);
wrapper.write(Types.BLOCK_POSITION1_8, new Position(x, (short) y, z));
wrapper.write(Types.BLOCK_POSITION1_8, new BlockPosition(x, (short) y, z));
wrapper.write(Types.VAR_INT, wrapper.read(Types.BYTE) - 1);
String mode = wrapper.read(Types.STRING);
int modeId = mode.equals("SAVE") ? 0 : mode.equals("LOAD") ? 1 : mode.equals("CORNER") ? 2 : 3;

Datei anzeigen

@ -19,7 +19,7 @@
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.libs.fastutil.ints.IntOpenHashSet;
import com.viaversion.viaversion.libs.fastutil.ints.IntSet;
import java.util.Map;
@ -66,9 +66,9 @@ public class BackwardsBlockStorage implements StorableObject {
}
}
private final Map<Position, Integer> blocks = new ConcurrentHashMap<>();
private final Map<BlockPosition, Integer> blocks = new ConcurrentHashMap<>();
public void checkAndStore(Position position, int block) {
public void checkAndStore(BlockPosition position, int block) {
if (!WHITELIST.contains(block)) {
// Remove if not whitelisted
blocks.remove(position);
@ -78,11 +78,11 @@ public class BackwardsBlockStorage implements StorableObject {
blocks.put(position, block);
}
public @Nullable Integer get(Position position) {
public @Nullable Integer get(BlockPosition position) {
return blocks.get(position);
}
public int remove(Position position) {
public int remove(BlockPosition position) {
return blocks.remove(position);
}
@ -90,7 +90,7 @@ public class BackwardsBlockStorage implements StorableObject {
blocks.clear();
}
public Map<Position, Integer> getBlocks() {
public Map<BlockPosition, Integer> getBlocks() {
return blocks;
}
}

Datei anzeigen

@ -18,7 +18,7 @@
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
import com.viaversion.viaversion.util.Pair;
@ -27,13 +27,13 @@ public class NoteBlockStorage implements StorableObject {
private static final int MAX_NOTE_ID = 24;
private final Object2IntMap<Position> noteBlockUpdates = new Object2IntOpenHashMap<>();
private final Object2IntMap<BlockPosition> noteBlockUpdates = new Object2IntOpenHashMap<>();
public void storeNoteBlockUpdate(final Position position, final int blockStateId) {
public void storeNoteBlockUpdate(final BlockPosition position, final int blockStateId) {
noteBlockUpdates.put(position, blockStateId);
}
public Pair<Integer, Integer> getNoteBlockUpdate(final Position position) {
public Pair<Integer, Integer> getNoteBlockUpdate(final BlockPosition position) {
if (!noteBlockUpdates.containsKey(position)) {
return null;
}

Datei anzeigen

@ -27,7 +27,7 @@ import com.viaversion.viabackwards.protocol.v1_14to1_13_2.storage.EntityPosition
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.api.minecraft.VillagerData;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
@ -57,7 +57,7 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
// Cache the position for every newly tracked entity
if (type == EntityTypes1_14.PAINTING) {
final Position position = wrapper.get(Types.BLOCK_POSITION1_8, 0);
final BlockPosition position = wrapper.get(Types.BLOCK_POSITION1_8, 0);
positionHandler.cacheEntityPosition(wrapper, position.x(), position.y(), position.z(), true, false);
} else if (wrapper.getId() != ClientboundPackets1_14.LOGIN.getId()) { // ignore join game
positionHandler.cacheEntityPosition(wrapper, true, false);
@ -411,7 +411,7 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
filter().type(EntityTypes1_14.LIVING_ENTITY).handler((event, meta) -> {
int index = event.index();
if (index == 12) {
Position position = (Position) meta.getValue();
BlockPosition position = (BlockPosition) meta.getValue();
if (position != null) {
// Use bed
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_13.PLAYER_SLEEP, null, event.user());

Datei anzeigen

@ -19,7 +19,7 @@ package com.viaversion.viabackwards.protocol.v1_14to1_13_2.rewriter;
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.Protocol1_14To1_13_2;
import com.viaversion.viabackwards.protocol.v1_14to1_13_2.storage.DifficultyStorage;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.rewriter.RewriterBase;
import com.viaversion.viaversion.api.type.Types;
@ -111,7 +111,7 @@ public class PlayerPacketRewriter1_14 extends RewriterBase<Protocol1_14To1_13_2>
});
protocol.registerServerbound(ServerboundPackets1_13.USE_ITEM_ON, wrapper -> {
Position position = wrapper.read(Types.BLOCK_POSITION1_8);
BlockPosition position = wrapper.read(Types.BLOCK_POSITION1_8);
int face = wrapper.read(Types.VAR_INT);
int hand = wrapper.read(Types.VAR_INT);
float x = wrapper.read(Types.FLOAT);

Datei anzeigen

@ -22,7 +22,7 @@ import com.viaversion.viabackwards.protocol.v1_18to1_17_1.Protocol1_18To1_17_1;
import com.viaversion.viabackwards.protocol.v1_18to1_17_1.data.BlockEntityMappings1_17_1;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
@ -147,7 +147,7 @@ public final class BlockItemPacketRewriter1_18 extends BackwardsItemRewriter<Cli
// If those were the only fields on the block entity (e.g.: skull, bed), we'll receive a null NBT
// We initialize one and add the missing fields, so it can be handled correctly down the line
final CompoundTag newTag = tag == null ? new CompoundTag() : tag;
final Position pos = wrapper.get(Types.BLOCK_POSITION1_14, 0);
final BlockPosition pos = wrapper.get(Types.BLOCK_POSITION1_14, 0);
// The protocol converters downstream rely on this field, let's add it back
newTag.putString("id", Key.namespaced(identifier));

Datei anzeigen

@ -24,7 +24,7 @@ import com.viaversion.viabackwards.protocol.v1_19to1_18_2.storage.StoredPainting
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
@ -87,7 +87,7 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter<ClientboundPa
// The entity has been tracked, now we wait for the metadata packet
final int entityId = wrapper.get(Types.VAR_INT, 0);
final StoredEntityData entityData = tracker(wrapper.user()).entityData(entityId);
final Position position = new Position(wrapper.get(Types.DOUBLE, 0).intValue(), wrapper.get(Types.DOUBLE, 1).intValue(), wrapper.get(Types.DOUBLE, 2).intValue());
final BlockPosition position = new BlockPosition(wrapper.get(Types.DOUBLE, 0).intValue(), wrapper.get(Types.DOUBLE, 1).intValue(), wrapper.get(Types.DOUBLE, 2).intValue());
entityData.put(new StoredPainting(entityId, wrapper.get(Types.UUID, 0), position, data));
return;
}

Datei anzeigen

@ -18,17 +18,17 @@
package com.viaversion.viabackwards.protocol.v1_19to1_18_2.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import java.util.UUID;
public final class StoredPainting implements StorableObject {
private final int entityId;
private final UUID uuid;
private final Position position;
private final BlockPosition position;
private final byte direction;
public StoredPainting(final int entityId, final UUID uuid, final Position position, final int direction3d) {
public StoredPainting(final int entityId, final UUID uuid, final BlockPosition position, final int direction3d) {
this.entityId = entityId;
this.uuid = uuid;
this.position = position;
@ -43,7 +43,7 @@ public final class StoredPainting implements StorableObject {
return uuid;
}
public Position position() {
public BlockPosition position() {
return position;
}

Datei anzeigen

@ -20,12 +20,11 @@ package com.viaversion.viabackwards.protocol.v1_20_2to1_20.rewriter;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.v1_20_2to1_20.Protocol1_20_2To1_20;
import com.viaversion.viabackwards.protocol.v1_20_2to1_20.storage.ConfigurationPacketStorage;
import com.viaversion.viaversion.api.minecraft.GlobalPosition;
import com.viaversion.viaversion.api.minecraft.GlobalBlockPosition;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
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_20;
import com.viaversion.viaversion.api.type.types.version.Types1_20_2;
@ -168,7 +167,7 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
wrapper.passthrough(Types.BOOLEAN); // Debug
wrapper.passthrough(Types.BOOLEAN); // Flat
final GlobalPosition lastDeathPosition = wrapper.read(Types.OPTIONAL_GLOBAL_POSITION);
final GlobalBlockPosition lastDeathPosition = wrapper.read(Types.OPTIONAL_GLOBAL_POSITION);
final int portalCooldown = wrapper.read(Types.VAR_INT);
wrapper.passthrough(Types.BYTE); // Data to keep

Datei anzeigen

@ -26,7 +26,7 @@ import com.viaversion.viabackwards.protocol.v1_20_3to1_20_2.rewriter.EntityPacke
import com.viaversion.viabackwards.protocol.v1_20_3to1_20_2.storage.ResourcepackIDStorage;
import com.viaversion.viabackwards.protocol.v1_20_3to1_20_2.storage.SpawnPositionStorage;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_3;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
@ -315,7 +315,7 @@ public final class Protocol1_20_3To1_20_2 extends BackwardsProtocol<ClientboundP
}
});
registerClientbound(ClientboundPackets1_20_3.SET_DEFAULT_SPAWN_POSITION, wrapper -> {
final Position position = wrapper.passthrough(Types.BLOCK_POSITION1_14);
final BlockPosition position = wrapper.passthrough(Types.BLOCK_POSITION1_14);
final float angle = wrapper.passthrough(Types.FLOAT);
wrapper.user().get(SpawnPositionStorage.class).setSpawnPosition(Pair.of(position, angle));
@ -325,7 +325,7 @@ public final class Protocol1_20_3To1_20_2 extends BackwardsProtocol<ClientboundP
if (reason == 13) { // Level chunks load start
wrapper.cancel();
final Pair<Position, Float> spawnPositionAndAngle = wrapper.user().get(SpawnPositionStorage.class).getSpawnPosition();
final Pair<BlockPosition, Float> spawnPositionAndAngle = wrapper.user().get(SpawnPositionStorage.class).getSpawnPosition();
// To emulate the old behavior, we send a fake spawn pos packet containing the actual spawn pos which forces
// the 1.20.2 client to close the downloading terrain screen like the new game state does

Datei anzeigen

@ -18,21 +18,21 @@
package com.viaversion.viabackwards.protocol.v1_20_3to1_20_2.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.libs.fastutil.Pair;
import java.util.Objects;
public class SpawnPositionStorage implements StorableObject {
public static final Pair<Position, Float> DEFAULT_SPAWN_POSITION = Pair.of(new Position(8, 64, 8), 0.0F); // Default values copied from the original client
public static final Pair<BlockPosition, Float> DEFAULT_SPAWN_POSITION = Pair.of(new BlockPosition(8, 64, 8), 0.0F); // Default values copied from the original client
private Pair<Position, Float> spawnPosition;
private Pair<BlockPosition, Float> spawnPosition;
private String dimension;
public Pair<Position, Float> getSpawnPosition() {
public Pair<BlockPosition, Float> getSpawnPosition() {
return spawnPosition;
}
public void setSpawnPosition(final Pair<Position, Float> spawnPosition) {
public void setSpawnPosition(final Pair<BlockPosition, Float> spawnPosition) {
this.spawnPosition = spawnPosition;
}

Datei anzeigen

@ -22,7 +22,7 @@ import com.viaversion.viabackwards.protocol.v1_20to1_19_4.Protocol1_20To1_19_4;
import com.viaversion.viabackwards.protocol.v1_20to1_19_4.storage.BackSignEditStorage;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -130,7 +130,7 @@ public final class BlockItemPacketRewriter1_20 extends BackwardsItemRewriter<Cli
});
protocol.registerClientbound(ClientboundPackets1_19_4.OPEN_SIGN_EDITOR, wrapper -> {
final Position position = wrapper.passthrough(Types.BLOCK_POSITION1_14);
final BlockPosition position = wrapper.passthrough(Types.BLOCK_POSITION1_14);
final boolean frontSide = wrapper.read(Types.BOOLEAN);
if (frontSide) {
wrapper.user().remove(BackSignEditStorage.class);
@ -139,7 +139,7 @@ public final class BlockItemPacketRewriter1_20 extends BackwardsItemRewriter<Cli
}
});
protocol.registerServerbound(ServerboundPackets1_19_4.SIGN_UPDATE, wrapper -> {
final Position position = wrapper.passthrough(Types.BLOCK_POSITION1_14);
final BlockPosition position = wrapper.passthrough(Types.BLOCK_POSITION1_14);
final BackSignEditStorage backSignEditStorage = wrapper.user().remove(BackSignEditStorage.class);
final boolean frontSide = backSignEditStorage == null || !backSignEditStorage.position().equals(position);
wrapper.write(Types.BOOLEAN, frontSide);

Datei anzeigen

@ -18,7 +18,7 @@
package com.viaversion.viabackwards.protocol.v1_20to1_19_4.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.BlockPosition;
public record BackSignEditStorage(Position position) implements StorableObject {
public record BackSignEditStorage(BlockPosition position) implements StorableObject {
}

Datei anzeigen

@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.v1_9_3to1_9_1;
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.BlockPosition;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -50,7 +50,7 @@ public class Protocol1_9_3To1_9_1 extends AbstractProtocol<ClientboundPackets1_9
map(Types.NAMED_COMPOUND_TAG); //NBT
handler(wrapper -> {
if (wrapper.get(Types.UNSIGNED_BYTE, 0) == 9) {
Position position = wrapper.get(Types.BLOCK_POSITION1_8, 0);
BlockPosition position = wrapper.get(Types.BLOCK_POSITION1_8, 0);
CompoundTag tag = wrapper.get(Types.NAMED_COMPOUND_TAG, 0);
wrapper.clearPacket(); //Clear the packet

Datei anzeigen

@ -19,7 +19,7 @@ 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.minecraft.BlockPosition;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
@ -62,16 +62,16 @@ public class BlockEntity1_9_1 {
}
int x = tag.getNumberTag("x").asInt();
int y = tag.getNumberTag("y").asInt();
short y = tag.getNumberTag("y").asShort();
int z = tag.getNumberTag("z").asInt();
Position pos = new Position(x, (short) y, z);
BlockPosition pos = new BlockPosition(x, y, z);
updateBlockEntity(pos, (short) newId, tag, connection);
}
}
private static void updateBlockEntity(Position pos, short id, CompoundTag tag, UserConnection connection) {
private static void updateBlockEntity(BlockPosition pos, short id, CompoundTag tag, UserConnection connection) {
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, null, connection);
wrapper.write(Types.BLOCK_POSITION1_8, pos);
wrapper.write(Types.UNSIGNED_BYTE, id);