Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-27 00:22:53 +01:00
Actually track inventory state id
Dieser Commit ist enthalten in:
Ursprung
681e8a2f07
Commit
ff94019b08
@ -23,6 +23,7 @@ import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
|
|||||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||||
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.rewriter.BlockItemPacketRewriter1_21_2;
|
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.rewriter.BlockItemPacketRewriter1_21_2;
|
||||||
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.rewriter.EntityPacketRewriter1_21_2;
|
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.rewriter.EntityPacketRewriter1_21_2;
|
||||||
|
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.storage.InventoryStateIdStorage;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
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.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
@ -108,6 +109,7 @@ public final class Protocol1_21_2To1_21 extends BackwardsProtocol<ClientboundPac
|
|||||||
@Override
|
@Override
|
||||||
public void init(final UserConnection user) {
|
public void init(final UserConnection user) {
|
||||||
addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_20_5.PLAYER));
|
addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_20_5.PLAYER));
|
||||||
|
user.put(new InventoryStateIdStorage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,8 +91,11 @@ public final class BlockItemPacketRewriter1_21_2 extends BackwardsStructuredItem
|
|||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_21_2.CONTAINER_SET_CONTENT, wrapper -> {
|
protocol.registerClientbound(ClientboundPackets1_21_2.CONTAINER_SET_CONTENT, wrapper -> {
|
||||||
updateContainerId(wrapper);
|
updateContainerId(wrapper);
|
||||||
wrapper.passthrough(Types.VAR_INT); // State id
|
|
||||||
Item[] items = wrapper.read(itemArrayType());
|
final int stateId = wrapper.passthrough(Types.VAR_INT);
|
||||||
|
wrapper.user().get(InventoryStateIdStorage.class).setStateId(stateId);
|
||||||
|
|
||||||
|
final Item[] items = wrapper.read(itemArrayType());
|
||||||
wrapper.write(mappedItemArrayType(), items);
|
wrapper.write(mappedItemArrayType(), items);
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
items[i] = handleItemToClient(wrapper.user(), items[i]);
|
items[i] = handleItemToClient(wrapper.user(), items[i]);
|
||||||
@ -101,7 +104,10 @@ public final class BlockItemPacketRewriter1_21_2 extends BackwardsStructuredItem
|
|||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_21_2.CONTAINER_SET_SLOT, wrapper -> {
|
protocol.registerClientbound(ClientboundPackets1_21_2.CONTAINER_SET_SLOT, wrapper -> {
|
||||||
updateContainerId(wrapper);
|
updateContainerId(wrapper);
|
||||||
wrapper.passthrough(Types.VAR_INT); // State id
|
|
||||||
|
final int stateId = wrapper.passthrough(Types.VAR_INT);
|
||||||
|
wrapper.user().get(InventoryStateIdStorage.class).setStateId(stateId);
|
||||||
|
|
||||||
wrapper.passthrough(Types.SHORT); // Slot id
|
wrapper.passthrough(Types.SHORT); // Slot id
|
||||||
passthroughClientboundItem(wrapper);
|
passthroughClientboundItem(wrapper);
|
||||||
});
|
});
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren