Q to drop
This commit is contained in:
@@ -2,6 +2,8 @@ import { BlockRegistry, EverythingRegistry, ItemRegistry } from "$/common/everyt
|
||||
import { AIR, FACE_OFFSETS, TICK_DELTA } from "$/common/constants.ts";
|
||||
import type { Client } from "./client.ts";
|
||||
import type { BlockHitResult } from "./level/client_level.ts";
|
||||
import type { Container } from "$/common/inventory.ts";
|
||||
import type { ContainerKey } from "$/common/protocol.ts";
|
||||
|
||||
// breaking and using blocks against a server, like minecraft's MultiPlayerGameMode. the client times breaking
|
||||
// and guesses the results so they feel instant, the server decides what really happens
|
||||
@@ -68,6 +70,17 @@ export class MultiPlayerGameMode {
|
||||
}
|
||||
}
|
||||
|
||||
// q on a slot: throws one, or the whole stack. the server spawns the item, this only takes it out right away
|
||||
drop_item(container: Container, key: ContainerKey, index: number, all: boolean) {
|
||||
const item = container.get_item(index);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
this.client.connection.send({ type: "drop_item", container: key, index, all });
|
||||
item.amount = all ? 0 : item.amount - 1;
|
||||
container.set_item(index, item.amount > 0 ? item : undefined);
|
||||
}
|
||||
|
||||
// right click on nothing
|
||||
use_item() {
|
||||
this.client.connection.send({ type: "use_item" });
|
||||
|
||||
Reference in New Issue
Block a user