More work on the inv provider

This commit is contained in:
mmxw11 2017-09-24 22:11:54 +03:00
parent 343e316e4c
commit b2669129f2
3 changed files with 23 additions and 4 deletions

View File

@ -6,8 +6,10 @@ import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.providers.InvContainer
public class BukkitInvContainerItemProvider extends InvContainerItemProvider {
@Override
public boolean registerInvClickPacket(int windowId, short slotId, byte button, short amumber, int mode, UserConnection uconnection) {
public boolean registerInvClickPacket(short windowId, short slotId, short anumber, UserConnection uconnection) {
// TODO: lets add some stuff here :)
return true;
//http://wiki.vg/index.php?title=Protocol&oldid=13223#Click_Window
System.out.println("QUICK ACTION windowId: " + windowId + " slotId: " + slotId + " button: " + 0 + " anumber: " + anumber + " mode: " + 1);
return false; // change to true once supported
}
}

View File

@ -1,6 +1,7 @@
package us.myles.ViaVersion.protocols.protocol1_12to1_11_1.packets;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
@ -8,6 +9,7 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.BedRewriter;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.providers.InvContainerItemProvider;
public class InventoryPackets {
public static void register(Protocol1_12To1_11_1 protocol) {
@ -118,8 +120,23 @@ public class InventoryPackets {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
byte button = wrapper.get(Type.BYTE, 0);
int mode = wrapper.get(Type.VAR_INT, 0);
Item item = wrapper.get(Type.ITEM, 0);
BedRewriter.toServerItem(item);
// QUICK_MOVE PATCH (Shift + (click/double click))
if (mode == 1 && button == 0 && item == null) {
short windowId = wrapper.get(Type.UNSIGNED_BYTE, 0);
short slotId = wrapper.get(Type.SHORT, 0);
short anumber = wrapper.get(Type.SHORT, 1);
InvContainerItemProvider provider = Via.getManager().getProviders().get(InvContainerItemProvider.class);
boolean succeed = provider.registerInvClickPacket(windowId, slotId, anumber, wrapper.user());
if (succeed) {
wrapper.cancel();
}
// otherwise just pass through so the server sends the PacketPlayOutTransaction packet.
} else {
BedRewriter.toServerItem(item);
}
}
});
}

View File

@ -5,7 +5,7 @@ import us.myles.ViaVersion.api.platform.providers.Provider;
public class InvContainerItemProvider implements Provider {
public boolean registerInvClickPacket(int windowId, short slotId, byte button, short amumber, int mode, UserConnection uconnection) {
public boolean registerInvClickPacket(short windowId, short slotId, short anumber, UserConnection uconnection) {
return false; // not supported :/ plays very sad violin
}
}