mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-10 20:41:14 +01:00
Don't send empty items in 1.8->1.9 hand item provider (#3920)
This commit is contained in:
parent
b77d0fedd9
commit
2fba2c1e65
@ -18,10 +18,8 @@
|
||||
package com.viaversion.viaversion.protocols.v1_8to1_9;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
@ -68,10 +66,6 @@ public class Protocol1_8To1_9 extends AbstractProtocol<ClientboundPackets1_8, Cl
|
||||
super(ClientboundPackets1_8.class, ClientboundPackets1_9.class, ServerboundPackets1_8.class, ServerboundPackets1_9.class);
|
||||
}
|
||||
|
||||
public static Item getHandItem(final UserConnection info) {
|
||||
return Via.getManager().getProviders().get(HandItemProvider.class).getHandItem(info);
|
||||
}
|
||||
|
||||
public static boolean isSword(int id) {
|
||||
return switch (id) {
|
||||
case 267, // Iron sword
|
||||
|
@ -18,12 +18,13 @@
|
||||
package com.viaversion.viaversion.protocols.v1_8to1_9.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.platform.providers.Provider;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class HandItemProvider implements Provider {
|
||||
public Item getHandItem(final UserConnection info) {
|
||||
return new DataItem(0, (byte) 0, (short) 0, null);
|
||||
|
||||
public @Nullable Item getHandItem(final UserConnection connection) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ServerboundPackets1_8;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ServerboundPackets1_9;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.provider.CommandBlockProvider;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.provider.HandItemProvider;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.storage.ClientChunks;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.storage.EntityTracker1_9;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
@ -293,7 +294,7 @@ public class WorldPacketRewriter1_9 {
|
||||
wrapper.write(Types.BLOCK_POSITION1_8, new BlockPosition(-1, -1, -1));
|
||||
wrapper.write(Types.UNSIGNED_BYTE, (short) 255);
|
||||
// Write item in hand
|
||||
Item item = Protocol1_8To1_9.getHandItem(wrapper.user());
|
||||
Item item = Via.getManager().getProviders().get(HandItemProvider.class).getHandItem(wrapper.user());
|
||||
// Blocking patch
|
||||
if (Via.getConfig().isShieldBlocking()) {
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class);
|
||||
@ -350,7 +351,7 @@ public class WorldPacketRewriter1_9 {
|
||||
if (hand != 0) wrapper.cancel();
|
||||
});
|
||||
handler(wrapper -> {
|
||||
Item item = Protocol1_8To1_9.getHandItem(wrapper.user());
|
||||
Item item = Via.getManager().getProviders().get(HandItemProvider.class).getHandItem(wrapper.user());
|
||||
wrapper.write(Types.ITEM1_8, item); // 3 - Item
|
||||
});
|
||||
map(Types.UNSIGNED_BYTE); // 4 - X
|
||||
|
Loading…
Reference in New Issue
Block a user