Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 08:10:09 +01:00
More work on the inv provider
Dieser Commit ist enthalten in:
Ursprung
343e316e4c
Commit
b2669129f2
@ -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
|
||||
}
|
||||
}
|
@ -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,9 +120,24 @@ 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);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren