Move monkey-patching into its own module
This commit is contained in:
parent
f3e39802d2
commit
514b324156
15
bot.py
15
bot.py
|
@ -10,20 +10,7 @@ SERVER = ''
|
|||
|
||||
from custom.managers import DataManager, ChunksManager, ChatManager
|
||||
|
||||
import minecraft.networking.packets
|
||||
from custom.networking.packets.clientbound.play import chunk_data, block_change_packet
|
||||
|
||||
def get_packets(old_get_packets):
|
||||
def wrapper(func, context):
|
||||
print('Monkey-patched.')
|
||||
packets = func(context)
|
||||
packets.add(chunk_data.ChunkDataPacket)
|
||||
packets.add(block_change_packet.BlockChangePacket)
|
||||
packets.add(block_change_packet.MultiBlockChangePacket)
|
||||
return 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)
|
||||
import monkey_patch
|
||||
|
||||
from minecraft import authentication
|
||||
from minecraft.exceptions import YggdrasilError
|
||||
|
|
17
monkey_patch.py
Normal file
17
monkey_patch.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
import minecraft.networking.packets
|
||||
from custom.networking.packets.clientbound.play import chunk_data, block_change_packet
|
||||
|
||||
def get_packets(old_get_packets):
|
||||
def wrapper(func, context):
|
||||
print('Monkey-patched.')
|
||||
packets = func(context)
|
||||
|
||||
# add any custom packets here
|
||||
packets.add(chunk_data.ChunkDataPacket)
|
||||
packets.add(block_change_packet.BlockChangePacket)
|
||||
packets.add(block_change_packet.MultiBlockChangePacket)
|
||||
|
||||
return 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)
|
Loading…
Reference in New Issue
Block a user