Add job for filling in a volume of blocks
This commit is contained in:
@@ -20,7 +20,7 @@ from protocol.packets import (
|
||||
ClickWindowPacket, CloseWindowPacket, ServerWindowConfirmationPacket,
|
||||
ClientWindowConfirmationPacket, EntityMetadataPacket,
|
||||
SpawnLivingEntityPacket, EntityPositionRotationPacket, DestroyEntitiesPacket,
|
||||
EntityActionPacket,
|
||||
EntityActionPacket, SpawnPlayerPacket,
|
||||
)
|
||||
|
||||
from protocol.types import Slot
|
||||
@@ -319,6 +319,7 @@ class Game:
|
||||
register(self.handle_entity_position, clientbound.play.EntityPositionDeltaPacket)
|
||||
register(self.handle_entity_position_rotation, EntityPositionRotationPacket)
|
||||
register(self.handle_destroy_entities, DestroyEntitiesPacket)
|
||||
register(self.handle_spawn_player, SpawnPlayerPacket)
|
||||
#register(self.handle_entity_velocity, clientbound.play.EntityVelocityPacket)
|
||||
|
||||
#register(self.handle_packet, Packet, early=True)
|
||||
@@ -356,6 +357,8 @@ class Game:
|
||||
import traceback
|
||||
print(traceback.format_exc())
|
||||
|
||||
#print(packet)
|
||||
|
||||
def handle_position_and_look(self, packet):
|
||||
print(packet)
|
||||
p = LPoint3f(x=packet.x, y=packet.y, z=packet.z)
|
||||
@@ -612,6 +615,33 @@ class Game:
|
||||
data = data.replace('^', '.')
|
||||
reply = str(eval(data))
|
||||
|
||||
if command == 'fill':
|
||||
try:
|
||||
data = data.replace('(', ' ').replace(')', ' ').replace(',', ' ')
|
||||
x1, y1, z1, x2, y2, z2 = [int(x) for x in data.split()]
|
||||
except (AttributeError, ValueError):
|
||||
reply = 'usage: !fill x1 y1 z1 x2 y2 z2'
|
||||
|
||||
if not reply:
|
||||
coord1 = (x1, y1, z1)
|
||||
coord2 = (x2, y2, z2)
|
||||
block = self.g.world.block_at(*coord1)
|
||||
|
||||
if not reply and y1 > y2:
|
||||
reply = 'can only fill upwards'
|
||||
|
||||
if not reply and block is None:
|
||||
reply = 'first coord out of range'
|
||||
|
||||
if not reply and block == 0:
|
||||
reply = 'can\'t fill with air'
|
||||
|
||||
if not reply:
|
||||
self.g.filling = Munch(coord1=coord1, coord2=coord2, block=block)
|
||||
self.g.job.state = self.g.job.fill_blocks
|
||||
reply = 'filling ' + str(utils.pvolume(coord1, coord2)) + ' with ' + blocks.BLOCKS[block]
|
||||
|
||||
|
||||
except BaseException as e:
|
||||
import traceback
|
||||
print(traceback.format_exc())
|
||||
@@ -794,6 +824,18 @@ class Game:
|
||||
packet2.accepted = packet.accepted
|
||||
self.g.connection.write_packet(packet2)
|
||||
|
||||
def handle_spawn_player(self, packet):
|
||||
print(packet)
|
||||
self.g.players[packet.entity_id] = Munch(
|
||||
entity_id=packet.entity_id,
|
||||
player_uuid=packet.player_uuid,
|
||||
x=packet.x,
|
||||
y=packet.y,
|
||||
z=packet.z,
|
||||
yaw=packet.yaw,
|
||||
pitch=packet.pitch,
|
||||
)
|
||||
|
||||
def handle_spawn_object(self, packet):
|
||||
#return
|
||||
if packet.type_id != 37: return
|
||||
@@ -809,9 +851,6 @@ class Game:
|
||||
)
|
||||
|
||||
def check_gapple(self, packet):
|
||||
if not self.g.job:
|
||||
return
|
||||
|
||||
current_gapple_chest = self.g.job.find_gapple_states.current_chest
|
||||
if current_gapple_chest:
|
||||
for entry in packet.metadata:
|
||||
@@ -826,7 +865,8 @@ class Game:
|
||||
if not packet.metadata:
|
||||
return
|
||||
|
||||
self.check_gapple(packet)
|
||||
if self.g.job and self.g.job.state == self.g.job.find_gapple_states:
|
||||
self.check_gapple(packet)
|
||||
|
||||
obj = self.g.objects.get(packet.entity_id, None)
|
||||
if obj:
|
||||
@@ -836,6 +876,10 @@ class Game:
|
||||
obj.item_id = entry.value.item_id
|
||||
obj.item_count = entry.value.item_count
|
||||
|
||||
player = self.g.players.get(packet.entity_id, None)
|
||||
if player:
|
||||
return
|
||||
|
||||
def handle_spawn_living(self, packet):
|
||||
self.g.mobs[packet.entity_id] = Munch(
|
||||
entity_id=packet.entity_id,
|
||||
|
||||
Reference in New Issue
Block a user