minecraft-bot/mosfet/monkey_patch.py
2021-04-22 00:46:54 +00:00

29 lines
1.1 KiB
Python

import minecraft.networking.packets
from .protocol import packets
def get_packets(old_get_packets):
def wrapper(func, context):
print('Monkey-patch worked.')
mc_packets = func(context)
# add any custom CLIENTBOUND packets here
mc_packets.add(packets.ChunkDataPacket)
mc_packets.add(packets.AcknowledgePlayerDiggingPacket)
mc_packets.add(packets.BlockBreakAnimationPacket)
mc_packets.add(packets.SetSlotPacket)
mc_packets.add(packets.OpenWindowPacket)
mc_packets.add(packets.ClientWindowConfirmationPacket)
mc_packets.add(packets.EntityMetadataPacket)
mc_packets.add(packets.SpawnLivingEntityPacket)
mc_packets.add(packets.EntityPositionRotationPacket)
mc_packets.add(packets.DestroyEntitiesPacket)
mc_packets.add(packets.EntityTeleport)
mc_packets.add(packets.TradeListPacket)
mc_packets.add(packets.DisconnectPacket)
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)