Some more kinetic blocks
This commit is contained in:
@@ -1396,6 +1396,7 @@ export class GameServer {
|
||||
face,
|
||||
hit: [hit[0], hit[1], hit[2]],
|
||||
sneaking: player.sneaking,
|
||||
item: held_slot.type_id!,
|
||||
});
|
||||
// its rules say it can't go there
|
||||
if (ruled_value === undefined) {
|
||||
|
||||
@@ -735,9 +735,18 @@ export class ModRuntime {
|
||||
},
|
||||
world: {
|
||||
get_block: (x, y, z) => game().world.get_block_id(x, y, z),
|
||||
set_block: (x, y, z, id) => {
|
||||
if (id !== AIR_ID && !EverythingRegistry.get("blocks", id)) throw new Error(`unknown block ${id}`);
|
||||
game().set_block(x, y, z, id);
|
||||
set_block: (x, y, z, id, states) => {
|
||||
const info = id === AIR_ID ? undefined : EverythingRegistry.get<BlockRegistry>("blocks", id);
|
||||
if (id !== AIR_ID && !info) throw new Error(`unknown block ${id}`);
|
||||
let value = info && game().world.default_values[game().world.block_ids[id]];
|
||||
for (const [name, state] of Object.entries(states ?? {})) {
|
||||
const bits = info?.states?.find((s) => s.name === name)?.bits;
|
||||
if (bits === undefined || !Number.isInteger(state) || state < 0 || state >= 2 ** bits) {
|
||||
throw new Error(`${id} has no state ${name} that fits ${state}`);
|
||||
}
|
||||
value = set_state_value(value!, info!, name, state)!;
|
||||
}
|
||||
game().set_block(x, y, z, id, undefined, states && value !== undefined ? value >>> 16 : undefined);
|
||||
return true;
|
||||
},
|
||||
break_block: (x, y, z, options = {}) => {
|
||||
|
||||
Reference in New Issue
Block a user