minecraft-bot/monkey_patch.py

26 lines
1017 B
Python
Raw Normal View History

import minecraft.networking.packets
2020-09-09 02:13:15 +00:00
from protocol import packets
def get_packets(old_get_packets):
def wrapper(func, context):
print('Monkey-patch worked.')
2020-09-09 02:13:15 +00:00
mc_packets = func(context)
# add any custom packets here
2020-09-09 02:13:15 +00:00
mc_packets.add(packets.ChunkDataPacket)
mc_packets.add(packets.AcknowledgePlayerDiggingPacket)
mc_packets.add(packets.BlockBreakAnimationPacket)
mc_packets.add(packets.SetSlotPacket)
mc_packets.add(packets.TimeUpdatePacket)
mc_packets.add(packets.PlayerDiggingPacket)
mc_packets.add(packets.PickItemPacket)
mc_packets.add(packets.HeldItemChangePacket)
mc_packets.add(packets.OpenWindowPacket)
mc_packets.add(packets.CloseWindowPacket)
mc_packets.add(packets.ClickWindowPacket)
2020-09-09 02:13:15 +00:00
return mc_packets
return lambda x: wrapper(old_get_packets, x)
minecraft.networking.packets.clientbound.play.get_packets = get_packets(minecraft.networking.packets.clientbound.play.get_packets)