mirror of
https://github.com/ViaVersion/ViaAprilFools.git
synced 2024-11-15 10:35:12 +01:00
Add UserConnection param to item rewriter methods
This commit is contained in:
parent
a3fa487012
commit
cf0e9c9baf
@ -48,10 +48,10 @@ public class BlockItemPackets3D_Shareware extends ItemRewriter<ClientboundPacket
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
BlockItemPackets3D_Shareware.this.handleItemToClient(wrapper.passthrough(Type.ITEM1_13_2));
|
||||
BlockItemPackets3D_Shareware.this.handleItemToClient(wrapper.passthrough(Type.ITEM1_13_2));
|
||||
BlockItemPackets3D_Shareware.this.handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2));
|
||||
BlockItemPackets3D_Shareware.this.handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2));
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
BlockItemPackets3D_Shareware.this.handleItemToClient(wrapper.passthrough(Type.ITEM1_13_2));
|
||||
BlockItemPackets3D_Shareware.this.handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2));
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package net.raphimc.viaaprilfools.protocols.protocol1_14to3D_Shareware.packets;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
@ -51,7 +52,7 @@ public class EntityPackets3D_Shareware {
|
||||
map(Type.SHORT); // 10 - Velocity Y
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_14.METADATA_LIST); // 12 - Metadata
|
||||
handler(packetWrapper -> handleMetadata(packetWrapper.get(Types1_14.METADATA_LIST, 0)));
|
||||
handler(packetWrapper -> handleMetadata(packetWrapper.user(), packetWrapper.get(Types1_14.METADATA_LIST, 0)));
|
||||
}
|
||||
});
|
||||
this.protocol.registerClientbound(ClientboundPackets3D_Shareware.SPAWN_PLAYER, new PacketHandlers() {
|
||||
@ -65,7 +66,7 @@ public class EntityPackets3D_Shareware {
|
||||
map(Type.BYTE); // 5 - Yaw
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_14.METADATA_LIST); // 7 - Metadata
|
||||
handler(packetWrapper -> handleMetadata(packetWrapper.get(Types1_14.METADATA_LIST, 0)));
|
||||
handler(packetWrapper -> handleMetadata(packetWrapper.user(), packetWrapper.get(Types1_14.METADATA_LIST, 0)));
|
||||
}
|
||||
});
|
||||
this.protocol.registerClientbound(ClientboundPackets3D_Shareware.ENTITY_METADATA, new PacketHandlers() {
|
||||
@ -73,15 +74,15 @@ public class EntityPackets3D_Shareware {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Types1_14.METADATA_LIST);
|
||||
handler(packetWrapper -> handleMetadata(packetWrapper.get(Types1_14.METADATA_LIST, 0)));
|
||||
handler(packetWrapper -> handleMetadata(packetWrapper.user(), packetWrapper.get(Types1_14.METADATA_LIST, 0)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void handleMetadata(final List<Metadata> metadataList) {
|
||||
public void handleMetadata(final UserConnection user, final List<Metadata> metadataList) {
|
||||
for (Metadata metadata : metadataList) {
|
||||
if (metadata.metaType() == Types1_14.META_TYPES.itemType) {
|
||||
metadata.setValue(this.protocol.getItemRewriter().handleItemToClient(metadata.value()));
|
||||
metadata.setValue(this.protocol.getItemRewriter().handleItemToClient(user, metadata.value()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class BlockItemPackets20w14infinite extends ItemRewriter<ClientboundPacke
|
||||
handler(wrapper -> {
|
||||
int slot = wrapper.read(Type.VAR_INT);
|
||||
wrapper.write(Type.BYTE, (byte) slot);
|
||||
handleItemToClient(wrapper.passthrough(Type.ITEM1_13_2));
|
||||
handleItemToClient(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2));
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -122,7 +122,7 @@ public class BlockItemPackets20w14infinite extends ItemRewriter<ClientboundPacke
|
||||
protocol.registerServerbound(ServerboundPackets1_16.EDIT_BOOK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2)));
|
||||
handler(wrapper -> handleItemToServer(wrapper.user(), wrapper.passthrough(Type.ITEM1_13_2)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user