Server actually ticks
This commit is contained in:
@@ -128,6 +128,10 @@ export class PlayerControlsSystem extends System {
|
||||
|
||||
if (block && player_component.screens.length === 0) {
|
||||
const block_info = EverythingRegistry.get_by_id<BlockRegistry>("blocks", block.block)!;
|
||||
if (InputManager.is_mouse_pressed(0)) {
|
||||
// for mods' on_click, breaking itself is timed here and sent when done
|
||||
send({ type: "hit_block", x: block.x, y: block.y, z: block.z });
|
||||
}
|
||||
if (player_component.breaking_block) {
|
||||
player_component.breaking_block = { x: block.x, y: block.y, z: block.z };
|
||||
player_component.break_progress_max = block_info.toughness ?? 9999;
|
||||
@@ -151,9 +155,11 @@ export class PlayerControlsSystem extends System {
|
||||
const target = { x: block.x + offset.x, y: block.y + offset.y, z: block.z + offset.z };
|
||||
const target_id = world.dimension.get_block(target.x, target.y, target.z);
|
||||
const replaceable = target_id === AIR ||
|
||||
EverythingRegistry.get_by_id<BlockRegistry>("blocks", target_id)?.id === "bworld:water";
|
||||
if (!block_info.interactive && holding_item_info?.block_id && replaceable) {
|
||||
world.dimension.add_block({ ...target, id: holding_item_info.block_id });
|
||||
EverythingRegistry.get_by_id<BlockRegistry>("blocks", target_id)?.replaceable;
|
||||
// items with components might do something else on the server, like on_use
|
||||
const place_id = holding_item_info?.components ? undefined : holding_item_info?.block_id;
|
||||
if (!block_info.interactive && place_id && replaceable) {
|
||||
world.dimension.add_block({ ...target, id: place_id });
|
||||
hotbar_slot.amount = hotbar_slot.amount! - 1;
|
||||
}
|
||||
}
|
||||
@@ -161,6 +167,9 @@ export class PlayerControlsSystem extends System {
|
||||
player_component.breaking_block = undefined;
|
||||
player_component.break_progress_max = 0;
|
||||
player_component.break_progress = 0;
|
||||
if (!block && player_component.screens.length === 0 && InputManager.is_mouse_pressed(2)) {
|
||||
send({ type: "use_item" });
|
||||
}
|
||||
}
|
||||
|
||||
if (player_component.screens.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user