Finish executing the villager trade
This commit is contained in:
@@ -20,7 +20,8 @@ from protocol.packets import (
|
||||
ClickWindowPacket, CloseWindowPacket, ServerWindowConfirmationPacket,
|
||||
ClientWindowConfirmationPacket, EntityMetadataPacket,
|
||||
SpawnLivingEntityPacket, EntityPositionRotationPacket, DestroyEntitiesPacket,
|
||||
EntityActionPacket, EntityTeleport, InteractEntityPacket, TradeListPacket
|
||||
EntityActionPacket, EntityTeleport, InteractEntityPacket, TradeListPacket,
|
||||
SelectTradePacket,
|
||||
)
|
||||
|
||||
from protocol.types import Slot
|
||||
@@ -789,6 +790,7 @@ class Game:
|
||||
if command == 'close':
|
||||
if self.g.window:
|
||||
self.close_window()
|
||||
reply = 'ok'
|
||||
else:
|
||||
reply = 'nothing open'
|
||||
|
||||
@@ -930,6 +932,16 @@ class Game:
|
||||
count += item.item_count
|
||||
return count
|
||||
|
||||
def get_window_slot(self, item_id):
|
||||
# get the first slot that matches item of a window
|
||||
window_items = list(self.g.window.contents.items())
|
||||
for slot, item in window_items:
|
||||
if not item.present: continue
|
||||
if item.item_id == item_id:
|
||||
return slot, item
|
||||
else: #for
|
||||
return False, False
|
||||
|
||||
def select_item(self, items):
|
||||
# select the first match from items of inv
|
||||
# uses smallest stack of that match
|
||||
@@ -1186,6 +1198,11 @@ class Game:
|
||||
print(packet)
|
||||
self.g.trades = packet.trades
|
||||
|
||||
def select_trade(self, num):
|
||||
packet = SelectTradePacket()
|
||||
packet.selected_slot = num
|
||||
self.g.connection.write_packet(packet)
|
||||
|
||||
def tick(self):
|
||||
if self.g.breaking:
|
||||
self.animate()
|
||||
|
||||
Reference in New Issue
Block a user