Compare commits

...
7 Commits
Author SHA1 Message Date
paula df7a1a94d6 Work on the factory rooms 2026-11-22 16:06:02 -03:00
paula a26d801f4e Middling clicking to give in creative 2026-11-22 14:11:37 -03:00
paula fe09e0cdd7 the purpur was a lie 2026-11-22 14:09:05 -03:00
paula b9deda1a55 Missing blocks 2026-11-22 13:55:30 -03:00
paula 784bac7dd2 Deno fmt 2026-11-22 13:21:32 -03:00
paula ac791b886e Scrap !! 2026-11-22 13:21:27 -03:00
paula e751d22c6e Render geo models in items 2026-11-22 12:24:14 -03:00
128 changed files with 5953 additions and 2848 deletions
+12 -3
View File
@@ -318,7 +318,7 @@ export class Client {
player.entity_interaction_range, player.entity_interaction_range,
(entity) => (entity) =>
entity instanceof RemotePlayer || entity instanceof RemotePlayer ||
(entity instanceof RemoteEntity && !entity.dead && is_hittable(entity)), (entity instanceof RemoteEntity && !entity.dead && is_pickable(entity)),
); );
// a block in front of the entity hides it // a block in front of the entity hides it
this.hit_result = this.level.pick( this.hit_result = this.level.pick(
@@ -352,6 +352,12 @@ export class Client {
return; return;
} }
// middle click in creative gives the block under the crosshair, like minecraft's pick block
if (hit && this.player.creative && InputManager.is_mouse_pressed(1)) {
const block = EverythingRegistry.get_by_id<BlockRegistry>("blocks", hit.block);
if (block) this.connection.send({ type: "chat", text: `/give ${block.id}` });
}
// a click uses right away, holding it on blocks keeps using every USE_REPEAT_MS. not while it's using an item // a click uses right away, holding it on blocks keeps using every USE_REPEAT_MS. not while it's using an item
const now = performance.now(); const now = performance.now();
const use_pressed = InputManager.is_mouse_pressed(2) && !this.player.using_item; const use_pressed = InputManager.is_mouse_pressed(2) && !this.player.using_item;
@@ -377,6 +383,8 @@ export class Client {
if (!attacking && using) { if (!attacking && using) {
this.game_mode.use_item_on(hit); this.game_mode.use_item_on(hit);
} }
} else if (use_pressed && this.entity_hit) {
this.game_mode.interact(this.entity_hit);
} else if (use_pressed) { } else if (use_pressed) {
this.game_mode.use_item(); this.game_mode.use_item();
} else if (!this.entity_hit && InputManager.is_mouse_pressed(0)) { } else if (!this.entity_hit && InputManager.is_mouse_pressed(0)) {
@@ -413,7 +421,8 @@ export class Client {
} }
} }
// mobs can be hit, scripted entities like the fishing hook can't. kinds the client doesn't know are left to the server // what the crosshair can be on: mobs and objects, not scripted entities like the fishing hook. kinds the client doesn't
function is_hittable(entity: RemoteEntity) { // know are left to the server
function is_pickable(entity: RemoteEntity) {
return EverythingRegistry.get<EntityJson>("entities", entity.type)?.behavior !== "scripted"; return EverythingRegistry.get<EntityJson>("entities", entity.type)?.behavior !== "scripted";
} }
+10 -2
View File
@@ -196,20 +196,28 @@ export class MultiPlayerGameMode {
this.client.player.last_attack = performance.now(); this.client.player.last_attack = performance.now();
} }
// right click on an entity or another player, for mods' entity_interact. the server uses the held item when none
// of them stops it
interact(entity: Entity) {
this.client.player.send_position_now();
this.client.connection.send({ type: "interact_entity", id: entity.id });
}
// right click on nothing // right click on nothing
use_item() { use_item() {
this.client.connection.send({ type: "use_item" }); this.client.connection.send({ type: "use_item" });
} }
// whether a mob's or player's collision box overlaps the block, the server doesn't let solid blocks go there. mobs // whether a mob's or player's collision box overlaps the block, the server doesn't let solid blocks go there. mobs
// are the mod entities that aren't scripted, players are this one and the others // are the mod entities that aren't scripted or objects, players are this one and the others
#occupied(x: number, y: number, z: number, block: BlockRegistry, value: number) { #occupied(x: number, y: number, z: number, block: BlockRegistry, value: number) {
const shape = collision_shape_at(block, value); const shape = collision_shape_at(block, value);
for (const entity of this.client.level.entities.values()) { for (const entity of this.client.level.entities.values()) {
const json = entity instanceof RemoteEntity const json = entity instanceof RemoteEntity
? EverythingRegistry.get<EntityJson>("entities", entity.type) ? EverythingRegistry.get<EntityJson>("entities", entity.type)
: undefined; : undefined;
const blocks = entity instanceof Player || (json !== undefined && json.behavior !== "scripted"); const blocks = entity instanceof Player ||
(json !== undefined && json.behavior !== "scripted" && json.behavior !== "object");
if (blocks && box_overlaps_block(entity, x, y, z, shape)) return true; if (blocks && box_overlaps_block(entity, x, y, z, shape)) return true;
} }
return false; return false;
+30 -14
View File
@@ -5,7 +5,7 @@
// turns to the entity's yaw, and its bones are posed by its type's animator from a mod (see entity_animators.ts). without // turns to the entity's yaw, and its bones are posed by its type's animator from a mod (see entity_animators.ts). without
// one, a bone named "head" turns to where it looks, and bones named like minecraft's humanoid ones (right_arm, left_arm, // one, a bone named "head" turns to where it looks, and bones named like minecraft's humanoid ones (right_arm, left_arm,
// right_leg, left_leg) swing as it walks, the right arm when it attacks too. entities without a model are their texture // right_leg, left_leg) swing as it walks, the right arm when it attacks too. entities without a model are their texture
// facing the camera, like minecraft's fishing hook // facing the camera, like minecraft's fishing hook, and objects without one are the item they hold
import { AssetManager } from "@/client/assets.ts"; import { AssetManager } from "@/client/assets.ts";
import type { Camera } from "@/client/camera.ts"; import type { Camera } from "@/client/camera.ts";
import type { RemoteEntity } from "@/client/entity/remote_entity.ts"; import type { RemoteEntity } from "@/client/entity/remote_entity.ts";
@@ -18,6 +18,8 @@ import { HURT_TINT } from "./player_renderer.ts";
import { bone_matrices, IDENTITY, model_pivot, multiply, rotation_around, type Vec3 } from "./model_math.ts"; import { bone_matrices, IDENTITY, model_pivot, multiply, rotation_around, type Vec3 } from "./model_math.ts";
import { push_model } from "./model_renderer.ts"; import { push_model } from "./model_renderer.ts";
import { entity_tint } from "./entity_light.ts"; import { entity_tint } from "./entity_light.ts";
import { push_item, synced_stack } from "./item_renderer.ts";
import type { ItemData } from "@/common/inventory.ts";
// models are in texture pixels, 16 to a block // models are in texture pixels, 16 to a block
const PIXEL = 1 / 16; const PIXEL = 1 / 16;
@@ -27,29 +29,42 @@ export function render_mod_entity(entity: RemoteEntity, camera: Camera, partial_
const json = EverythingRegistry.get<EntityJson>("entities", entity.type); const json = EverythingRegistry.get<EntityJson>("entities", entity.type);
if (!json) return; if (!json) return;
const atlas = AssetManager.instance.get<Texture>("cubi:textures"); const atlas = AssetManager.instance.get<Texture>("cubi:textures");
const region = get_sprite_region(json.texture);
const hurt = entity.hurt_time > 0 || entity.dead ? HURT_TINT : undefined; const hurt = entity.hurt_time > 0 || entity.dead ? HURT_TINT : undefined;
const tint = entity_tint(entity, partial_tick, hurt, entity.data.on_fire === true); const tint = entity_tint(entity, partial_tick, hurt, entity.data.on_fire === true);
const scale = json.scale ?? 1;
if (json.model === undefined) { if (json.model === undefined) {
render_sprite(entity, camera, atlas, region, partial_tick, tint); // an object is the item it holds, the size the item's model is made
const item = entity.data.item as ItemData | undefined;
if (json.behavior === "object") {
if (item) push_item(atlas, synced_stack(item), turned_with(entity, partial_tick, scale), tint);
} else if (json.texture !== undefined) {
render_sprite(entity, camera, atlas, get_sprite_region(json.texture), scale, partial_tick, tint);
}
return; return;
} }
const model = EverythingRegistry.get<EntityModelJson>("entity_models", json.model); const model = EverythingRegistry.get<EntityModelJson>("entity_models", json.model);
if (!model) return; if (!model || json.texture === undefined) return;
const { x, y, z } = entity.render_position(partial_tick);
const yaw_sin = Math.sin(entity.yaw);
const yaw_cos = Math.cos(entity.yaw);
const to_world = (px: number, py: number, pz: number): Vec3 => {
const [mx, my, mz] = [px * PIXEL, py * PIXEL, pz * PIXEL];
return [x + mx * yaw_cos + mz * yaw_sin, y + my, z - mx * yaw_sin + mz * yaw_cos];
};
const placed = turned_with(entity, partial_tick, scale);
const to_world = (px: number, py: number, pz: number) => placed(px * PIXEL, py * PIXEL, pz * PIXEL);
const offsets = entity.animation?.pose(entity.age + partial_tick); const offsets = entity.animation?.pose(entity.age + partial_tick);
const pose = offsets ? () => IDENTITY : default_pose(entity, partial_tick); const pose = offsets ? () => IDENTITY : default_pose(entity, partial_tick);
const region = get_sprite_region(json.texture);
push_model(model, bone_matrices(model, pose, offsets), atlas, region, to_world, tint); push_model(model, bone_matrices(model, pose, offsets), atlas, region, to_world, tint);
} }
// from blocks around the entity's feet, its own way round, to the world: sized by scale and turned to its yaw
function turned_with(entity: RemoteEntity, partial_tick: number, scale: number) {
const { x, y, z } = entity.render_position(partial_tick);
const yaw_sin = Math.sin(entity.yaw) * scale;
const yaw_cos = Math.cos(entity.yaw) * scale;
return (bx: number, by: number, bz: number): Vec3 => [
x + bx * yaw_cos + bz * yaw_sin,
y + by * scale,
z - bx * yaw_sin + bz * yaw_cos,
];
}
// the head looking and the humanoid swing, for an entity without an animator // the head looking and the humanoid swing, for an entity without an animator
function default_pose(entity: RemoteEntity, partial_tick: number) { function default_pose(entity: RemoteEntity, partial_tick: number) {
const limbs = limb_angles(entity, partial_tick); const limbs = limb_angles(entity, partial_tick);
@@ -86,14 +101,15 @@ function render_sprite(
camera: Camera, camera: Camera,
atlas: Texture, atlas: Texture,
region: SpriteRegion, region: SpriteRegion,
scale: number,
partial_tick: number, partial_tick: number,
[r, g, b]: Vec3, [r, g, b]: Vec3,
) { ) {
const { x, y, z } = entity.render_position(partial_tick); const { x, y, z } = entity.render_position(partial_tick);
const cy = y + entity.height / 2; const cy = y + entity.height / 2;
// the camera's right and up, halved to the sprite's size // the camera's right and up, halved to the sprite's size
const half_width = region.width * PIXEL / 2; const half_width = region.width * PIXEL * scale / 2;
const half_height = region.height * PIXEL / 2; const half_height = region.height * PIXEL * scale / 2;
const [yaw_sin, yaw_cos] = [Math.sin(camera.yaw), Math.cos(camera.yaw)]; const [yaw_sin, yaw_cos] = [Math.sin(camera.yaw), Math.cos(camera.yaw)];
const [pitch_sin, pitch_cos] = [Math.sin(camera.pitch), Math.cos(camera.pitch)]; const [pitch_sin, pitch_cos] = [Math.sin(camera.pitch), Math.cos(camera.pitch)];
const right: Vec3 = [yaw_cos * half_width, 0, -yaw_sin * half_width]; const right: Vec3 = [yaw_cos * half_width, 0, -yaw_sin * half_width];
+71 -11
View File
@@ -9,13 +9,14 @@ import { get_sprite_region } from "@/client/sprites.ts";
import type { ItemEntity } from "@/client/entity/item_entity.ts"; import type { ItemEntity } from "@/client/entity/item_entity.ts";
import { contained_fluid, type ItemData, ItemStack } from "@/common/inventory.ts"; import { contained_fluid, type ItemData, ItemStack } from "@/common/inventory.ts";
import type { FluidVariant } from "@/common/mod_api/shared.ts"; import type { FluidVariant } from "@/common/mod_api/shared.ts";
import type { FluidJson } from "@/common/mod_data.ts"; import type { EntityModelJson, FluidJson } from "@/common/mod_data.ts";
import { light_color, push_vertex, Texture } from "@/client/renderer/mod.ts"; import { light_color, push_vertex, Texture } from "@/client/renderer/mod.ts";
import { import {
bake_model, bake_model,
type BakedQuad, type BakedQuad,
block_item_texture, block_item_texture,
block_variant, block_variant,
classify_quad,
cube_face_texture, cube_face_texture,
cube_face_tint, cube_face_tint,
type DisplayTransform, type DisplayTransform,
@@ -30,6 +31,8 @@ import { get_state_value, item_texture } from "@/common/utils.ts";
import { ID_MASK, TEXTURE_SIZE } from "@/common/constants.ts"; import { ID_MASK, TEXTURE_SIZE } from "@/common/constants.ts";
import type { ClientLevel } from "@/client/level/client_level.ts"; import type { ClientLevel } from "@/client/level/client_level.ts";
import { entity_tint } from "./entity_light.ts"; import { entity_tint } from "./entity_light.ts";
import { bone_matrices, IDENTITY } from "./model_math.ts";
import { push_model } from "./model_renderer.ts";
import type { Vec3 } from "./player_renderer.ts"; import type { Vec3 } from "./player_renderer.ts";
import { fluid_rules } from "@/client/fluid_rules.ts"; import { fluid_rules } from "@/client/fluid_rules.ts";
import { color_rgb, tint_without_biome, type TintColor } from "@/common/worldgen/biome_colors.ts"; import { color_rgb, tint_without_biome, type TintColor } from "@/common/worldgen/biome_colors.ts";
@@ -124,8 +127,17 @@ export function render_item_entity(entity: ItemEntity, partial_tick: number) {
} }
} }
// the stacks shown items are drawn as, by their "item" client data, which is replaced whenever it changes // the stack an item synced to clients is drawn as, like a shown item's "item" client data or an object's. made once
const shown_stacks = new WeakMap<ItemData, ItemStack>(); // for each, since the data is replaced whenever it changes
export function synced_stack(data: ItemData): ItemStack {
let stack = synced_stacks.get(data);
if (!stack) {
stack = ItemStack.from_data(data);
synced_stacks.set(data, stack);
}
return stack;
}
const synced_stacks = new WeakMap<ItemData, ItemStack>();
// every item blocks with item_display show on top of them, their "item" client data, see BlockRegistry.item_display. // every item blocks with item_display show on top of them, their "item" client data, see BlockRegistry.item_display.
// the atlas has to be the current texture // the atlas has to be the current texture
@@ -140,11 +152,7 @@ export function render_block_items(level: ClientLevel) {
const value = level.get_block_value(x, y, z); const value = level.get_block_value(x, y, z);
const block = blocks[value & ID_MASK]; const block = blocks[value & ID_MASK];
if (!block?.item_display) continue; if (!block?.item_display) continue;
let item = shown_stacks.get(shown); const item = synced_stack(shown);
if (!item) {
item = ItemStack.from_data(shown);
shown_stacks.set(shown, item);
}
// the block's own light, or the one above for blocks light doesn't get into, since the items sit on top // the block's own light, or the one above for blocks light doesn't get into, since the items sit on top
const here = level.get_light(x, y, z); const here = level.get_light(x, y, z);
const above = level.get_light(x, y + 1, z); const above = level.get_light(x, y + 1, z);
@@ -249,11 +257,15 @@ export interface ItemModel {
block?: BlockRegistry; block?: BlockRegistry;
} }
// an item's own model, or its block's item_model with the block's textures, baked the first time it's drawn. undefined // an item's own model, or its block's item_model with the block's textures, baked the first time it's drawn. an item's
// for items drawn as a cube or as their sprite // own can be an entity model, drawn in the item's texture. undefined for items drawn as a cube or as their sprite
export function item_model_of(item: ItemStack): ItemModel | undefined { export function item_model_of(item: ItemStack): ItemModel | undefined {
const info = EverythingRegistry.get<ItemRegistry>("items", item.type_id); const info = EverythingRegistry.get<ItemRegistry>("items", item.type_id);
if (info?.model !== undefined) return baked_item_model(info, info.model); if (info?.model !== undefined) {
const entity_model = EverythingRegistry.get<EntityModelJson>("entity_models", info.model);
if (entity_model) return baked_entity_item_model(entity_model, item_texture(item, info));
return baked_item_model(info, info.model);
}
const block = placed_block(item); const block = placed_block(item);
if (block?.item_model !== undefined) return baked_item_model(block, block.item_model, block); if (block?.item_model !== undefined) return baked_item_model(block, block.item_model, block);
return undefined; return undefined;
@@ -270,6 +282,54 @@ function baked_item_model(key: ItemRegistry | BlockRegistry, id: string, block?:
} }
const baked_items = new WeakMap<ItemRegistry | BlockRegistry, ItemModel>(); const baked_items = new WeakMap<ItemRegistry | BlockRegistry, ItemModel>();
// by texture, since an item's texture can change with its data
function baked_entity_item_model(model: EntityModelJson, texture: string): ItemModel {
let by_texture = baked_entity_items.get(model);
if (!by_texture) {
by_texture = new Map();
baked_entity_items.set(model, by_texture);
}
let baked = by_texture.get(texture);
if (!baked) {
baked = { quads: entity_model_quads(model, texture), display: model.display ?? {} };
by_texture.set(texture, baked);
}
return baked;
}
const baked_entity_items = new WeakMap<EntityModelJson, Map<string, ItemModel>>();
// an entity model as a block model's quads, standing on the block's bottom in its middle like it stands on the ground,
// 16 of its pixels across the block. its uvs are pixels of the texture, 0 to 16 like a block model's
export function entity_model_quads(model: EntityModelJson, texture: string): BakedQuad[] {
const vertices: number[][] = [];
const pixels = { width: 1, height: 1 } as Texture;
const whole_texture = { x: 0, y: 0, width: TEXTURE_SIZE, height: TEXTURE_SIZE };
const to_block = (x: number, y: number, z: number): Vec3 => [x / 16 + 0.5, y / 16, z / 16 + 0.5];
push_model(model, bone_matrices(model, () => IDENTITY), pixels, whole_texture, to_block, undefined, undefined, (
x,
y,
z,
u,
v,
) => vertices.push([x, y, z, u, v]));
const quads: BakedQuad[] = [];
// two triangles a box face, its corners 0 1 2 and 0 2 3
for (let i = 0; i < vertices.length; i += 6) {
const corners = [vertices[i], vertices[i + 1], vertices[i + 2], vertices[i + 5]];
const positions = corners.flatMap(([x, y, z]) => [x, y, z]);
quads.push({
positions,
uvs: corners.flatMap(([, , , u, v]) => [u, v]),
texture,
variables: [],
...classify_quad(positions),
cull: -1,
shade: true,
});
}
return quads;
}
// whether an item is drawn as a block or a model rather than its sprite, which decides how big it's drawn and how it's // whether an item is drawn as a block or a model rather than its sprite, which decides how big it's drawn and how it's
// held when its model has no display transform for that // held when its model has no display transform for that
export function drawn_as_model(item: ItemStack) { export function drawn_as_model(item: ItemStack) {
+2 -2
View File
@@ -500,7 +500,7 @@ export function bake_model(
let cull = face_json.cullface ? FACE_INDEX[face_json.cullface] : -1; let cull = face_json.cullface ? FACE_INDEX[face_json.cullface] : -1;
for (let t = 0; t < x_turns && cull >= 0; t++) cull = TURN_X[cull]; for (let t = 0; t < x_turns && cull >= 0; t++) cull = TURN_X[cull];
for (let t = 0; t < turns && cull >= 0; t++) cull = TURN_Y[cull]; for (let t = 0; t < turns && cull >= 0; t++) cull = TURN_Y[cull];
const { face: facing, flush, aligned } = classify(positions); const { face: facing, flush, aligned } = classify_quad(positions);
quads.push({ quads.push({
positions, positions,
uvs, uvs,
@@ -560,7 +560,7 @@ export function element_rotation(element: ModelElementJson): (point: number[]) =
} }
// which way a quad faces most, whether it's flat against the block's edge, and whether it faces straight along an axis // which way a quad faces most, whether it's flat against the block's edge, and whether it faces straight along an axis
function classify(p: number[]): { face: number; flush: boolean; aligned: boolean } { export function classify_quad(p: number[]): { face: number; flush: boolean; aligned: boolean } {
const e1 = [p[3] - p[0], p[4] - p[1], p[5] - p[2]]; const e1 = [p[3] - p[0], p[4] - p[1], p[5] - p[2]];
const e2 = [p[9] - p[0], p[10] - p[1], p[11] - p[2]]; const e2 = [p[9] - p[0], p[10] - p[1], p[11] - p[2]];
const normal = [e1[1] * e2[2] - e1[2] * e2[1], e1[2] * e2[0] - e1[0] * e2[2], e1[0] * e2[1] - e1[1] * e2[0]]; const normal = [e1[1] * e2[2] - e1[2] * e2[1], e1[2] * e2[0] - e1[0] * e2[2], e1[0] * e2[1] - e1[1] * e2[0]];
+5 -1
View File
@@ -284,8 +284,12 @@ export interface ItemRegistry<T = unknown | undefined> {
texture_id: string | ((item: ItemStack<T>) => string); texture_id: string | ((item: ItemStack<T>) => string);
// shown in place of texture_id while the stack's data has that key set, like a cast fishing rod. the first wins // shown in place of texture_id while the stack's data has that key set, like a cast fishing rod. the first wins
data_textures?: Record<string, string>; data_textures?: Record<string, string>;
// a model it's drawn with instead of its texture, with the model's own textures, like a 3d wrench // a model it's drawn with instead of its texture, with the model's own textures, like a 3d wrench. or an entity
// model (see EntityModelJson), drawn in its texture
model?: string; model?: string;
// the entity it lies in the world as instead of a cubi:item, holding the stack, like neoforge's hasCustomEntity.
// an "object" (see EntityJson.behavior)
entity?: string;
// what players see, like "Iron Ingot". made from the id when not set, see display_name in common/utils.ts // what players see, like "Iron Ingot". made from the id when not set, see display_name in common/utils.ts
name?: string; name?: string;
block_id?: string; block_id?: string;
+12 -3
View File
@@ -381,6 +381,13 @@ export interface BlockInteractEvent {
readonly item: ItemStack | undefined; readonly item: ItemStack | undefined;
} }
// a right click on an entity, like neoforge's PlayerInteractEvent.EntityInteract
export interface EntityInteractEvent {
readonly player: Player;
readonly entity: EntityRef;
readonly item: ItemStack | undefined;
}
// a player or a mob being hurt, like neoforge's LivingIncomingDamageEvent // a player or a mob being hurt, like neoforge's LivingIncomingDamageEvent
export interface EntityDamageEvent { export interface EntityDamageEvent {
readonly entity: LivingRef; readonly entity: LivingRef;
@@ -408,6 +415,8 @@ export interface ServerBeforeEvents {
block_break: EventSignal<BlockBreakEvent & Cancelable>; block_break: EventSignal<BlockBreakEvent & Cancelable>;
block_place: EventSignal<BlockPlaceEvent & Cancelable>; block_place: EventSignal<BlockPlaceEvent & Cancelable>;
block_interact: EventSignal<BlockInteractEvent & Cancelable>; block_interact: EventSignal<BlockInteractEvent & Cancelable>;
// handlers do what the click does, and cancel it so the held item isn't used too
entity_interact: EventSignal<EntityInteractEvent & Cancelable>;
chat_send: EventSignal<ChatSendEvent & Cancelable>; chat_send: EventSignal<ChatSendEvent & Cancelable>;
entity_damage: EventSignal<EntityDamageEvent & Cancelable>; entity_damage: EventSignal<EntityDamageEvent & Cancelable>;
} }
@@ -584,10 +593,10 @@ export interface EntityRef {
// like neoforge's Entity.kill: a player or a mob dies, even when invulnerable, and anything else is removed. cause // like neoforge's Entity.kill: a player or a mob dies, even when invulnerable, and anything else is removed. cause
// is for events and the death message, like LivingRef.damage's. mods' entity_damage can still cancel it // is for events and the death message, like LivingRef.damage's. mods' entity_damage can still cancel it
kill(cause?: string): void; kill(cause?: string): void;
// what an item lying around is, a copy. undefined for every other kind of entity // what an item lying around is, or what an object holds, a copy. undefined for every other kind of entity
get_item(): ItemStack | undefined; get_item(): ItemStack | undefined;
// changes what an item lying around is, like ItemEntity.setItem. undefined or a count of 0 removes it. throws for // changes what an item lying around is, like ItemEntity.setItem, undefined or a count of 0 removing it. or what an
// every other kind of entity // object holds, undefined or a count of 0 leaving it holding nothing. throws for every other kind of entity
set_item(item: ItemStack | undefined): void; set_item(item: ItemStack | undefined): void;
// a sound following it, once, for every player who sees it and is within its range // a sound following it, once, for every player who sees it and is within its range
play_sound(sound: Id, options?: PlayOptions): void; play_sound(sound: Id, options?: PlayOptions): void;
+11 -2
View File
@@ -361,7 +361,16 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
errors.push(`${file}: item ${json.id} has no texture, and no block of this mod gives it an item`); errors.push(`${file}: item ${json.id} has no texture, and no block of this mod gives it an item`);
} }
for (const texture of Object.values(json.data_textures ?? {})) uses(file, texture, "texture"); for (const texture of Object.values(json.data_textures ?? {})) uses(file, texture, "texture");
if (json.model) uses(file, json.model, "model"); // an entity model is drawn in the item's texture
if (json.model && !entity_model_owners.has(json.model)) uses(file, json.model, "model");
if (json.entity) {
check_namespace(file, json.entity);
const behavior = entity_jsons.get(json.entity)?.behavior;
if (!entity_owners.has(json.entity)) errors.push(`${file}: entity ${json.entity} doesn't exist`);
else if (behavior !== "object") {
errors.push(`${file}: entity ${json.entity} has to be an "object" to lie around holding the item`);
}
}
if (json.places) uses(file, json.places, "block"); if (json.places) uses(file, json.places, "block");
if (json.food?.returns) uses(file, json.food.returns, "item"); if (json.food?.returns) uses(file, json.food.returns, "item");
for (const layer of json.layers ?? []) uses(file, layer.texture, "texture"); for (const layer of json.layers ?? []) uses(file, layer.texture, "texture");
@@ -404,7 +413,7 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
errors.push(`${file}: entity ${json.id} is also defined by ${entity_owners.get(json.id)!.join(", ")}`); errors.push(`${file}: entity ${json.id} is also defined by ${entity_owners.get(json.id)!.join(", ")}`);
} }
if (json.model !== undefined) uses(file, json.model, "entity model"); if (json.model !== undefined) uses(file, json.model, "entity model");
uses(file, json.texture, "texture"); if (json.texture !== undefined) uses(file, json.texture, "texture");
if (json.loot_table) uses(file, json.loot_table, "loot table"); if (json.loot_table) uses(file, json.loot_table, "loot table");
if (json.sounds) uses_sounds(file, json.sounds, ENTITY_SOUNDS); if (json.sounds) uses_sounds(file, json.sounds, ENTITY_SOUNDS);
// scripts register behaviors, the server checks them when it starts // scripts register behaviors, the server checks them when it starts
+44 -7
View File
@@ -23,7 +23,7 @@ import {
WATERLOGGED, WATERLOGGED,
type WornProperties, type WornProperties,
} from "./everything_registry.ts"; } from "./everything_registry.ts";
import type { BlockPart, BlockVariant, ModelFileJson } from "./block_models.ts"; import type { BlockPart, BlockVariant, ModelDisplay, ModelFileJson } from "./block_models.ts";
import { expand_items, list_matches } from "./tags.ts"; import { expand_items, list_matches } from "./tags.ts";
import { GAME_VERSION } from "./constants.ts"; import { GAME_VERSION } from "./constants.ts";
import type { PlayOptions } from "./mod_api/shared.ts"; import type { PlayOptions } from "./mod_api/shared.ts";
@@ -368,6 +368,8 @@ export interface ItemJson {
data_textures?: Record<string, string>; data_textures?: Record<string, string>;
// see ItemRegistry.model // see ItemRegistry.model
model?: string; model?: string;
// see ItemRegistry.entity
entity?: string;
// tier and speed default to 0 and 2 // tier and speed default to 0 and 2
tool?: Omit<ToolProperties, "tier" | "speed"> & Partial<ToolProperties>; tool?: Omit<ToolProperties, "tier" | "speed"> & Partial<ToolProperties>;
places?: string; places?: string;
@@ -390,6 +392,7 @@ const item_schema: z.ZodType<ItemJson> = z.object({
texture: id.optional(), texture: id.optional(),
data_textures: z.record(z.string(), id).optional(), data_textures: z.record(z.string(), id).optional(),
model: id.optional(), model: id.optional(),
entity: id.optional(),
tool: z.object({ tool: z.object({
type: z.string(), type: z.string(),
durability: z.int().min(1), durability: z.int().min(1),
@@ -429,19 +432,24 @@ const item_schema: z.ZodType<ItemJson> = z.object({
components: json_object.optional(), components: json_object.optional(),
}); });
// a kind of entity, drawn with an entity model and one texture, or without a model as its texture facing the camera const ENTITY_BEHAVIORS = ["animal", "monster", "scripted", "object"];
// a kind of entity, drawn with an entity model and one texture, or without a model as its texture facing the camera.
// an object without a model is drawn as the item it holds
const entity_schema = z.object({ const entity_schema = z.object({
id, id,
// an entity model, see EntityModelJson // an entity model, see EntityModelJson
model: id.optional(), model: id.optional(),
texture: id, // only an object can go without one
texture: id.optional(),
// "animal" (the default) wanders around, panics when hurt and looks at players. "monster" goes after players it // "animal" (the default) wanders around, panics when hurt and looks at players. "monster" goes after players it
// sees and whoever hurts it, and despawns far from players, like minecraft's zombies. "scripted" stays where // sees and whoever hurts it, and despawns far from players, like minecraft's zombies. "scripted" stays where
// scripts put it: no gravity, ai or health, and it isn't saved with the world, like the fishing hook. any other id // scripts put it: no gravity, ai or health, and it isn't saved with the world, like the fishing hook. "object" lies
// is a behavior a mod's script registers // around like a dropped item, holding one, without ai or health (see ItemRegistry.entity). any other id is a
// behavior a mod's script registers
behavior: z.custom<string>( behavior: z.custom<string>(
(value) => ["animal", "monster", "scripted"].includes(value as string) || id.safeParse(value).success, (value) => ENTITY_BEHAVIORS.includes(value as string) || id.safeParse(value).success,
'must be "animal", "monster", "scripted" or a behavior id like "my_mod:thing"', 'must be "animal", "monster", "scripted", "object" or a behavior id like "my_mod:thing"',
).optional(), ).optional(),
// what natural spawning counts it as, see entity_category // what natural spawning counts it as, see entity_category
category: z.enum(["monster", "creature"]).optional(), category: z.enum(["monster", "creature"]).optional(),
@@ -465,6 +473,11 @@ const entity_schema = z.object({
loot_table: loot_table_id.optional(), loot_table: loot_table_id.optional(),
// what it sounds like: <sounds>/hurt, /death, /step and /ambient, see ENTITY_SOUNDS // what it sounds like: <sounds>/hurt, /death, /step and /ambient, see ENTITY_SOUNDS
sounds: sound_prefix.optional(), sounds: sound_prefix.optional(),
// how much bigger it's drawn than its model (or its texture, or its item), 1 when not set. its box stays the same
scale: z.number().positive().optional(),
}).refine((entity) => entity.texture !== undefined || entity.behavior === "object", {
path: ["texture"],
message: "is needed unless it's an object",
}); });
export type EntityJson = z.infer<typeof entity_schema>; export type EntityJson = z.infer<typeof entity_schema>;
@@ -567,6 +580,8 @@ const entity_model_schema = z.object({
// the size its uvs are laid out for, the texture is stretched to it // the size its uvs are laid out for, the texture is stretched to it
texture_width: z.int().min(1), texture_width: z.int().min(1),
texture_height: z.int().min(1), texture_height: z.int().min(1),
// how it's placed where it's shown as an item, from the geometry's item_display_transforms
display: z.partialRecord(z.enum(DISPLAY_CONTEXTS), display_transform).optional(),
// parents come before their children // parents come before their children
bones: z.array(entity_bone).superRefine((bones, ctx) => { bones: z.array(entity_bone).superRefine((bones, ctx) => {
const names = new Set<string>(); const names = new Set<string>();
@@ -897,6 +912,7 @@ export function item_to_json(id: string, item: ItemRegistry): ItemJson {
const json: ItemJson = { id, texture: item.texture_id }; const json: ItemJson = { id, texture: item.texture_id };
if (item.data_textures !== undefined) json.data_textures = item.data_textures; if (item.data_textures !== undefined) json.data_textures = item.data_textures;
if (item.model !== undefined) json.model = item.model; if (item.model !== undefined) json.model = item.model;
if (item.entity !== undefined) json.entity = item.entity;
if (item.tool !== undefined) json.tool = item.tool; if (item.tool !== undefined) json.tool = item.tool;
if (item.block_id !== undefined) json.places = item.block_id; if (item.block_id !== undefined) json.places = item.block_id;
if (item.max_stack !== undefined) json.max_stack = item.max_stack; if (item.max_stack !== undefined) json.max_stack = item.max_stack;
@@ -927,6 +943,7 @@ function item_fields(json: ItemJson): Partial<ItemRegistry> {
const item: Partial<ItemRegistry> = {}; const item: Partial<ItemRegistry> = {};
if (json.data_textures !== undefined) item.data_textures = json.data_textures; if (json.data_textures !== undefined) item.data_textures = json.data_textures;
if (json.model !== undefined) item.model = json.model; if (json.model !== undefined) item.model = json.model;
if (json.entity !== undefined) item.entity = json.entity;
if (json.tool !== undefined) item.tool = { tier: 0, speed: 2, ...json.tool }; if (json.tool !== undefined) item.tool = { tier: 0, speed: 2, ...json.tool };
if (json.places !== undefined) item.block_id = json.places; if (json.places !== undefined) item.block_id = json.places;
if (json.max_stack !== undefined) item.max_stack = json.max_stack; if (json.max_stack !== undefined) item.max_stack = json.max_stack;
@@ -1063,10 +1080,12 @@ export function entity_model_from_geo(json: unknown, id: string): { model?: Enti
}; };
} }
const bones = Array.isArray(geometry.bones) ? geometry.bones : []; const bones = Array.isArray(geometry.bones) ? geometry.bones : [];
const display = geo_display(geometry.item_display_transforms);
const model = { const model = {
id, id,
texture_width: geometry.description.texture_width, texture_width: geometry.description.texture_width,
texture_height: geometry.description.texture_height, texture_height: geometry.description.texture_height,
...(display === undefined ? {} : { display }),
bones: bones.map((bone) => { bones: bones.map((bone) => {
if (!is_object(bone)) return bone; if (!is_object(bone)) return bone;
const { name, parent, pivot, rotation } = bone; const { name, parent, pivot, rotation } = bone;
@@ -1094,6 +1113,24 @@ export function entity_model_from_geo(json: unknown, id: string): { model?: Enti
return problems.length === 0 ? { model: model as EntityModelJson, problems } : { problems }; return problems.length === 0 ? { model: model as EntityModelJson, problems } : { problems };
} }
// the places a geometry's item_display_transforms has that items are shown in, with what of each the engine uses. their
// rotation_pivot, scale_pivot and fit_to_frame are left out
function geo_display(transforms: unknown): ModelDisplay | undefined {
if (!is_object(transforms)) return undefined;
const display: Record<string, unknown> = {};
for (const context of DISPLAY_CONTEXTS) {
const transform = transforms[context];
if (!is_object(transform)) continue;
const { rotation, translation, scale } = transform;
display[context] = {
...(rotation === undefined ? {} : { rotation }),
...(translation === undefined ? {} : { translation }),
...(scale === undefined ? {} : { scale }),
};
}
return Object.keys(display).length > 0 ? display as ModelDisplay : undefined;
}
export function validate_clip(json: unknown): Problems { export function validate_clip(json: unknown): Problems {
return find_problems(clip_schema, json); return find_problems(clip_schema, json);
} }
+3 -1
View File
@@ -12,7 +12,7 @@ export const AIR_ID = "cubi:air";
// bump when a client and server of different versions can't play together. // bump when a client and server of different versions can't play together.
// the server rejects a different version before the client downloads anything // the server rejects a different version before the client downloads anything
export const PROTOCOL_VERSION = 30; export const PROTOCOL_VERSION = 31;
export interface PlayerInfo { export interface PlayerInfo {
id: string; id: string;
@@ -132,6 +132,8 @@ export type ClientMessage =
| { type: "hit_block"; x: number; y: number; z: number } | { type: "hit_block"; x: number; y: number; z: number }
// left click on an entity, by id // left click on an entity, by id
| { type: "attack_entity"; id: string } | { type: "attack_entity"; id: string }
// right click on an entity, by id, for mods' entity_interact. it uses the held item when they don't stop it
| { type: "interact_entity"; id: string }
// left click at nothing, a swing at the air. it starts the attack cooldown over, like an attack // left click at nothing, a swing at the air. it starts the attack cooldown over, like an attack
| { type: "swing" } | { type: "swing" }
// right click without looking at a block, for items' on_use // right click without looking at a block, for items' on_use
+2 -1
View File
@@ -43,10 +43,11 @@ showed. These events fire for **every** player's actions, since they all go thro
## The Events ## The Events
| Event | Before | After | Fields | | Event | Before | After | Fields |
| ---------------- | ------ | ----- | ------------------------------------------------------------------------------------------------------------------------------------- | | ----------------- | ------ | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `block_break` | ✓ | ✓ | `player`, `block` (with its tile `data`), `item` held | | `block_break` | ✓ | ✓ | `player`, `block` (with its tile `data`), `item` held |
| `block_place` | ✓ | ✓ | `player`, `block` (`{ id, x, y, z }`), `face` clicked, `hit` where on it (0-1 each axis), `item` held | | `block_place` | ✓ | ✓ | `player`, `block` (`{ id, x, y, z }`), `face` clicked, `hit` where on it (0-1 each axis), `item` held |
| `block_interact` | ✓ | ✓ | `player`, `block`, `item` held. Before fires for every right click on a block, after only when a component's `on_interact` handled it | | `block_interact` | ✓ | ✓ | `player`, `block`, `item` held. Before fires for every right click on a block, after only when a component's `on_interact` handled it |
| `entity_interact` | ✓ | | `player`, `entity` right clicked, `item` held. Cancelling it stops the held item being used, see [Interacting](../entities/index.md#interacting) |
| `chat_send` | ✓ | ✓ | `player`, `message`. Before handlers can change `message` | | `chat_send` | ✓ | ✓ | `player`, `message`. Before handlers can change `message` |
| `entity_damage` | ✓ | ✓ | `entity`, `player`, `amount`, `cause`, `bypasses_invulnerability`. See below | | `entity_damage` | ✓ | ✓ | `entity`, `player`, `amount`, `cause`, `bypasses_invulnerability`. See below |
| `player_death` | | ✓ | `player`, `cause`. They've dropped what they carried and respawn right after | | `player_death` | | ✓ | `player`, `cause`. They've dropped what they carried and respawn right after |
+50 -5
View File
@@ -25,9 +25,10 @@ and players. Mods define new kinds in their `entities/` folder, and draw them wi
| Field | Default | Meaning | | Field | Default | Meaning |
| -------------------- | ---------- | ------------------------------------------------------------------------------------------------------ | | -------------------- | ---------- | ------------------------------------------------------------------------------------------------------ |
| `id` | required | The entity's id. | | `id` | required | The entity's id. |
| `texture` | required | Any texture, stretched over the model's `texture_width` and `texture_height`. | | `texture` | required | Any texture, stretched over the model's `texture_width` and `texture_height`. An object needs none. |
| `model` | none | An [entity model](#entity-models). Without one it's drawn as its texture, facing the camera. | | `model` | none | An [entity model](#entity-models). Without one it's drawn as its texture, facing the camera. |
| `behavior` | `"animal"` | `"animal"`, `"monster"`, `"scripted"`, or a [custom behavior](#custom-behaviors)'s id. | | `behavior` | `"animal"` | `"animal"`, `"monster"`, `"scripted"`, `"object"`, or a [custom behavior](#custom-behaviors)'s id. |
| `scale` | `1` | How much bigger it's drawn than its model, texture or item. Its box stays `width` and `height`. |
| `category` | see below | `"monster"` or `"creature"`, see [Natural Spawning](#natural-spawning). | | `category` | see below | `"monster"` or `"creature"`, see [Natural Spawning](#natural-spawning). |
| `width`, `height` | required | Its collision box in blocks, up to 16. `width` is for both x and z. Its eyes are at 85% of the height. | | `width`, `height` | required | Its collision box in blocks, up to 16. `width` is for both x and z. Its eyes are at 85% of the height. |
| `max_health` | `10` | In half hearts. | | `max_health` | `10` | In half hearts. |
@@ -92,6 +93,49 @@ the world, so a script never finds one it doesn't know about after a restart. Th
} }
``` ```
**Objects** lie around like a dropped item, holding one: they fall, slide and float in water the same way, but nobody
picks them up by walking into them, and they never despawn or merge. They can't be hurt, don't think, don't stop blocks
being placed where they are, and are saved with the world with what they hold. Without a `model`, an object is drawn as
its item: the item's [model](../resources/models.md#entity-models-as-items) at the size it's made, times `scale`, turned
the way the object faces.
An item lies around as an object instead of a dropped item when it names one as its
[`entity`](../items/index.md#properties), like NeoForge's `hasCustomEntity`. Every way an item ends up in the world
spawns the object holding it: thrown, dropped when its holder dies or when it doesn't fit, popped out of a broken block,
or a script's `spawn_item` or `drop_item`. Dangerous Business's scrap is one, picked up by right clicking it (see
[Interacting](#interacting)):
```json
{
"format_version": 1,
"entity": {
"id": "dangerous_business:scrap",
"behavior": "object",
"width": 0.7,
"height": 0.7,
"scale": 0.7
}
}
```
## Interacting
Right clicking an entity from up to 3 blocks away fires [`before.entity_interact`](../concepts/events.md#the-events),
like NeoForge's `PlayerInteractEvent.EntityInteract`. Its handlers do whatever the click does and cancel it, otherwise
the held item is used as if clicking nothing. A handler can also leave the entity be, like scrap with nowhere to go:
```ts
ctx.events.before.entity_interact.subscribe((event) => {
if (event.entity.type !== "dangerous_business:scrap") return;
event.cancel = true;
const item = event.entity.get_item();
const slot = [0, 1, 2, 3].find((slot) => event.player.inventory.get(slot) === undefined);
if (!item || slot === undefined) return;
event.player.inventory.set(slot, item);
event.entity.remove();
});
```
## Custom Behaviors ## Custom Behaviors
A mob can get its goals from a script instead, like NeoForge's `registerGoals`. Its json names a behavior id, and the A mob can get its goals from a script instead, like NeoForge's `registerGoals`. Its json names a behavior id, and the
@@ -288,8 +332,8 @@ interface EntityRef {
push(x: number, y: number, z: number): void; // adds to its velocity push(x: number, y: number, z: number): void; // adds to its velocity
remove(): void; remove(): void;
kill(cause?: string): void; // players and mobs die, anything else is removed kill(cause?: string): void; // players and mobs die, anything else is removed
get_item(): ItemStack | undefined; // for an item lying around, a copy get_item(): ItemStack | undefined; // for an item lying around or what an object holds, a copy
set_item(item: ItemStack | undefined): void; // for an item lying around, undefined takes it away set_item(item: ItemStack | undefined): void; // undefined takes an item lying around away, an object holds nothing
} }
``` ```
@@ -330,7 +374,8 @@ get the id `<mod id>:<name>`. From the file's first geometry, bworld uses:
- the description's `texture_width` and `texture_height`, - the description's `texture_width` and `texture_height`,
- each bone's `name`, `parent`, `pivot` and `rotation`, - each bone's `name`, `parent`, `pivot` and `rotation`,
- each cube's `origin`, `size`, `uv`, `inflate`, `pivot` and `rotation`. - each cube's `origin`, `size`, `uv`, `inflate`, `pivot` and `rotation`,
- `item_display_transforms`, for an [item drawn with it](../resources/models.md#entity-models-as-items).
Cubes can use box UV (`"uv": [u, v]`) or per face UV (`"uv": { "north": { "uv": [u, v], "uv_size": [w, h] }, ... }`), Cubes can use box UV (`"uv": [u, v]`) or per face UV (`"uv": { "north": { "uv": [u, v], "uv_size": [w, h] }, ... }`),
where a face that's left out isn't drawn and a negative size flips it. Faces are drawn from both sides, like Bedrock's where a face that's left out isn't drawn and a negative size flips it. Faces are drawn from both sides, like Bedrock's
+3 -2
View File
@@ -43,7 +43,7 @@ down to 0 is gone.
## Properties ## Properties
| Field | Default | Meaning | | Field | Default | Meaning |
| ----------------- | ------------------- | -------------------------------------------------------------------------------------- | | ----------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | required | The item's id. | | `id` | required | The item's id. |
| `texture` | required | The texture it's drawn with. Leave it out to [fill in a block's item](#block-items). | | `texture` | required | The texture it's drawn with. Leave it out to [fill in a block's item](#block-items). |
| `name` | from the id | What players see. `copper_tools:copper_ingot` is "Copper Ingot" when not set. | | `name` | from the id | What players see. `copper_tools:copper_ingot` is "Copper Ingot" when not set. |
@@ -54,8 +54,9 @@ down to 0 is gone.
| `tool` | none | Makes it a [tool](tools.md). | | `tool` | none | Makes it a [tool](tools.md). |
| `food` | none | Makes it [edible](food.md). | | `food` | none | Makes it [edible](food.md). |
| `data_textures` | none | Other textures, picked by the stack's `data`, see below. | | `data_textures` | none | Other textures, picked by the stack's `data`, see below. |
| `model` | none | A [model](../resources/models.md#item-models) it's drawn with instead of its texture. | | `model` | none | A [model](../resources/models.md#item-models) it's drawn with instead of its texture, or an [entity model](../resources/models.md#entity-models-as-items). |
| `worn` | none | How it looks worn on a player, see [below](#worn-models). | | `worn` | none | How it looks worn on a player, see [below](#worn-models). |
| `entity` | none | An [object](../entities/index.md#behaviors) it lies in the world as instead of a dropped item, holding the stack. |
| `targets_fluids` | `false` | Players holding it aim at fluids, like buckets and fishing rods. Others aim through. | | `targets_fluids` | `false` | Players holding it aim at fluids, like buckets and fishing rods. Others aim through. |
| `fluid_container` | none | Makes it hold a fluid, like a bucket, see [Fluids](../resources/fluids.md#containers). | | `fluid_container` | none | Makes it hold a fluid, like a bucket, see [Fluids](../resources/fluids.md#containers). |
| `layers` | none | Textures drawn over its own, each in a color, see [below](#layers). | | `layers` | none | Textures drawn over its own, each in a color, see [below](#layers). |
+11
View File
@@ -236,6 +236,17 @@ the same places Minecraft's do, so a transform made for Minecraft, like in Block
here. A model gets its parent's transform for each place it doesn't set its own. Minecraft's other places, like third here. A model gets its parent's transform for each place it doesn't set its own. Minecraft's other places, like third
person, aren't used. person, aren't used.
### Entity Models as Items
An item's `model` can also be an [entity model](../entities/index.md#entity-models), a `models/<name>.geo.json` made in
Blockbench, drawn in the item's own `texture` laid out for the model's `texture_width` and `texture_height`. It stands
in the middle of the block the way Blockbench shows it, 16 pixels to a block with its bottom at 0, and its faces are
shaded like a block model's. Its pose is the one in the file, bones aren't animated.
Its display transforms are the geometry's `item_display_transforms`, which Blockbench's Display tab writes for the
"Bedrock Block" format. Only `rotation`, `translation` and `scale` of the places above are used: `rotation_pivot`,
`scale_pivot` and `fit_to_frame` aren't.
## Lighting ## Lighting
Faces flat against the block's edge get smooth lighting and ambient occlusion like a full block's. Anything inside the Faces flat against the block's edge get smooth lighting and ambient occlusion like a full block's. Anything inside the
+10
View File
@@ -0,0 +1,10 @@
{
"format_version": 1,
"block": {
"id": "dangerous_business:chain",
"textures": { "chain": "dangerous_business:iron_chain" },
"model": "dangerous_business:chain",
"render_layer": "cutout",
"shape": [[6.5, 0, 6.5, 9.5, 16, 9.5]]
}
}
@@ -0,0 +1,62 @@
{
"format_version": 1,
"block": {
"id": "dangerous_business:deepslate_tile_wall",
"textures": {
"wall": "dangerous_business:deepslate_tiles"
},
"render_layer": "cutout",
"item_model": "dangerous_business:wall_inventory",
"states": [
{
"name": "north",
"bits": 1,
"default": 0
},
{
"name": "east",
"bits": 1,
"default": 0
},
{
"name": "south",
"bits": 1,
"default": 0
},
{
"name": "west",
"bits": 1,
"default": 0
}
],
"parts": [
{
"model": "dangerous_business:template_wall_post"
},
{
"when": "north=1",
"model": "dangerous_business:template_wall_side"
},
{
"when": "east=1",
"model": "dangerous_business:template_wall_side",
"y": 90
},
{
"when": "south=1",
"model": "dangerous_business:template_wall_side",
"y": 180
},
{
"when": "west=1",
"model": "dangerous_business:template_wall_side",
"y": 270
}
],
"components": {
"dangerous_business:connects": {
"solid": true
}
}
}
}
@@ -0,0 +1,81 @@
{
"format_version": 1,
"block": {
"id": "dangerous_business:iron_bars",
"textures": {
"pane": "dangerous_business:iron_bars",
"edge": "dangerous_business:iron_bars"
},
"render_layer": "cutout",
"states": [
{
"name": "north",
"bits": 1,
"default": 0
},
{
"name": "east",
"bits": 1,
"default": 0
},
{
"name": "south",
"bits": 1,
"default": 0
},
{
"name": "west",
"bits": 1,
"default": 0
}
],
"parts": [
{
"model": "dangerous_business:template_glass_pane_post"
},
{
"when": "north=1",
"model": "dangerous_business:template_glass_pane_side"
},
{
"when": "north=0",
"model": "dangerous_business:template_glass_pane_noside"
},
{
"when": "east=1",
"model": "dangerous_business:template_glass_pane_side",
"y": 90
},
{
"when": "east=0",
"model": "dangerous_business:template_glass_pane_noside",
"y": 90
},
{
"when": "south=1",
"model": "dangerous_business:template_glass_pane_side",
"y": 180
},
{
"when": "south=0",
"model": "dangerous_business:template_glass_pane_noside",
"y": 180
},
{
"when": "west=1",
"model": "dangerous_business:template_glass_pane_side",
"y": 270
},
{
"when": "west=0",
"model": "dangerous_business:template_glass_pane_noside",
"y": 270
}
],
"components": {
"dangerous_business:connects": {
"solid": true
}
}
}
}
@@ -0,0 +1,7 @@
{
"format_version": 1,
"block": {
"id": "dangerous_business:iron_block",
"textures": "dangerous_business:iron_block"
}
}
@@ -0,0 +1,7 @@
{
"format_version": 1,
"block": {
"id": "dangerous_business:polished_andesite",
"textures": "dangerous_business:polished_andesite"
}
}
@@ -0,0 +1,71 @@
{
"format_version": 1,
"block": {
"id": "dangerous_business:purpur_stairs",
"textures": "dangerous_business:purpur_block",
"render_layer": "cutout",
"model": "dangerous_business:empty",
"item_model": "dangerous_business:stairs",
"shape": [
[
0,
0,
0,
16,
8,
16
],
[
8,
8,
0,
16,
16,
16
]
],
"states": [
{
"name": "facing",
"bits": 2,
"default": 0
},
{
"name": "half",
"bits": 1,
"default": 0
}
],
"variants": {
"facing=0": {
"y": 270
},
"facing=2": {
"y": 90
},
"facing=3": {
"y": 180
},
"half=1": {
"shape": [
[
0,
8,
0,
16,
16,
16
],
[
8,
0,
0,
16,
8,
16
]
]
}
}
}
}
@@ -0,0 +1,58 @@
{
"format_version": 1,
"block": {
"id": "dangerous_business:smooth_sandstone_stairs",
"textures": "dangerous_business:smooth_sandstone",
"render_layer": "cutout",
"model": "dangerous_business:stairs",
"item_model": "dangerous_business:stairs",
"states": [
{
"name": "facing",
"bits": 2,
"default": 0
},
{
"name": "half",
"bits": 1,
"default": 0
}
],
"variants": {
"facing=0": {
"y": 270,
"uvlock": true
},
"facing=2": {
"y": 90,
"uvlock": true
},
"facing=3": {
"y": 180,
"uvlock": true
},
"half=1": {
"x": 180,
"uvlock": true,
"shape": [
[
0,
8,
0,
16,
16,
16
],
[
8,
0,
0,
16,
8,
16
]
]
}
}
}
}
@@ -0,0 +1,163 @@
{
"format_version": 1,
"block": {
"id": "dangerous_business:spruce_fence",
"textures": {
"side": "dangerous_business:spruce_fence_side",
"top": "dangerous_business:spruce_fence_side"
},
"item_model": "dangerous_business:fence_inventory",
"render_layer": "cutout",
"states": [
{
"name": "north",
"bits": 1,
"default": 0
},
{
"name": "east",
"bits": 1,
"default": 0
},
{
"name": "south",
"bits": 1,
"default": 0
},
{
"name": "west",
"bits": 1,
"default": 0
}
],
"parts": [
{
"model": "dangerous_business:fence_post",
"shape": [
[
6,
0,
6,
10,
16,
10
]
],
"collision_shape": [
[
6,
0,
6,
10,
24,
10
]
]
},
{
"when": "north=1",
"model": "dangerous_business:fence_side",
"shape": [
[
7,
0,
0,
9,
16,
9
]
],
"collision_shape": [
[
7,
0,
0,
9,
24,
9
]
]
},
{
"when": "east=1",
"model": "dangerous_business:fence_side",
"shape": [
[
7,
0,
0,
9,
16,
9
]
],
"collision_shape": [
[
7,
0,
0,
9,
24,
9
]
],
"y": 90
},
{
"when": "south=1",
"model": "dangerous_business:fence_side",
"shape": [
[
7,
0,
0,
9,
16,
9
]
],
"collision_shape": [
[
7,
0,
0,
9,
24,
9
]
],
"y": 180
},
{
"when": "west=1",
"model": "dangerous_business:fence_side",
"shape": [
[
7,
0,
0,
9,
16,
9
]
],
"collision_shape": [
[
7,
0,
0,
9,
24,
9
]
],
"y": 270
}
],
"components": {
"dangerous_business:connects": {
"solid": true
}
}
}
}
@@ -0,0 +1,38 @@
{
"format_version": 1,
"block": {
"id": "dangerous_business:stair_rail_collision",
"textures": "cubi:missing",
"render_layer": "cutout",
"model": "dangerous_business:empty",
"item_model": "cubi:cube",
"shape": [
[
0,
0,
14,
16,
16,
16
]
],
"states": [
{
"name": "facing",
"bits": 2,
"default": 0
}
],
"variants": {
"facing=0": {
"y": 180
},
"facing=1": {
"y": 270
},
"facing=3": {
"y": 90
}
}
}
}
+33 -1
View File
@@ -8,15 +8,47 @@
"render_layer": "cutout", "render_layer": "cutout",
"model": "dangerous_business:tiny_pipe", "model": "dangerous_business:tiny_pipe",
"item_model": "dangerous_business:tiny_pipe", "item_model": "dangerous_business:tiny_pipe",
"shape": [[7, 0, 7, 9, 16, 9]], "shape": [
[
7,
0,
7,
9,
16,
9
]
],
"components": {
"dangerous_business:pipe": {}
},
"states": [ "states": [
{ {
"name": "facing", "name": "facing",
"bits": 2, "bits": 2,
"default": 0 "default": 0
},
{
"name": "horizontal",
"bits": 1,
"default": 0
} }
], ],
"variants": { "variants": {
"horizontal=1,facing=0": {
"x": 90
},
"horizontal=1,facing=1": {
"x": 90,
"y": 90
},
"horizontal=1,facing=2": {
"x": 90,
"y": 180
},
"horizontal=1,facing=3": {
"x": 90,
"y": 270
},
"facing=0": { "facing=0": {
"y": 180 "y": 180
}, },
@@ -8,7 +8,16 @@
"render_layer": "cutout", "render_layer": "cutout",
"model": "dangerous_business:tiny_pipe_curve", "model": "dangerous_business:tiny_pipe_curve",
"item_model": "dangerous_business:tiny_pipe_curve", "item_model": "dangerous_business:tiny_pipe_curve",
"shape": [[7, 0, 0, 9, 9, 9]], "shape": [
[
7,
7,
0,
9,
16,
9
]
],
"states": [ "states": [
{ {
"name": "facing", "name": "facing",
@@ -8,7 +8,16 @@
"render_layer": "cutout", "render_layer": "cutout",
"model": "dangerous_business:tiny_pipe_curve4", "model": "dangerous_business:tiny_pipe_curve4",
"item_model": "dangerous_business:tiny_pipe_curve4", "item_model": "dangerous_business:tiny_pipe_curve4",
"shape": [[7, 0, 0, 16, 9, 9]], "shape": [
[
7,
7,
0,
16,
16,
9
]
],
"states": [ "states": [
{ {
"name": "facing", "name": "facing",
@@ -0,0 +1,10 @@
{
"format_version": 1,
"entity": {
"id": "dangerous_business:scrap",
"behavior": "object",
"width": 0.7,
"height": 0.7,
"scale": 0.7
}
}
@@ -0,0 +1,10 @@
{
"format_version": 1,
"item": {
"id": "dangerous_business:air_horn",
"texture": "dangerous_business:air_horn",
"model": "dangerous_business:air_horn",
"entity": "dangerous_business:scrap",
"max_stack": 1
}
}
@@ -23,10 +23,37 @@
"parent": "root", "parent": "root",
"pivot": [-2, 5, 7], "pivot": [-2, 5, 7],
"cubes": [ "cubes": [
{"origin": [-0.5, 1, -8], "size": [1, 0, 10], "pivot": [0, 5, -3], "rotation": [0, 0, -90], "uv": [14, 0]}, {
{"origin": [-0.5, 1, -8], "size": [1, 0, 10], "pivot": [0, 5, -3], "rotation": [0, 0, 90], "uv": [14, 0], "mirror": true}, "origin": [-0.5, 1, -8],
{"origin": [-0.5, 1, -8], "size": [1, 0, 10], "pivot": [0, 5, -3], "rotation": [0, 0, -180], "uv": [14, 0], "mirror": true}, "size": [1, 0, 10],
{"origin": [-0.5, 9, -8], "size": [1, 0, 10], "pivot": [0, 5, -3], "rotation": [0, 0, 180], "uv": [14, 0], "mirror": true}, "pivot": [0, 5, -3],
"rotation": [0, 0, -90],
"uv": [14, 0]
},
{
"origin": [-0.5, 1, -8],
"size": [1, 0, 10],
"pivot": [0, 5, -3],
"rotation": [0, 0, 90],
"uv": [14, 0],
"mirror": true
},
{
"origin": [-0.5, 1, -8],
"size": [1, 0, 10],
"pivot": [0, 5, -3],
"rotation": [0, 0, -180],
"uv": [14, 0],
"mirror": true
},
{
"origin": [-0.5, 9, -8],
"size": [1, 0, 10],
"pivot": [0, 5, -3],
"rotation": [0, 0, 180],
"uv": [14, 0],
"mirror": true
},
{ "origin": [1, 6, 6], "size": [1, 1, 4], "uv": [30, 0] }, { "origin": [1, 6, 6], "size": [1, 1, 4], "uv": [30, 0] },
{ "origin": [-2, 6, 6], "size": [1, 1, 4], "uv": [30, 0] } { "origin": [-2, 6, 6], "size": [1, 1, 4], "uv": [30, 0] }
] ]
@@ -19,7 +19,13 @@
{ "origin": [6, 9, -1], "size": [1, 2, 2], "uv": [0, 0] }, { "origin": [6, 9, -1], "size": [1, 2, 2], "uv": [0, 0] },
{ "origin": [-6, 10, -1], "size": [12, 1, 2], "uv": [0, 17] }, { "origin": [-6, 10, -1], "size": [12, 1, 2], "uv": [0, 17] },
{ "origin": [-8, 0, -4], "size": [16, 9, 8], "uv": [0, 0] }, { "origin": [-8, 0, -4], "size": [16, 9, 8], "uv": [0, 0] },
{"origin": [1.425, 7.75, 3], "size": [5, 10, 0], "pivot": [5.5, 14, 3], "rotation": [-8.90928, -8.80348, -24.31282], "uv": [0, 20]} {
"origin": [1.425, 7.75, 3],
"size": [5, 10, 0],
"pivot": [5.5, 14, 3],
"rotation": [-8.90928, -8.80348, -24.31282],
"uv": [0, 20]
}
] ]
} }
] ]
@@ -26,7 +26,14 @@
"cubes": [ "cubes": [
{ "origin": [-7.4, 8.3, -4.4], "size": [2, 1, 2], "uv": [0, 6] }, { "origin": [-7.4, 8.3, -4.4], "size": [2, 1, 2], "uv": [0, 6] },
{ "origin": [-7.9, 0.1, -4.9], "size": [3, 5, 3], "uv": [0, 18] }, { "origin": [-7.9, 0.1, -4.9], "size": [3, 5, 3], "uv": [0, 18] },
{"origin": [-7.7, 4.7, -3.9], "size": [2, 4, 2], "inflate": -0.4, "pivot": [-7.2, 8.2, -3.5], "rotation": [0, 45, 0], "uv": [0, 0]} {
"origin": [-7.7, 4.7, -3.9],
"size": [2, 4, 2],
"inflate": -0.4,
"pivot": [-7.2, 8.2, -3.5],
"rotation": [0, 45, 0],
"uv": [0, 0]
}
] ]
}, },
{ {
@@ -37,7 +44,14 @@
"cubes": [ "cubes": [
{ "origin": [-3.9, 8.3, -4.4], "size": [2, 1, 2], "uv": [0, 6] }, { "origin": [-3.9, 8.3, -4.4], "size": [2, 1, 2], "uv": [0, 6] },
{ "origin": [-4.4, 0.1, -4.9], "size": [3, 5, 3], "uv": [0, 18] }, { "origin": [-4.4, 0.1, -4.9], "size": [3, 5, 3], "uv": [0, 18] },
{"origin": [-4.2, 4.7, -3.9], "size": [2, 4, 2], "inflate": -0.4, "pivot": [-3.7, 8.2, -3.5], "rotation": [0, 45, 0], "uv": [0, 0]} {
"origin": [-4.2, 4.7, -3.9],
"size": [2, 4, 2],
"inflate": -0.4,
"pivot": [-3.7, 8.2, -3.5],
"rotation": [0, 45, 0],
"uv": [0, 0]
}
] ]
}, },
{ {
@@ -47,7 +61,14 @@
"cubes": [ "cubes": [
{ "origin": [-0.5, 8.3, -4.4], "size": [2, 1, 2], "uv": [0, 6] }, { "origin": [-0.5, 8.3, -4.4], "size": [2, 1, 2], "uv": [0, 6] },
{ "origin": [-1, 0.1, -4.9], "size": [3, 5, 3], "uv": [0, 18] }, { "origin": [-1, 0.1, -4.9], "size": [3, 5, 3], "uv": [0, 18] },
{"origin": [-0.8, 4.7, -3.9], "size": [2, 4, 2], "inflate": -0.4, "pivot": [-0.3, 8.2, -3.5], "rotation": [0, 45, 0], "uv": [0, 0]} {
"origin": [-0.8, 4.7, -3.9],
"size": [2, 4, 2],
"inflate": -0.4,
"pivot": [-0.3, 8.2, -3.5],
"rotation": [0, 45, 0],
"uv": [0, 0]
}
] ]
}, },
{ {
@@ -58,7 +79,14 @@
"cubes": [ "cubes": [
{ "origin": [3.2, 8.4, -4.2], "size": [2, 1, 2], "uv": [0, 6] }, { "origin": [3.2, 8.4, -4.2], "size": [2, 1, 2], "uv": [0, 6] },
{ "origin": [2.7, 0.2, -4.7], "size": [3, 5, 3], "uv": [0, 18] }, { "origin": [2.7, 0.2, -4.7], "size": [3, 5, 3], "uv": [0, 18] },
{"origin": [2.9, 4.8, -3.7], "size": [2, 4, 2], "inflate": -0.4, "pivot": [3.4, 8.3, -3.3], "rotation": [0, 45, 0], "uv": [0, 0]} {
"origin": [2.9, 4.8, -3.7],
"size": [2, 4, 2],
"inflate": -0.4,
"pivot": [3.4, 8.3, -3.3],
"rotation": [0, 45, 0],
"uv": [0, 0]
}
] ]
}, },
{ {
@@ -69,7 +97,14 @@
"cubes": [ "cubes": [
{ "origin": [-5.8, 4.3, -0.4], "size": [2, 1, 2], "uv": [0, 6] }, { "origin": [-5.8, 4.3, -0.4], "size": [2, 1, 2], "uv": [0, 6] },
{ "origin": [-6.3, -3.9, -0.9], "size": [3, 5, 3], "uv": [0, 18] }, { "origin": [-6.3, -3.9, -0.9], "size": [3, 5, 3], "uv": [0, 18] },
{"origin": [-6.1, 0.7, 0.1], "size": [2, 4, 2], "inflate": -0.4, "pivot": [-5.6, 4.2, 0.5], "rotation": [0, 45, 0], "uv": [0, 0]} {
"origin": [-6.1, 0.7, 0.1],
"size": [2, 4, 2],
"inflate": -0.4,
"pivot": [-5.6, 4.2, 0.5],
"rotation": [0, 45, 0],
"uv": [0, 0]
}
] ]
}, },
{ {
@@ -80,7 +115,14 @@
"cubes": [ "cubes": [
{ "origin": [0.2, 8.4, -0.4], "size": [2, 1, 2], "uv": [0, 6] }, { "origin": [0.2, 8.4, -0.4], "size": [2, 1, 2], "uv": [0, 6] },
{ "origin": [-0.3, 0.2, -0.9], "size": [3, 5, 3], "uv": [0, 18] }, { "origin": [-0.3, 0.2, -0.9], "size": [3, 5, 3], "uv": [0, 18] },
{"origin": [-0.1, 4.8, 0.1], "size": [2, 4, 2], "inflate": -0.4, "pivot": [0.4, 8.3, 0.5], "rotation": [0, 45, 0], "uv": [0, 0]} {
"origin": [-0.1, 4.8, 0.1],
"size": [2, 4, 2],
"inflate": -0.4,
"pivot": [0.4, 8.3, 0.5],
"rotation": [0, 45, 0],
"uv": [0, 0]
}
] ]
}, },
{ {
@@ -91,7 +133,14 @@
"cubes": [ "cubes": [
{ "origin": [-6.8, 8.3, 1.6], "size": [2, 1, 2], "uv": [0, 6] }, { "origin": [-6.8, 8.3, 1.6], "size": [2, 1, 2], "uv": [0, 6] },
{ "origin": [-7.3, 0.1, 1.1], "size": [3, 5, 3], "uv": [0, 18] }, { "origin": [-7.3, 0.1, 1.1], "size": [3, 5, 3], "uv": [0, 18] },
{"origin": [-7.1, 4.7, 2.1], "size": [2, 4, 2], "inflate": -0.4, "pivot": [-6.6, 8.2, 2.5], "rotation": [0, 45, 0], "uv": [0, 0]} {
"origin": [-7.1, 4.7, 2.1],
"size": [2, 4, 2],
"inflate": -0.4,
"pivot": [-6.6, 8.2, 2.5],
"rotation": [0, 45, 0],
"uv": [0, 0]
}
] ]
}, },
{ {
@@ -102,7 +151,14 @@
"cubes": [ "cubes": [
{ "origin": [4.2, 8.3, 0.6], "size": [2, 1, 2], "uv": [0, 6] }, { "origin": [4.2, 8.3, 0.6], "size": [2, 1, 2], "uv": [0, 6] },
{ "origin": [3.7, 0.1, 0.1], "size": [3, 5, 3], "uv": [0, 18] }, { "origin": [3.7, 0.1, 0.1], "size": [3, 5, 3], "uv": [0, 18] },
{"origin": [3.9, 4.7, 1.1], "size": [2, 4, 2], "inflate": -0.4, "pivot": [4.4, 8.2, 1.5], "rotation": [0, 45, 0], "uv": [0, 0]} {
"origin": [3.9, 4.7, 1.1],
"size": [2, 4, 2],
"inflate": -0.4,
"pivot": [4.4, 8.2, 1.5],
"rotation": [0, 45, 0],
"uv": [0, 0]
}
] ]
} }
] ]
@@ -16,10 +16,29 @@
"pivot": [0, 0, 0], "pivot": [0, 0, 0],
"cubes": [ "cubes": [
{ "origin": [-8, 3, 5], "size": [16, 12, 3], "inflate": 0.01, "uv": [0, 41] }, { "origin": [-8, 3, 5], "size": [16, 12, 3], "inflate": 0.01, "uv": [0, 41] },
{"origin": [8, 5, 3], "size": [1, 3, 3], "pivot": [8.5, 6.5, 4.5], "rotation": [-45, 0, 0], "uv": [48, 33]}, {
"origin": [8, 5, 3],
"size": [1, 3, 3],
"pivot": [8.5, 6.5, 4.5],
"rotation": [-45, 0, 0],
"uv": [48, 33]
},
{ "origin": [-8, 3, 0], "size": [16, 6, 5], "inflate": 0.01, "uv": [38, 41] }, { "origin": [-8, 3, 0], "size": [16, 6, 5], "inflate": 0.01, "uv": [38, 41] },
{"origin": [-8, 9, 0], "size": [16, 3, 5], "inflate": 0.0002, "pivot": [8, 12, 5], "rotation": [25, 0, 0], "uv": [48, 17]}, {
{"origin": [-8, 5.88691, -7.78154], "size": [16, 4, 8.25], "pivot": [8, 9.88691, 0.46846], "rotation": [57.5, 0, 0], "uv": [0, 17]}, "origin": [-8, 9, 0],
"size": [16, 3, 5],
"inflate": 0.0002,
"pivot": [8, 12, 5],
"rotation": [25, 0, 0],
"uv": [48, 17]
},
{
"origin": [-8, 5.88691, -7.78154],
"size": [16, 4, 8.25],
"pivot": [8, 9.88691, 0.46846],
"rotation": [57.5, 0, 0],
"uv": [0, 17]
},
{ "origin": [-8, 0, -6], "size": [16, 3, 14], "inflate": 0.01, "uv": [0, 0] } { "origin": [-8, 0, -6], "size": [16, 3, 14], "inflate": 0.01, "uv": [0, 0] }
] ]
}, },
@@ -31,7 +50,13 @@
"cubes": [ "cubes": [
{ "origin": [9, 5.81915, 4.57358], "size": [2, 1, 1], "uv": [48, 39] }, { "origin": [9, 5.81915, 4.57358], "size": [2, 1, 1], "uv": [48, 39] },
{ "origin": [10, 5.81915, 1.57358], "size": [1, 1, 3], "uv": [38, 52] }, { "origin": [10, 5.81915, 1.57358], "size": [1, 1, 3], "uv": [38, 52] },
{"origin": [9.21367, 4.47212, -1.42642], "size": [1.5, 1.5, 3], "pivot": [11.5, 5.1, -0.5], "rotation": [0, 0, 45], "uv": [46, 52]} {
"origin": [9.21367, 4.47212, -1.42642],
"size": [1.5, 1.5, 3],
"pivot": [11.5, 5.1, -0.5],
"rotation": [0, 0, 45],
"uv": [46, 52]
}
] ]
}, },
{ {
@@ -39,8 +64,22 @@
"parent": "cash_register", "parent": "cash_register",
"pivot": [8, 9.88691, 0.46846], "pivot": [8, 9.88691, 0.46846],
"cubes": [ "cubes": [
{"origin": [-8, 9, 0], "size": [16, 3, 5], "inflate": 0.1, "pivot": [8, 12, 5], "rotation": [25, 0, 0], "uv": [48, 25]}, {
{"origin": [-8, 5.79721, -7.88382], "size": [16, 4, 8.25], "inflate": 0.1, "pivot": [8, 9.79721, 0.36618], "rotation": [57.5, 0, 0], "uv": [0, 29]} "origin": [-8, 9, 0],
"size": [16, 3, 5],
"inflate": 0.1,
"pivot": [8, 12, 5],
"rotation": [25, 0, 0],
"uv": [48, 25]
},
{
"origin": [-8, 5.79721, -7.88382],
"size": [16, 4, 8.25],
"inflate": 0.1,
"pivot": [8, 9.79721, 0.36618],
"rotation": [57.5, 0, 0],
"uv": [0, 29]
}
] ]
} }
] ]
+28
View File
@@ -0,0 +1,28 @@
{
"format_version": 1,
"model": {
"id": "dangerous_business:chain",
"elements": [
{
"from": [6.5, 0, 8],
"to": [9.5, 16, 8],
"rotation": { "origin": [8, 8, 8], "axis": "y", "angle": 45 },
"shade": false,
"faces": {
"north": { "texture": "#chain", "uv": [3, 0, 0, 16] },
"south": { "texture": "#chain", "uv": [0, 0, 3, 16] }
}
},
{
"from": [8, 0, 6.5],
"to": [8, 16, 9.5],
"rotation": { "origin": [8, 8, 8], "axis": "y", "angle": 45 },
"shade": false,
"faces": {
"east": { "texture": "#chain", "uv": [3, 0, 6, 16] },
"west": { "texture": "#chain", "uv": [6, 0, 3, 16] }
}
}
]
}
}
@@ -16,7 +16,13 @@
"pivot": [0, 1.94847, 2.69906], "pivot": [0, 1.94847, 2.69906],
"rotation": [-87.5, 0, 0], "rotation": [-87.5, 0, 0],
"cubes": [ "cubes": [
{"origin": [-1, -15.2182, 1.69906], "size": [2, 16, 2], "pivot": [0, -9.6182, 2.69906], "rotation": [0, -45, 0], "uv": [0, 12]}, {
"origin": [-1, -15.2182, 1.69906],
"size": [2, 16, 2],
"pivot": [0, -9.6182, 2.69906],
"rotation": [0, -45, 0],
"uv": [0, 12]
},
{ "origin": [0, 0.7818, 2.19906], "size": [0, 5, 1], "uv": [8, 11] }, { "origin": [0, 0.7818, 2.19906], "size": [0, 5, 1], "uv": [8, 11] },
{ "origin": [-2, 5.7818, 0.69906], "size": [4, 8, 4], "uv": [0, 0] } { "origin": [-2, 5.7818, 0.69906], "size": [4, 8, 4], "uv": [0, 0] }
] ]
@@ -0,0 +1,280 @@
{
"format_version": 1,
"model": {
"id": "dangerous_business:fence_inventory",
"elements": [
{
"from": [
6,
0,
0
],
"to": [
10,
16,
4
],
"faces": {
"north": {
"texture": "#side",
"uv": [
6,
0,
10,
16
]
},
"south": {
"texture": "#side",
"uv": [
6,
0,
10,
16
]
},
"east": {
"texture": "#side",
"uv": [
6,
0,
10,
16
]
},
"west": {
"texture": "#side",
"uv": [
6,
0,
10,
16
]
},
"top": {
"texture": "#top",
"uv": [
6,
6,
10,
10
]
},
"bottom": {
"texture": "#top",
"uv": [
6,
6,
10,
10
]
}
}
},
{
"from": [
6,
0,
12
],
"to": [
10,
16,
16
],
"faces": {
"north": {
"texture": "#side",
"uv": [
6,
0,
10,
16
]
},
"south": {
"texture": "#side",
"uv": [
6,
0,
10,
16
]
},
"east": {
"texture": "#side",
"uv": [
6,
0,
10,
16
]
},
"west": {
"texture": "#side",
"uv": [
6,
0,
10,
16
]
},
"top": {
"texture": "#top",
"uv": [
6,
6,
10,
10
]
},
"bottom": {
"texture": "#top",
"uv": [
6,
6,
10,
10
]
}
}
},
{
"from": [
7,
12,
0
],
"to": [
9,
15,
16
],
"faces": {
"north": {
"texture": "#side",
"uv": [
7,
1,
9,
4
]
},
"south": {
"texture": "#side",
"uv": [
7,
1,
9,
4
]
},
"east": {
"texture": "#side",
"uv": [
0,
1,
16,
4
]
},
"west": {
"texture": "#side",
"uv": [
0,
1,
16,
4
]
},
"top": {
"texture": "#top",
"uv": [
7,
0,
9,
16
]
},
"bottom": {
"texture": "#top",
"uv": [
7,
0,
9,
16
]
}
}
},
{
"from": [
7,
6,
0
],
"to": [
9,
9,
16
],
"faces": {
"north": {
"texture": "#side",
"uv": [
7,
7,
9,
10
]
},
"south": {
"texture": "#side",
"uv": [
7,
7,
9,
10
]
},
"east": {
"texture": "#side",
"uv": [
0,
7,
16,
10
]
},
"west": {
"texture": "#side",
"uv": [
0,
7,
16,
10
]
},
"top": {
"texture": "#top",
"uv": [
7,
0,
9,
16
]
},
"bottom": {
"texture": "#top",
"uv": [
7,
0,
9,
16
]
}
}
}
]
}
}
@@ -0,0 +1,78 @@
{
"format_version": 1,
"model": {
"id": "dangerous_business:fence_post",
"elements": [
{
"from": [
6,
0,
6
],
"to": [
10,
16,
10
],
"faces": {
"north": {
"texture": "#side",
"uv": [
6,
0,
10,
16
]
},
"east": {
"texture": "#side",
"uv": [
6,
0,
10,
16
]
},
"south": {
"texture": "#side",
"uv": [
6,
0,
10,
16
]
},
"west": {
"texture": "#side",
"uv": [
6,
0,
10,
16
]
},
"top": {
"texture": "#top",
"uv": [
6,
6,
10,
10
],
"cullface": "top"
},
"bottom": {
"texture": "#top",
"uv": [
6,
6,
10,
10
],
"cullface": "bottom"
}
}
}
]
}
}
@@ -0,0 +1,128 @@
{
"format_version": 1,
"model": {
"id": "dangerous_business:fence_side",
"elements": [
{
"from": [
7,
12,
0
],
"to": [
9,
15,
9
],
"faces": {
"north": {
"texture": "#side",
"uv": [
7,
1,
9,
4
],
"cullface": "north"
},
"east": {
"texture": "#side",
"uv": [
7,
1,
16,
4
]
},
"west": {
"texture": "#side",
"uv": [
0,
1,
9,
4
]
},
"top": {
"texture": "#top",
"uv": [
7,
0,
9,
9
]
},
"bottom": {
"texture": "#top",
"uv": [
7,
0,
9,
9
]
}
}
},
{
"from": [
7,
6,
0
],
"to": [
9,
9,
9
],
"faces": {
"north": {
"texture": "#side",
"uv": [
7,
7,
9,
10
],
"cullface": "north"
},
"east": {
"texture": "#side",
"uv": [
7,
7,
16,
10
]
},
"west": {
"texture": "#side",
"uv": [
0,
7,
9,
10
]
},
"top": {
"texture": "#top",
"uv": [
7,
0,
9,
9
]
},
"bottom": {
"texture": "#top",
"uv": [
7,
0,
9,
9
]
}
}
}
]
}
}
@@ -15,10 +15,34 @@
"name": "flashlight", "name": "flashlight",
"pivot": [0, 1, 0], "pivot": [0, 1, 0],
"cubes": [ "cubes": [
{"origin": [-1, 1, -4], "size": [2, 2, 7], "pivot": [0, 2, 0], "rotation": [0, 0, 45], "uv": [0, 0]}, {
{"origin": [-1.5, 0.5, -6], "size": [3, 3, 4], "pivot": [0, 2, 0], "rotation": [0, 0, 45], "uv": [0, 9]}, "origin": [-1, 1, -4],
{"origin": [-1.5, 0.5, -7], "size": [3, 3, 1], "pivot": [0, 2, 0], "rotation": [0, 0, 45], "uv": [24, 0]}, "size": [2, 2, 7],
{"origin": [-1.5, 0.5, 2], "size": [3, 3, 2], "pivot": [0, 2, 0], "rotation": [0, 0, 45], "uv": [11, 0]} "pivot": [0, 2, 0],
"rotation": [0, 0, 45],
"uv": [0, 0]
},
{
"origin": [-1.5, 0.5, -6],
"size": [3, 3, 4],
"pivot": [0, 2, 0],
"rotation": [0, 0, 45],
"uv": [0, 9]
},
{
"origin": [-1.5, 0.5, -7],
"size": [3, 3, 1],
"pivot": [0, 2, 0],
"rotation": [0, 0, 45],
"uv": [24, 0]
},
{
"origin": [-1.5, 0.5, 2],
"size": [3, 3, 2],
"pivot": [0, 2, 0],
"rotation": [0, 0, 45],
"uv": [11, 0]
}
] ]
}, },
{ {
+16 -2
View File
@@ -16,8 +16,22 @@
"pivot": [0, 0, 0], "pivot": [0, 0, 0],
"cubes": [ "cubes": [
{ "origin": [-3, 0, -3], "size": [6, 6, 6], "uv": [0, 0] }, { "origin": [-3, 0, -3], "size": [6, 6, 6], "uv": [0, 0] },
{"origin": [-1, 6.2, -1], "size": [2, 4, 2], "inflate": 0.2, "pivot": [0, 8.5, 0], "rotation": [0, 45, 0], "uv": [12, 12]}, {
{"origin": [-1.5, 10.6, -1.5], "size": [3, 2, 3], "inflate": 0.2, "pivot": [0, 8.5, 0], "rotation": [0, 45, 0], "uv": [0, 12]} "origin": [-1, 6.2, -1],
"size": [2, 4, 2],
"inflate": 0.2,
"pivot": [0, 8.5, 0],
"rotation": [0, 45, 0],
"uv": [12, 12]
},
{
"origin": [-1.5, 10.6, -1.5],
"size": [3, 2, 3],
"inflate": 0.2,
"pivot": [0, 8.5, 0],
"rotation": [0, 45, 0],
"uv": [0, 12]
}
] ]
} }
] ]
+84 -12
View File
@@ -32,18 +32,90 @@
"pivot": [0, 6, 0], "pivot": [0, 6, 0],
"rotation": [0, -22.5, 0], "rotation": [0, -22.5, 0],
"cubes": [ "cubes": [
{"origin": [0, 6, -1], "size": [0, 3, 2], "pivot": [0, 6, 0], "rotation": [0, 0, -45], "uv": [23, 1]}, {
{"origin": [-0.12124, 5.90481, -1], "size": [0, 3, 2], "pivot": [0, 6, 0], "rotation": [0, 0, -62], "uv": [25, 6]}, "origin": [0, 6, -1],
{"origin": [-0.22354, 8.89778, -1], "size": [1, 0, 2], "pivot": [0, 6, 0], "rotation": [0, 0, -60], "uv": [19, 4]}, "size": [0, 3, 2],
{"origin": [0, 6, -1], "size": [0, 3, 2], "pivot": [0, 6, 0], "rotation": [-90, 45, -90], "uv": [23, 1]}, "pivot": [0, 6, 0],
{"origin": [-0.12124, 5.90481, -1], "size": [0, 3, 2], "pivot": [0, 6, 0], "rotation": [-90, 28, -90], "uv": [25, 6]}, "rotation": [0, 0, -45],
{"origin": [-0.22354, 8.89778, -1], "size": [1, 0, 2], "pivot": [0, 6, 0], "rotation": [-90, 30, -90], "uv": [19, 4]}, "uv": [23, 1]
{"origin": [0, 6, -1], "size": [0, 3, 2], "pivot": [0, 6, 0], "rotation": [180, 0, -135], "uv": [23, 1]}, },
{"origin": [-0.12124, 5.90481, -1], "size": [0, 3, 2], "pivot": [0, 6, 0], "rotation": [-180, 0, -118], "uv": [25, 6]}, {
{"origin": [-0.22354, 8.89778, -1], "size": [1, 0, 2], "pivot": [0, 6, 0], "rotation": [-180, 0, -120], "uv": [19, 4]}, "origin": [-0.12124, 5.90481, -1],
{"origin": [0, 6, -1], "size": [0, 3, 2], "pivot": [0, 6, 0], "rotation": [90, -45, -90], "uv": [23, 1]}, "size": [0, 3, 2],
{"origin": [-0.12124, 5.90481, -1], "size": [0, 3, 2], "pivot": [0, 6, 0], "rotation": [90, -28, -90], "uv": [25, 6]}, "pivot": [0, 6, 0],
{"origin": [-0.22354, 8.89778, -1], "size": [1, 0, 2], "pivot": [0, 6, 0], "rotation": [90, -30, -90], "uv": [19, 4]} "rotation": [0, 0, -62],
"uv": [25, 6]
},
{
"origin": [-0.22354, 8.89778, -1],
"size": [1, 0, 2],
"pivot": [0, 6, 0],
"rotation": [0, 0, -60],
"uv": [19, 4]
},
{
"origin": [0, 6, -1],
"size": [0, 3, 2],
"pivot": [0, 6, 0],
"rotation": [-90, 45, -90],
"uv": [23, 1]
},
{
"origin": [-0.12124, 5.90481, -1],
"size": [0, 3, 2],
"pivot": [0, 6, 0],
"rotation": [-90, 28, -90],
"uv": [25, 6]
},
{
"origin": [-0.22354, 8.89778, -1],
"size": [1, 0, 2],
"pivot": [0, 6, 0],
"rotation": [-90, 30, -90],
"uv": [19, 4]
},
{
"origin": [0, 6, -1],
"size": [0, 3, 2],
"pivot": [0, 6, 0],
"rotation": [180, 0, -135],
"uv": [23, 1]
},
{
"origin": [-0.12124, 5.90481, -1],
"size": [0, 3, 2],
"pivot": [0, 6, 0],
"rotation": [-180, 0, -118],
"uv": [25, 6]
},
{
"origin": [-0.22354, 8.89778, -1],
"size": [1, 0, 2],
"pivot": [0, 6, 0],
"rotation": [-180, 0, -120],
"uv": [19, 4]
},
{
"origin": [0, 6, -1],
"size": [0, 3, 2],
"pivot": [0, 6, 0],
"rotation": [90, -45, -90],
"uv": [23, 1]
},
{
"origin": [-0.12124, 5.90481, -1],
"size": [0, 3, 2],
"pivot": [0, 6, 0],
"rotation": [90, -28, -90],
"uv": [25, 6]
},
{
"origin": [-0.22354, 8.89778, -1],
"size": [1, 0, 2],
"pivot": [0, 6, 0],
"rotation": [90, -30, -90],
"uv": [19, 4]
}
] ]
} }
] ]
@@ -19,14 +19,48 @@
{ "origin": [-3.5, 7, 7], "size": [7, 3, 0], "uv": [0, 21] }, { "origin": [-3.5, 7, 7], "size": [7, 3, 0], "uv": [0, 21] },
{ "origin": [-8.5, 0, 2], "size": [5, 11, 5], "uv": [24, 0] }, { "origin": [-8.5, 0, 2], "size": [5, 11, 5], "uv": [24, 0] },
{ "origin": [-8.5, 0, 2], "size": [5, 11, 5], "inflate": 0.25, "uv": [17, 16] }, { "origin": [-8.5, 0, 2], "size": [5, 11, 5], "inflate": 0.25, "uv": [17, 16] },
{"origin": [5.5, 2, 7], "size": [3, 1, 2], "inflate": -0.1, "pivot": [6.5, 3, 7], "rotation": [-32.5, 0, 0], "uv": [54, 33], "mirror": true}, {
{"origin": [-8.5, 2, 7], "size": [3, 1, 2], "inflate": -0.1, "pivot": [-6.5, 3, 7], "rotation": [-32.5, 0, 0], "uv": [54, 33]}, "origin": [5.5, 2, 7],
"size": [3, 1, 2],
"inflate": -0.1,
"pivot": [6.5, 3, 7],
"rotation": [-32.5, 0, 0],
"uv": [54, 33],
"mirror": true
},
{
"origin": [-8.5, 2, 7],
"size": [3, 1, 2],
"inflate": -0.1,
"pivot": [-6.5, 3, 7],
"rotation": [-32.5, 0, 0],
"uv": [54, 33]
},
{ "origin": [3.5, 0, 2], "size": [5, 11, 5], "inflate": 0.25, "uv": [17, 16], "mirror": true }, { "origin": [3.5, 0, 2], "size": [5, 11, 5], "inflate": 0.25, "uv": [17, 16], "mirror": true },
{ "origin": [-4, 0, -2], "size": [8, 12, 4], "inflate": 0.25, "uv": [0, 0] }, { "origin": [-4, 0, -2], "size": [8, 12, 4], "inflate": 0.25, "uv": [0, 0] },
{ "origin": [4.5, 4.5, -9], "size": [2, 6, 2], "uv": [20, 32], "mirror": true }, { "origin": [4.5, 4.5, -9], "size": [2, 6, 2], "uv": [20, 32], "mirror": true },
{"origin": [5.5, -0.5, -8.5], "size": [0, 5, 11], "pivot": [5.5, 4.5, -9.5], "rotation": [-2.41558, 9.23973, -17.90374], "uv": [0, 5], "mirror": true}, {
{"origin": [-5.5, -0.5, -8.5], "size": [0, 5, 11], "pivot": [-5.5, 4.5, -9.5], "rotation": [-2.41558, -9.23973, 17.90374], "uv": [0, 5]}, "origin": [5.5, -0.5, -8.5],
{"origin": [4.5, 10, -9.5], "size": [2, 1, 2], "inflate": 0.02, "uv": [20, 0], "mirror": true}, "size": [0, 5, 11],
"pivot": [5.5, 4.5, -9.5],
"rotation": [-2.41558, 9.23973, -17.90374],
"uv": [0, 5],
"mirror": true
},
{
"origin": [-5.5, -0.5, -8.5],
"size": [0, 5, 11],
"pivot": [-5.5, 4.5, -9.5],
"rotation": [-2.41558, -9.23973, 17.90374],
"uv": [0, 5]
},
{
"origin": [4.5, 10, -9.5],
"size": [2, 1, 2],
"inflate": 0.02,
"uv": [20, 0],
"mirror": true
},
{ "origin": [5, 11.1, -9], "size": [1, 0, 1], "uv": [0, 0], "mirror": true }, { "origin": [5, 11.1, -9], "size": [1, 0, 1], "uv": [0, 0], "mirror": true },
{ "origin": [-6.5, 4.5, -9], "size": [2, 6, 2], "uv": [20, 32] }, { "origin": [-6.5, 4.5, -9], "size": [2, 6, 2], "uv": [20, 32] },
{ "origin": [-6.5, 10, -9.5], "size": [2, 1, 2], "inflate": 0.02, "uv": [20, 0] }, { "origin": [-6.5, 10, -9.5], "size": [2, 1, 2], "inflate": 0.02, "uv": [20, 0] },
+23 -3
View File
@@ -20,9 +20,29 @@
{ "origin": [-1, 3.5, -6.5], "size": [2, 2, 2], "uv": [0, 4] }, { "origin": [-1, 3.5, -6.5], "size": [2, 2, 2], "uv": [0, 4] },
{ "origin": [-1, 4.5, -9.5], "size": [2, 2, 3], "uv": [0, 24] }, { "origin": [-1, 4.5, -9.5], "size": [2, 2, 3], "uv": [0, 24] },
{ "origin": [-1, 4.5, -11.5], "size": [2, 2, 2], "uv": [0, 0] }, { "origin": [-1, 4.5, -11.5], "size": [2, 2, 2], "uv": [0, 0] },
{"origin": [-1, 4.41421, -8.70711], "size": [2, 1, 3], "inflate": -0.01, "pivot": [0, 4.91421, -7.20711], "rotation": [-45, 0, 0], "uv": [10, 24]}, {
{"origin": [-1, 4.55629, -7.35525], "size": [2, 1, 2], "inflate": -0.01, "pivot": [0, 5.05629, -5.85525], "rotation": [-47.5, 0, 0], "uv": [26, 15]}, "origin": [-1, 4.41421, -8.70711],
{"origin": [-2, 6, -2], "size": [4, 1, 4], "pivot": [0, 6.5, 0], "rotation": [0, 45, 0], "uv": [22, 20]}, "size": [2, 1, 3],
"inflate": -0.01,
"pivot": [0, 4.91421, -7.20711],
"rotation": [-45, 0, 0],
"uv": [10, 24]
},
{
"origin": [-1, 4.55629, -7.35525],
"size": [2, 1, 2],
"inflate": -0.01,
"pivot": [0, 5.05629, -5.85525],
"rotation": [-47.5, 0, 0],
"uv": [26, 15]
},
{
"origin": [-2, 6, -2],
"size": [4, 1, 4],
"pivot": [0, 6.5, 0],
"rotation": [0, 45, 0],
"uv": [22, 20]
},
{ "origin": [-1, 8, -1], "size": [2, 2, 2], "uv": [20, 25] }, { "origin": [-1, 8, -1], "size": [2, 2, 2], "uv": [20, 25] },
{ "origin": [0, 7, -1], "size": [0, 1, 2], "uv": [0, 6] } { "origin": [0, 7, -1], "size": [0, 1, 2], "uv": [0, 6] }
] ]
@@ -16,10 +16,34 @@
"pivot": [0.16667, 6.83246, 1.86752], "pivot": [0.16667, 6.83246, 1.86752],
"rotation": [-90, 80, -90], "rotation": [-90, 80, -90],
"cubes": [ "cubes": [
{"origin": [-6, 0.74912, -7.13248], "size": [12, 12, 2], "pivot": [0, 6.74912, -6.13248], "rotation": [0, 0, 45], "uv": [18, 0]}, {
{"origin": [-8, -1.25088, -6.13248], "size": [16, 16, 0], "pivot": [0, 6.74912, -6.13248], "rotation": [0, 0, 45], "uv": [0, 32]}, "origin": [-6, 0.74912, -7.13248],
{"origin": [-4, 2.74912, 8.86752], "size": [8, 8, 2], "pivot": [0, 6.74912, 9.86752], "rotation": [0, 0, 45], "uv": [32, 28]}, "size": [12, 12, 2],
{"origin": [-6, 0.74912, 9.86752], "size": [12, 12, 0], "pivot": [0, 6.74912, 9.86752], "rotation": [0, 0, 45], "uv": [18, 16]}, "pivot": [0, 6.74912, -6.13248],
"rotation": [0, 0, 45],
"uv": [18, 0]
},
{
"origin": [-8, -1.25088, -6.13248],
"size": [16, 16, 0],
"pivot": [0, 6.74912, -6.13248],
"rotation": [0, 0, 45],
"uv": [0, 32]
},
{
"origin": [-4, 2.74912, 8.86752],
"size": [8, 8, 2],
"pivot": [0, 6.74912, 9.86752],
"rotation": [0, 0, 45],
"uv": [32, 28]
},
{
"origin": [-6, 0.74912, 9.86752],
"size": [12, 12, 0],
"pivot": [0, 6.74912, 9.86752],
"rotation": [0, 0, 45],
"uv": [18, 16]
},
{ "origin": [-1, 5.99912, -5.13248], "size": [2, 2, 14], "uv": [0, 16] }, { "origin": [-1, 5.99912, -5.13248], "size": [2, 2, 14], "uv": [0, 16] },
{ "origin": [1, 5.99912, -5.13248], "size": [0, 2, 14], "inflate": 1, "uv": [0, 0] } { "origin": [1, 5.99912, -5.13248], "size": [0, 2, 14], "inflate": 1, "uv": [0, 0] }
] ]
@@ -16,10 +16,28 @@
"pivot": [0, 0, 0], "pivot": [0, 0, 0],
"cubes": [ "cubes": [
{ "origin": [-6, 0, -8], "size": [12, 1, 9], "uv": [0, 0] }, { "origin": [-6, 0, -8], "size": [12, 1, 9], "uv": [0, 0] },
{"origin": [-6, -0.2355, 7.19179], "size": [12, 1, 4], "pivot": [0, -0.2355, 15.19179], "rotation": [-2.5, 0, 0], "uv": [0, 10]}, {
{"origin": [-6, 0.42792, 0.78022], "size": [12, 1, 3], "pivot": [0, 0.92792, 2.28022], "rotation": [17.5, 0, 0], "uv": [0, 19]}, "origin": [-6, -0.2355, 7.19179],
"size": [12, 1, 4],
"pivot": [0, -0.2355, 15.19179],
"rotation": [-2.5, 0, 0],
"uv": [0, 10]
},
{
"origin": [-6, 0.42792, 0.78022],
"size": [12, 1, 3],
"pivot": [0, 0.92792, 2.28022],
"rotation": [17.5, 0, 0],
"uv": [0, 19]
},
{ "origin": [-6, 0.85583, 3.56045], "size": [12, 1, 1], "uv": [0, 23] }, { "origin": [-6, 0.85583, 3.56045], "size": [12, 1, 1], "uv": [0, 23] },
{"origin": [-6, 0.74346, 4.414], "size": [12, 1, 3], "pivot": [0, 1.24346, 4.914], "rotation": [-15, 0, 0], "uv": [0, 15]} {
"origin": [-6, 0.74346, 4.414],
"size": [12, 1, 3],
"pivot": [0, 1.24346, 4.914],
"rotation": [-15, 0, 0],
"uv": [0, 15]
}
] ]
} }
] ]
@@ -17,10 +17,28 @@
"rotation": [180, 0, -93.5], "rotation": [180, 0, -93.5],
"cubes": [ "cubes": [
{ "origin": [-1.3, -1.5, -6.2], "size": [4, 6, 8], "uv": [0, 0] }, { "origin": [-1.3, -1.5, -6.2], "size": [4, 6, 8], "uv": [0, 0] },
{"origin": [2.7, 1.5, -4.2], "size": [2, 0, 3], "pivot": [2.7, 1.5, -2.7], "rotation": [0, 0, -35], "uv": [0, 3]}, {
{"origin": [-3.3, 1.5, -4.2], "size": [2, 0, 3], "pivot": [-1.3, 1.5, -2.7], "rotation": [0, 0, 80], "uv": [0, 0]}, "origin": [2.7, 1.5, -4.2],
"size": [2, 0, 3],
"pivot": [2.7, 1.5, -2.7],
"rotation": [0, 0, -35],
"uv": [0, 3]
},
{
"origin": [-3.3, 1.5, -4.2],
"size": [2, 0, 3],
"pivot": [-1.3, 1.5, -2.7],
"rotation": [0, 0, 80],
"uv": [0, 0]
},
{ "origin": [0.7, 4.5, -5.2], "size": [0, 1, 7], "uv": [1, 7] }, { "origin": [0.7, 4.5, -5.2], "size": [0, 1, 7], "uv": [1, 7] },
{"origin": [0.7, -1.5, 1.8], "size": [0, 6, 4], "pivot": [0.7, 1.5, 1.8], "rotation": [0, -12.5, 0], "uv": [0, 11]} {
"origin": [0.7, -1.5, 1.8],
"size": [0, 6, 4],
"pivot": [0.7, 1.5, 1.8],
"rotation": [0, -12.5, 0],
"uv": [0, 11]
}
] ]
}, },
{ {
@@ -16,9 +16,27 @@
"pivot": [0, -0.2, 0], "pivot": [0, -0.2, 0],
"rotation": [-5, 0, 0], "rotation": [-5, 0, 0],
"cubes": [ "cubes": [
{"origin": [-1, 0.84482, -2.89762], "size": [2, 2, 7], "pivot": [0, 1.84482, 1.10238], "rotation": [0, 0, 45], "uv": [0, 0]}, {
{"origin": [-1.5, 0.34482, -4.89762], "size": [3, 3, 2], "pivot": [0, 1.84482, 1.10238], "rotation": [0, 0, 45], "uv": [0, 9]}, "origin": [-1, 0.84482, -2.89762],
{"origin": [-1.5, 0.34482, -5.89762], "size": [3, 3, 1], "pivot": [0, 1.84482, 1.10238], "rotation": [0, 0, 45], "uv": [10, 9]} "size": [2, 2, 7],
"pivot": [0, 1.84482, 1.10238],
"rotation": [0, 0, 45],
"uv": [0, 0]
},
{
"origin": [-1.5, 0.34482, -4.89762],
"size": [3, 3, 2],
"pivot": [0, 1.84482, 1.10238],
"rotation": [0, 0, 45],
"uv": [0, 9]
},
{
"origin": [-1.5, 0.34482, -5.89762],
"size": [3, 3, 1],
"pivot": [0, 1.84482, 1.10238],
"rotation": [0, 0, 45],
"uv": [10, 9]
}
] ]
} }
] ]
@@ -16,7 +16,13 @@
"pivot": [0, 0, 0], "pivot": [0, 0, 0],
"cubes": [ "cubes": [
{ "origin": [-2, 0, -4], "size": [4, 2, 8], "uv": [0, 0] }, { "origin": [-2, 0, -4], "size": [4, 2, 8], "uv": [0, 0] },
{"origin": [0.5, 0.25, 4], "size": [1, 1, 3], "pivot": [1, 0.75, 5], "rotation": [0, 0, -45], "uv": [0, 10]} {
"origin": [0.5, 0.25, 4],
"size": [1, 1, 3],
"pivot": [1, 0.75, 5],
"rotation": [0, 0, -45],
"uv": [0, 10]
}
] ]
} }
] ]
+7 -1
View File
@@ -15,7 +15,13 @@
"name": "ring", "name": "ring",
"pivot": [0, 0, 0], "pivot": [0, 0, 0],
"cubes": [ "cubes": [
{"origin": [-2, 0, -2], "size": [4, 1, 4], "pivot": [0, 0.5, 0], "rotation": [0, 45, 0], "uv": [0, 0]}, {
"origin": [-2, 0, -2],
"size": [4, 1, 4],
"pivot": [0, 0.5, 0],
"rotation": [0, 45, 0],
"uv": [0, 0]
},
{ "origin": [-1, 0, 2], "size": [2, 1, 1], "inflate": 0.1, "uv": [0, 5] } { "origin": [-1, 0, 2], "size": [2, 1, 1], "inflate": 0.1, "uv": [0, 5] }
] ]
} }
+14 -2
View File
@@ -16,8 +16,20 @@
"pivot": [0.175, 1.65, 0], "pivot": [0.175, 1.65, 0],
"rotation": [0, 90, 90], "rotation": [0, 90, 90],
"cubes": [ "cubes": [
{"origin": [-0.825, -18.025, -0.75], "size": [2, 35, 2], "pivot": [0.175, -0.525, 0.25], "rotation": [0, 45, 0], "uv": [0, 18]}, {
{"origin": [-2.825, -19.075, -0.75], "size": [6, 2, 2], "pivot": [0.175, -18.075, 0.25], "rotation": [45, 0, 0], "uv": [8, 29]}, "origin": [-0.825, -18.025, -0.75],
"size": [2, 35, 2],
"pivot": [0.175, -0.525, 0.25],
"rotation": [0, 45, 0],
"uv": [0, 18]
},
{
"origin": [-2.825, -19.075, -0.75],
"size": [6, 2, 2],
"pivot": [0.175, -18.075, 0.25],
"rotation": [45, 0, 0],
"uv": [8, 29]
},
{ "origin": [-5.825, -28.275, 0.25], "size": [12, 11, 0], "uv": [8, 18] }, { "origin": [-5.825, -28.275, 0.25], "size": [12, 11, 0], "uv": [8, 18] },
{ "origin": [-6.825, 11.975, -1.75], "size": [14, 16, 2], "uv": [0, 0] } { "origin": [-6.825, 11.975, -1.75], "size": [14, 16, 2], "uv": [0, 0] }
] ]
@@ -15,14 +15,54 @@
"name": "steering_wheel", "name": "steering_wheel",
"pivot": [0, 0.5, 0], "pivot": [0, 0.5, 0],
"cubes": [ "cubes": [
{"origin": [-5, 0, 4], "size": [10, 1, 1], "inflate": 0.01, "pivot": [0, 0, 0], "rotation": [0, 45, 0], "uv": [10, 2]}, {
"origin": [-5, 0, 4],
"size": [10, 1, 1],
"inflate": 0.01,
"pivot": [0, 0, 0],
"rotation": [0, 45, 0],
"uv": [10, 2]
},
{ "origin": [-0.5, 0, -6], "size": [1, 1, 5], "uv": [10, 9] }, { "origin": [-0.5, 0, -6], "size": [1, 1, 5], "uv": [10, 9] },
{"origin": [0, 0, 0], "size": [1, 1, 4], "pivot": [1, 0, 0], "rotation": [0, 60, 0], "uv": [17, 5]}, {
{"origin": [-1, 0, 0], "size": [1, 1, 4], "pivot": [-1, 0, 0], "rotation": [0, -60, 0], "uv": [14, 15]}, "origin": [0, 0, 0],
"size": [1, 1, 4],
"pivot": [1, 0, 0],
"rotation": [0, 60, 0],
"uv": [17, 5]
},
{
"origin": [-1, 0, 0],
"size": [1, 1, 4],
"pivot": [-1, 0, 0],
"rotation": [0, -60, 0],
"uv": [14, 15]
},
{ "origin": [-1, 0, -1], "size": [2, 1, 2], "inflate": 0.01, "uv": [0, 0] }, { "origin": [-1, 0, -1], "size": [2, 1, 2], "inflate": 0.01, "uv": [0, 0] },
{"origin": [-5, 0, -4], "size": [1, 1, 8], "inflate": 0.01, "pivot": [0, 0, 0], "rotation": [0, 45, 0], "uv": [0, 9]}, {
{"origin": [4, 0, -4], "size": [1, 1, 8], "inflate": 0.01, "pivot": [0, 0, 0], "rotation": [0, 45, 0], "uv": [0, 0]}, "origin": [-5, 0, -4],
{"origin": [-5, 0, -5], "size": [10, 1, 1], "inflate": 0.01, "pivot": [0, 0, 0], "rotation": [0, 45, 0], "uv": [10, 0]} "size": [1, 1, 8],
"inflate": 0.01,
"pivot": [0, 0, 0],
"rotation": [0, 45, 0],
"uv": [0, 9]
},
{
"origin": [4, 0, -4],
"size": [1, 1, 8],
"inflate": 0.01,
"pivot": [0, 0, 0],
"rotation": [0, 45, 0],
"uv": [0, 0]
},
{
"origin": [-5, 0, -5],
"size": [10, 1, 1],
"inflate": 0.01,
"pivot": [0, 0, 0],
"rotation": [0, 45, 0],
"uv": [10, 0]
}
] ]
} }
] ]
@@ -0,0 +1,78 @@
{
"format_version": 1,
"model": {
"id": "dangerous_business:stairs",
"elements": [
{
"from": [
0,
0,
0
],
"to": [
16,
8,
16
],
"faces": {
"bottom": {
"texture": "#bottom",
"cullface": "bottom"
},
"top": {
"texture": "#top"
},
"north": {
"texture": "#side",
"cullface": "north"
},
"south": {
"texture": "#side",
"cullface": "south"
},
"west": {
"texture": "#side",
"cullface": "west"
},
"east": {
"texture": "#side",
"cullface": "east"
}
}
},
{
"from": [
8,
8,
0
],
"to": [
16,
16,
16
],
"faces": {
"top": {
"texture": "#top",
"cullface": "top"
},
"north": {
"texture": "#side",
"cullface": "north"
},
"south": {
"texture": "#side",
"cullface": "south"
},
"west": {
"texture": "#side"
},
"east": {
"texture": "#side",
"cullface": "east"
}
}
}
]
}
}
@@ -0,0 +1,25 @@
{
"format_version": 1,
"model": {
"id": "dangerous_business:template_glass_pane_noside",
"elements": [
{
"from": [
7,
0,
7
],
"to": [
9,
16,
9
],
"faces": {
"north": {
"texture": "#pane"
}
}
}
]
}
}
@@ -0,0 +1,30 @@
{
"format_version": 1,
"model": {
"id": "dangerous_business:template_glass_pane_post",
"elements": [
{
"from": [
7,
0,
7
],
"to": [
9,
16,
9
],
"faces": {
"bottom": {
"texture": "#edge",
"cullface": "bottom"
},
"top": {
"texture": "#edge",
"cullface": "top"
}
}
}
]
}
}
@@ -0,0 +1,40 @@
{
"format_version": 1,
"model": {
"id": "dangerous_business:template_glass_pane_side",
"elements": [
{
"from": [
7,
0,
0
],
"to": [
9,
16,
7
],
"faces": {
"bottom": {
"texture": "#edge",
"cullface": "bottom"
},
"top": {
"texture": "#edge",
"cullface": "top"
},
"north": {
"texture": "#edge",
"cullface": "north"
},
"west": {
"texture": "#pane"
},
"east": {
"texture": "#pane"
}
}
}
]
}
}
@@ -0,0 +1,42 @@
{
"format_version": 1,
"model": {
"id": "dangerous_business:template_wall_post",
"elements": [
{
"from": [
4,
0,
4
],
"to": [
12,
16,
12
],
"faces": {
"bottom": {
"texture": "#wall",
"cullface": "bottom"
},
"top": {
"texture": "#wall",
"cullface": "top"
},
"north": {
"texture": "#wall"
},
"south": {
"texture": "#wall"
},
"west": {
"texture": "#wall"
},
"east": {
"texture": "#wall"
}
}
}
]
}
}
@@ -0,0 +1,39 @@
{
"format_version": 1,
"model": {
"id": "dangerous_business:template_wall_side",
"elements": [
{
"from": [
5,
0,
0
],
"to": [
11,
14,
8
],
"faces": {
"bottom": {
"texture": "#wall",
"cullface": "bottom"
},
"top": {
"texture": "#wall"
},
"north": {
"texture": "#wall",
"cullface": "north"
},
"west": {
"texture": "#wall"
},
"east": {
"texture": "#wall"
}
}
}
]
}
}
@@ -0,0 +1,76 @@
{
"format_version": 1,
"model": {
"id": "dangerous_business:wall_inventory",
"elements": [
{
"from": [
4,
0,
4
],
"to": [
12,
16,
12
],
"faces": {
"bottom": {
"texture": "#wall",
"cullface": "bottom"
},
"top": {
"texture": "#wall",
"cullface": "top"
},
"north": {
"texture": "#wall"
},
"south": {
"texture": "#wall"
},
"west": {
"texture": "#wall"
},
"east": {
"texture": "#wall"
}
}
},
{
"from": [
5,
0,
0
],
"to": [
11,
13,
16
],
"faces": {
"bottom": {
"texture": "#wall"
},
"top": {
"texture": "#wall"
},
"north": {
"texture": "#wall",
"cullface": "north"
},
"south": {
"texture": "#wall",
"cullface": "south"
},
"west": {
"texture": "#wall"
},
"east": {
"texture": "#wall"
}
}
}
]
}
}
@@ -4,188 +4,420 @@
"id": "dangerous_business:tiny_pipe_curve", "id": "dangerous_business:tiny_pipe_curve",
"elements": [ "elements": [
{ {
"from": [7, 0, 7], "from": [
"to": [9, 9, 9], 7,
7,
7
],
"to": [
9,
16,
9
],
"faces": { "faces": {
"north": { "north": {
"texture": "#texture", "texture": "#texture",
"uv": [2.25, 3.5, 2.75, 5.75] "uv": [
2.25,
5.75,
2.75,
3.5
]
}, },
"east": { "east": {
"texture": "#texture", "texture": "#texture",
"uv": [1.75, 3.5, 2.25, 5.75] "uv": [
1.75,
5.75,
2.25,
3.5
]
}, },
"south": { "south": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 3.5, 3.75, 5.75] "uv": [
3.25,
5.75,
3.75,
3.5
]
}, },
"west": { "west": {
"texture": "#texture", "texture": "#texture",
"uv": [2.75, 3.5, 3.25, 5.75] "uv": [
}, 2.75,
"top": { 5.75,
"texture": "#texture", 3.25,
"uv": [3.75, 2.5, 3.25, 2] 3.5
]
}, },
"bottom": { "bottom": {
"texture": "#texture", "texture": "#texture",
"uv": [4.5, 0.75, 4, 1.25], "uv": [
"cullface": "bottom" 3.75,
2,
3.25,
2.5
]
},
"top": {
"texture": "#texture",
"uv": [
4.5,
1.25,
4,
0.75
],
"cullface": "top"
} }
} }
}, },
{ {
"from": [7, 0, 7], "from": [
"to": [9, 9, 7], 7,
7,
7
],
"to": [
9,
16,
7
],
"faces": { "faces": {
"south": { "south": {
"texture": "#texture", "texture": "#texture",
"uv": [2.75, 3.5, 2.25, 5.75] "uv": [
2.75,
5.75,
2.25,
3.5
]
} }
} }
}, },
{ {
"from": [9, 0, 7], "from": [
"to": [9, 9, 9], 9,
7,
7
],
"to": [
9,
16,
9
],
"faces": { "faces": {
"west": { "west": {
"texture": "#texture", "texture": "#texture",
"uv": [2.25, 3.5, 1.75, 5.75] "uv": [
2.25,
5.75,
1.75,
3.5
]
} }
} }
}, },
{ {
"from": [7, 0, 9], "from": [
"to": [9, 9, 9], 7,
7,
9
],
"to": [
9,
16,
9
],
"faces": { "faces": {
"north": { "north": {
"texture": "#texture", "texture": "#texture",
"uv": [3.75, 3.5, 3.25, 5.75] "uv": [
3.75,
5.75,
3.25,
3.5
]
} }
} }
}, },
{ {
"from": [7, 0, 7], "from": [
"to": [7, 9, 9], 7,
7,
7
],
"to": [
7,
16,
9
],
"faces": { "faces": {
"east": { "east": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 3.5, 2.75, 5.75] "uv": [
3.25,
5.75,
2.75,
3.5
]
} }
} }
}, },
{ {
"from": [7, 9, 7], "from": [
"to": [9, 9, 9], 7,
"faces": { 7,
"bottom": { 7
"texture": "#texture", ],
"uv": [3.75, 2, 3.25, 2.5] "to": [
} 9,
} 7,
}, 9
{ ],
"from": [7, 0, 7],
"to": [9, 0, 9],
"faces": { "faces": {
"top": { "top": {
"texture": "#texture", "texture": "#texture",
"uv": [4.5, 1.25, 4, 0.75] "uv": [
3.75,
2.5,
3.25,
2
]
} }
} }
}, },
{ {
"from": [7, 7, 0], "from": [
"to": [9, 9, 7], 7,
16,
7
],
"to": [
9,
16,
9
],
"faces": {
"bottom": {
"texture": "#texture",
"uv": [
4.5,
0.75,
4,
1.25
]
}
}
},
{
"from": [
7,
7,
0
],
"to": [
9,
9,
7
],
"faces": { "faces": {
"north": { "north": {
"texture": "#texture", "texture": "#texture",
"uv": [2.5, 0.5, 3, 1], "uv": [
2.5,
1,
3,
0.5
],
"cullface": "north" "cullface": "north"
}, },
"east": { "east": {
"texture": "#texture", "texture": "#texture",
"uv": [2, 1.75, 2.5, 4.25], "uv": [
2.5,
1.75,
2,
4.25
],
"rotation": 90 "rotation": 90
}, },
"south": { "south": {
"texture": "#texture", "texture": "#texture",
"uv": [3.75, 1.75, 3.25, 2.25] "uv": [
3.75,
2.25,
3.25,
1.75
]
}, },
"west": { "west": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 4.25, 2.75, 1.75], "uv": [
2.75,
4.25,
3.25,
1.75
],
"rotation": 90 "rotation": 90
}, },
"top": {
"texture": "#texture",
"uv": [3.25, 1.75, 3.75, 4.25]
},
"bottom": { "bottom": {
"texture": "#texture", "texture": "#texture",
"uv": [2.75, 4.25, 2.25, 1.75] "uv": [
3.25,
4.25,
3.75,
1.75
]
},
"top": {
"texture": "#texture",
"uv": [
2.75,
1.75,
2.25,
4.25
]
} }
} }
}, },
{ {
"from": [7, 7, 0], "from": [
"to": [9, 9, 0], 7,
7,
0
],
"to": [
9,
9,
0
],
"faces": { "faces": {
"south": { "south": {
"texture": "#texture", "texture": "#texture",
"uv": [3, 0.5, 2.5, 1] "uv": [
3,
1,
2.5,
0.5
]
} }
} }
}, },
{ {
"from": [9, 7, 0], "from": [
"to": [9, 9, 7], 9,
7,
0
],
"to": [
9,
9,
7
],
"faces": { "faces": {
"west": { "west": {
"texture": "#texture", "texture": "#texture",
"uv": [2, 4.25, 2.5, 1.75], "uv": [
2.5,
4.25,
2,
1.75
],
"rotation": 90 "rotation": 90
} }
} }
}, },
{ {
"from": [7, 7, 7], "from": [
"to": [9, 9, 7], 7,
7,
7
],
"to": [
9,
9,
7
],
"faces": { "faces": {
"north": { "north": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 1.75, 3.75, 2.25] "uv": [
3.25,
2.25,
3.75,
1.75
]
} }
} }
}, },
{ {
"from": [7, 7, 0], "from": [
"to": [7, 9, 7], 7,
7,
0
],
"to": [
7,
9,
7
],
"faces": { "faces": {
"east": { "east": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 1.75, 2.75, 4.25], "uv": [
2.75,
1.75,
3.25,
4.25
],
"rotation": 90 "rotation": 90
} }
} }
}, },
{ {
"from": [7, 9, 0], "from": [
"to": [9, 9, 7], 7,
7,
0
],
"to": [
9,
7,
7
],
"faces": { "faces": {
"bottom": { "top": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 4.25, 3.75, 1.75] "uv": [
3.25,
1.75,
3.75,
4.25
]
} }
} }
}, },
{ {
"from": [7, 7, 0], "from": [
"to": [9, 7, 7], 7,
9,
0
],
"to": [
9,
9,
7
],
"faces": { "faces": {
"top": { "bottom": {
"texture": "#texture", "texture": "#texture",
"uv": [2.75, 1.75, 2.25, 4.25] "uv": [
2.75,
4.25,
2.25,
1.75
]
} }
} }
} }
@@ -4,291 +4,639 @@
"id": "dangerous_business:tiny_pipe_curve4", "id": "dangerous_business:tiny_pipe_curve4",
"elements": [ "elements": [
{ {
"from": [7, 0, 7], "from": [
"to": [9, 9, 9], 7,
7,
7
],
"to": [
9,
16,
9
],
"faces": { "faces": {
"north": { "north": {
"texture": "#texture", "texture": "#texture",
"uv": [2.25, 3.5, 2.75, 5.75] "uv": [
2.25,
5.75,
2.75,
3.5
]
}, },
"east": { "east": {
"texture": "#texture", "texture": "#texture",
"uv": [1.75, 3.5, 2.25, 5.75] "uv": [
1.75,
5.75,
2.25,
3.5
]
}, },
"south": { "south": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 3.5, 3.75, 5.75] "uv": [
3.25,
5.75,
3.75,
3.5
]
}, },
"west": { "west": {
"texture": "#texture", "texture": "#texture",
"uv": [2.75, 3.5, 3.25, 5.75] "uv": [
}, 2.75,
"top": { 5.75,
"texture": "#texture", 3.25,
"uv": [3.75, 2.5, 3.25, 2] 3.5
]
}, },
"bottom": { "bottom": {
"texture": "#texture", "texture": "#texture",
"uv": [4.5, 0.75, 4, 1.25], "uv": [
"cullface": "bottom" 3.75,
2,
3.25,
2.5
]
},
"top": {
"texture": "#texture",
"uv": [
4.5,
1.25,
4,
0.75
],
"cullface": "top"
} }
} }
}, },
{ {
"from": [7, 0, 7], "from": [
"to": [9, 9, 7], 7,
7,
7
],
"to": [
9,
16,
7
],
"faces": { "faces": {
"south": { "south": {
"texture": "#texture", "texture": "#texture",
"uv": [2.75, 3.5, 2.25, 5.75] "uv": [
2.75,
5.75,
2.25,
3.5
]
} }
} }
}, },
{ {
"from": [9, 0, 7], "from": [
"to": [9, 9, 9], 9,
7,
7
],
"to": [
9,
16,
9
],
"faces": { "faces": {
"west": { "west": {
"texture": "#texture", "texture": "#texture",
"uv": [2.25, 3.5, 1.75, 5.75] "uv": [
2.25,
5.75,
1.75,
3.5
]
} }
} }
}, },
{ {
"from": [7, 0, 9], "from": [
"to": [9, 9, 9], 7,
7,
9
],
"to": [
9,
16,
9
],
"faces": { "faces": {
"north": { "north": {
"texture": "#texture", "texture": "#texture",
"uv": [3.75, 3.5, 3.25, 5.75] "uv": [
3.75,
5.75,
3.25,
3.5
]
} }
} }
}, },
{ {
"from": [7, 0, 7], "from": [
"to": [7, 9, 9], 7,
7,
7
],
"to": [
7,
16,
9
],
"faces": { "faces": {
"east": { "east": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 3.5, 2.75, 5.75] "uv": [
3.25,
5.75,
2.75,
3.5
]
} }
} }
}, },
{ {
"from": [7, 9, 7], "from": [
"to": [9, 9, 9], 7,
"faces": { 7,
"bottom": { 7
"texture": "#texture", ],
"uv": [3.75, 2, 3.25, 2.5] "to": [
} 9,
} 7,
}, 9
{ ],
"from": [7, 0, 7],
"to": [9, 0, 9],
"faces": { "faces": {
"top": { "top": {
"texture": "#texture", "texture": "#texture",
"uv": [4.5, 1.25, 4, 0.75] "uv": [
3.75,
2.5,
3.25,
2
]
} }
} }
}, },
{ {
"from": [9, 7, 7], "from": [
"to": [16, 9, 9], 7,
16,
7
],
"to": [
9,
16,
9
],
"faces": {
"bottom": {
"texture": "#texture",
"uv": [
4.5,
0.75,
4,
1.25
]
}
}
},
{
"from": [
9,
7,
7
],
"to": [
16,
9,
9
],
"faces": { "faces": {
"north": { "north": {
"texture": "#texture", "texture": "#texture",
"uv": [2.75, 5.75, 2.25, 4], "uv": [
2.25,
5.75,
2.75,
4
],
"rotation": 90 "rotation": 90
}, },
"east": { "east": {
"texture": "#texture", "texture": "#texture",
"uv": [3.75, 2.5, 3.25, 2], "uv": [
3.25,
2.5,
3.75,
2
],
"rotation": 90, "rotation": 90,
"cullface": "east" "cullface": "east"
}, },
"south": { "south": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 4, 3.75, 5.75], "uv": [
3.75,
4,
3.25,
5.75
],
"rotation": 90 "rotation": 90
}, },
"west": { "west": {
"texture": "#texture", "texture": "#texture",
"uv": [4.5, 0.75, 4, 1.25], "uv": [
"rotation": 90 4,
}, 0.75,
"top": { 4.5,
"texture": "#texture", 1.25
"uv": [2.75, 4, 3.25, 5.75], ],
"rotation": 90 "rotation": 90
}, },
"bottom": { "bottom": {
"texture": "#texture", "texture": "#texture",
"uv": [1.75, 4, 2.25, 5.75], "uv": [
3.25,
4,
2.75,
5.75
],
"rotation": 90
},
"top": {
"texture": "#texture",
"uv": [
2.25,
4,
1.75,
5.75
],
"rotation": 90 "rotation": 90
} }
} }
}, },
{ {
"from": [9, 7, 7], "from": [
"to": [16, 9, 7], 9,
7,
7
],
"to": [
16,
9,
7
],
"faces": { "faces": {
"south": { "south": {
"texture": "#texture", "texture": "#texture",
"uv": [2.75, 4, 2.25, 5.75], "uv": [
2.25,
4,
2.75,
5.75
],
"rotation": 90 "rotation": 90
} }
} }
}, },
{ {
"from": [16, 7, 7], "from": [
"to": [16, 9, 9], 16,
7,
7
],
"to": [
16,
9,
9
],
"faces": { "faces": {
"west": { "west": {
"texture": "#texture", "texture": "#texture",
"uv": [3.75, 2, 3.25, 2.5], "uv": [
3.25,
2,
3.75,
2.5
],
"rotation": 90 "rotation": 90
} }
} }
}, },
{ {
"from": [9, 7, 9], "from": [
"to": [16, 9, 9], 9,
7,
9
],
"to": [
16,
9,
9
],
"faces": { "faces": {
"north": { "north": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 5.75, 3.75, 4], "uv": [
3.75,
5.75,
3.25,
4
],
"rotation": 90 "rotation": 90
} }
} }
}, },
{ {
"from": [9, 7, 7], "from": [
"to": [9, 9, 9], 9,
7,
7
],
"to": [
9,
9,
9
],
"faces": { "faces": {
"east": { "east": {
"texture": "#texture", "texture": "#texture",
"uv": [4.5, 1.25, 4, 0.75], "uv": [
4,
1.25,
4.5,
0.75
],
"rotation": 90 "rotation": 90
} }
} }
}, },
{ {
"from": [9, 9, 7], "from": [
"to": [16, 9, 9], 9,
"faces": { 7,
"bottom": { 7
"texture": "#texture", ],
"uv": [3.25, 4, 2.75, 5.75], "to": [
"rotation": 90 16,
} 7,
} 9
}, ],
{
"from": [9, 7, 7],
"to": [16, 7, 9],
"faces": { "faces": {
"top": { "top": {
"texture": "#texture", "texture": "#texture",
"uv": [2.25, 4, 1.75, 5.75], "uv": [
2.75,
4,
3.25,
5.75
],
"rotation": 90 "rotation": 90
} }
} }
}, },
{ {
"from": [7, 7, 0], "from": [
"to": [9, 9, 7], 9,
9,
7
],
"to": [
16,
9,
9
],
"faces": {
"bottom": {
"texture": "#texture",
"uv": [
1.75,
4,
2.25,
5.75
],
"rotation": 90
}
}
},
{
"from": [
7,
7,
0
],
"to": [
9,
9,
7
],
"faces": { "faces": {
"north": { "north": {
"texture": "#texture", "texture": "#texture",
"uv": [2.5, 0.5, 3, 1], "uv": [
2.5,
1,
3,
0.5
],
"cullface": "north" "cullface": "north"
}, },
"east": { "east": {
"texture": "#texture", "texture": "#texture",
"uv": [2, 1.75, 2.5, 4.25], "uv": [
2.5,
1.75,
2,
4.25
],
"rotation": 90 "rotation": 90
}, },
"south": { "south": {
"texture": "#texture", "texture": "#texture",
"uv": [3.75, 1.75, 3.25, 2.25] "uv": [
3.75,
2.25,
3.25,
1.75
]
}, },
"west": { "west": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 4.25, 2.75, 1.75], "uv": [
2.75,
4.25,
3.25,
1.75
],
"rotation": 90 "rotation": 90
}, },
"top": {
"texture": "#texture",
"uv": [3.25, 1.75, 3.75, 4.25]
},
"bottom": { "bottom": {
"texture": "#texture", "texture": "#texture",
"uv": [2.75, 4.25, 2.25, 1.75] "uv": [
3.25,
4.25,
3.75,
1.75
]
},
"top": {
"texture": "#texture",
"uv": [
2.75,
1.75,
2.25,
4.25
]
} }
} }
}, },
{ {
"from": [7, 7, 0], "from": [
"to": [9, 9, 0], 7,
7,
0
],
"to": [
9,
9,
0
],
"faces": { "faces": {
"south": { "south": {
"texture": "#texture", "texture": "#texture",
"uv": [3, 0.5, 2.5, 1] "uv": [
3,
1,
2.5,
0.5
]
} }
} }
}, },
{ {
"from": [9, 7, 0], "from": [
"to": [9, 9, 7], 9,
7,
0
],
"to": [
9,
9,
7
],
"faces": { "faces": {
"west": { "west": {
"texture": "#texture", "texture": "#texture",
"uv": [2, 4.25, 2.5, 1.75], "uv": [
2.5,
4.25,
2,
1.75
],
"rotation": 90 "rotation": 90
} }
} }
}, },
{ {
"from": [7, 7, 7], "from": [
"to": [9, 9, 7], 7,
7,
7
],
"to": [
9,
9,
7
],
"faces": { "faces": {
"north": { "north": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 1.75, 3.75, 2.25] "uv": [
3.25,
2.25,
3.75,
1.75
]
} }
} }
}, },
{ {
"from": [7, 7, 0], "from": [
"to": [7, 9, 7], 7,
7,
0
],
"to": [
7,
9,
7
],
"faces": { "faces": {
"east": { "east": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 1.75, 2.75, 4.25], "uv": [
2.75,
1.75,
3.25,
4.25
],
"rotation": 90 "rotation": 90
} }
} }
}, },
{ {
"from": [7, 9, 0], "from": [
"to": [9, 9, 7], 7,
7,
0
],
"to": [
9,
7,
7
],
"faces": { "faces": {
"bottom": { "top": {
"texture": "#texture", "texture": "#texture",
"uv": [3.25, 4.25, 3.75, 1.75] "uv": [
3.25,
1.75,
3.75,
4.25
]
} }
} }
}, },
{ {
"from": [7, 7, 0], "from": [
"to": [9, 7, 7], 7,
9,
0
],
"to": [
9,
9,
7
],
"faces": { "faces": {
"top": { "bottom": {
"texture": "#texture", "texture": "#texture",
"uv": [2.75, 1.75, 2.25, 4.25] "uv": [
2.75,
4.25,
2.25,
1.75
]
} }
} }
} }
@@ -16,21 +16,110 @@
"pivot": [0, -3, 0], "pivot": [0, -3, 0],
"cubes": [ "cubes": [
{ "origin": [-3, 2, -1.25], "size": [6, 13, 6], "uv": [0, 20] }, { "origin": [-3, 2, -1.25], "size": [6, 13, 6], "uv": [0, 20] },
{"origin": [1.75, 12.5, -2.25], "size": [1, 0, 6], "pivot": [3, 12.501, 4.75], "rotation": [0, -25, 0], "uv": [-6, 39]}, {
{"origin": [1.75, 4.5, -4.25], "size": [1, 0, 8], "pivot": [3, 12.501, 4.75], "rotation": [0, -25, 0], "uv": [-6, 39]}, "origin": [1.75, 12.5, -2.25],
{"origin": [-1, 0, 1.25], "size": [2, 2, 2], "pivot": [0, 1, 2.25], "rotation": [0, -45, 0], "uv": [28, 12]}, "size": [1, 0, 6],
{"origin": [-1, 0, -2.25], "size": [2, 2, 2], "pivot": [0, 1, -1.25], "rotation": [0, -45, 0], "uv": [28, 8]}, "pivot": [3, 12.501, 4.75],
{"origin": [-1, 15, -2.25], "size": [2, 3, 2], "pivot": [0, 16, -1.25], "rotation": [0, -45, 0], "uv": [21, 0]}, "rotation": [0, -25, 0],
{"origin": [-1, 15, 1.25], "size": [2, 3, 2], "pivot": [0, 16, 2.25], "rotation": [0, -45, 0], "uv": [28, 3]}, "uv": [-6, 39]
},
{
"origin": [1.75, 4.5, -4.25],
"size": [1, 0, 8],
"pivot": [3, 12.501, 4.75],
"rotation": [0, -25, 0],
"uv": [-6, 39]
},
{
"origin": [-1, 0, 1.25],
"size": [2, 2, 2],
"pivot": [0, 1, 2.25],
"rotation": [0, -45, 0],
"uv": [28, 12]
},
{
"origin": [-1, 0, -2.25],
"size": [2, 2, 2],
"pivot": [0, 1, -1.25],
"rotation": [0, -45, 0],
"uv": [28, 8]
},
{
"origin": [-1, 15, -2.25],
"size": [2, 3, 2],
"pivot": [0, 16, -1.25],
"rotation": [0, -45, 0],
"uv": [21, 0]
},
{
"origin": [-1, 15, 1.25],
"size": [2, 3, 2],
"pivot": [0, 16, 2.25],
"rotation": [0, -45, 0],
"uv": [28, 3]
},
{ "origin": [-2, 3, 4.75], "size": [4, 11, 1], "uv": [24, 20] }, { "origin": [-2, 3, 4.75], "size": [4, 11, 1], "uv": [24, 20] },
{"origin": [-3, 2, -3.575], "size": [7, 13, 7], "inflate": 0.01, "pivot": [0, 8, 0.425], "rotation": [0, 45, 0], "uv": [0, 0]}, {
{"origin": [-1, 7, -4.075], "size": [3, 3, 1], "inflate": 0.01, "pivot": [0, 8, 0.425], "rotation": [0, 45, 0], "uv": [6, 39]}, "origin": [-3, 2, -3.575],
{"origin": [-1.17157, 7, -2.075], "size": [3, 3, 1], "inflate": 0.01, "pivot": [2.82843, 8, 0.425], "rotation": [0, -45, 0], "uv": [6, 39]}, "size": [7, 13, 7],
{"origin": [-1.17157, 11, -2.075], "size": [3, 3, 1], "inflate": 0.01, "pivot": [2.82843, 8, 0.425], "rotation": [0, -45, 0], "uv": [6, 39]}, "inflate": 0.01,
{"origin": [-1, 3, -4.075], "size": [3, 3, 1], "inflate": 0.01, "pivot": [0, 8, 0.425], "rotation": [0, 45, 0], "uv": [6, 39]}, "pivot": [0, 8, 0.425],
{"origin": [-8.5, 12.75, -2.325], "size": [8, 0, 10], "pivot": [-4, 12, 1.425], "rotation": [-2.84335, 34.95365, 3.00429], "uv": [26, 0]}, "rotation": [0, 45, 0],
{"origin": [-8, 11.5, -2.575], "size": [8, 0, 10], "pivot": [-4, 12, 1.425], "rotation": [-12.2127, 43.65747, -17.40744], "uv": [26, 10]}, "uv": [0, 0]
{"origin": [-0.21637, 4.51185, -2.94442], "size": [8, 0, 10], "pivot": [3.78363, 4.51185, 2.05558], "rotation": [-5, 0, 0], "uv": [26, 20]} },
{
"origin": [-1, 7, -4.075],
"size": [3, 3, 1],
"inflate": 0.01,
"pivot": [0, 8, 0.425],
"rotation": [0, 45, 0],
"uv": [6, 39]
},
{
"origin": [-1.17157, 7, -2.075],
"size": [3, 3, 1],
"inflate": 0.01,
"pivot": [2.82843, 8, 0.425],
"rotation": [0, -45, 0],
"uv": [6, 39]
},
{
"origin": [-1.17157, 11, -2.075],
"size": [3, 3, 1],
"inflate": 0.01,
"pivot": [2.82843, 8, 0.425],
"rotation": [0, -45, 0],
"uv": [6, 39]
},
{
"origin": [-1, 3, -4.075],
"size": [3, 3, 1],
"inflate": 0.01,
"pivot": [0, 8, 0.425],
"rotation": [0, 45, 0],
"uv": [6, 39]
},
{
"origin": [-8.5, 12.75, -2.325],
"size": [8, 0, 10],
"pivot": [-4, 12, 1.425],
"rotation": [-2.84335, 34.95365, 3.00429],
"uv": [26, 0]
},
{
"origin": [-8, 11.5, -2.575],
"size": [8, 0, 10],
"pivot": [-4, 12, 1.425],
"rotation": [-12.2127, 43.65747, -17.40744],
"uv": [26, 10]
},
{
"origin": [-0.21637, 4.51185, -2.94442],
"size": [8, 0, 10],
"pivot": [3.78363, 4.51185, 2.05558],
"rotation": [-5, 0, 0],
"uv": [26, 20]
}
] ]
} }
] ]
@@ -25,7 +25,14 @@
"parent": "walkie", "parent": "walkie",
"pivot": [-1.5, 5.25, -1.75], "pivot": [-1.5, 5.25, -1.75],
"cubes": [ "cubes": [
{"origin": [-2.5, 4.95, -2.75], "size": [2, 7, 2], "inflate": -0.3, "pivot": [-1.5, 4.95, -1.75], "rotation": [0, -45, 0], "uv": [18, 0]} {
"origin": [-2.5, 4.95, -2.75],
"size": [2, 7, 2],
"inflate": -0.3,
"pivot": [-1.5, 4.95, -1.75],
"rotation": [0, -45, 0],
"uv": [18, 0]
}
] ]
} }
] ]
@@ -23,8 +23,23 @@
{ "origin": [-4.5, 3.52494, -0.07494], "size": [9, 7, 0], "uv": [1, 44] }, { "origin": [-4.5, 3.52494, -0.07494], "size": [9, 7, 0], "uv": [1, 44] },
{ "origin": [-4.5, 3.52494, 0.87506], "size": [9, 7, 0], "uv": [1, 51] }, { "origin": [-4.5, 3.52494, 0.87506], "size": [9, 7, 0], "uv": [1, 51] },
{ "origin": [-5.5, 10.02494, -0.12494], "size": [11, 1, 1], "uv": [4, 9] }, { "origin": [-5.5, 10.02494, -0.12494], "size": [11, 1, 1], "uv": [4, 9] },
{"origin": [-3.65, 10.02494, -0.12494], "size": [9.15, 1, 1], "inflate": 0.01, "pivot": [5.5, 10.02494, 0.87506], "rotation": [0, 0, -60.8], "uv": [5, 11]}, {
{"origin": [-5.5, 10.02494, -0.12494], "size": [9.15, 1, 1], "inflate": 0.01, "pivot": [-5.5, 10.02494, 0.87506], "rotation": [0, 0, 60.8], "uv": [5, 11], "mirror": true}, "origin": [-3.65, 10.02494, -0.12494],
"size": [9.15, 1, 1],
"inflate": 0.01,
"pivot": [5.5, 10.02494, 0.87506],
"rotation": [0, 0, -60.8],
"uv": [5, 11]
},
{
"origin": [-5.5, 10.02494, -0.12494],
"size": [9.15, 1, 1],
"inflate": 0.01,
"pivot": [-5.5, 10.02494, 0.87506],
"rotation": [0, 0, 60.8],
"uv": [5, 11],
"mirror": true
},
{ {
"origin": [-3, 7.02494, -0.17494], "origin": [-3, 7.02494, -0.17494],
"size": [6, 3, 1], "size": [6, 3, 1],
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2
View File
@@ -4,6 +4,7 @@ import { DOOR, FACILITY_DOOR } from "./shared.ts";
import { Alea } from "@paulaboks/rng"; import { Alea } from "@paulaboks/rng";
import { register_coilhead, register_coilhead_animator } from "./coilhead.ts"; import { register_coilhead, register_coilhead_animator } from "./coilhead.ts";
import { register_jester, register_jester_animator } from "./jester.ts"; import { register_jester, register_jester_animator } from "./jester.ts";
import { register_scrap } from "./scrap.ts";
import { import {
DOORWAY, DOORWAY,
MAIN_TILE, MAIN_TILE,
@@ -26,6 +27,7 @@ export function server(ctx: ServerContext) {
register_commands(ctx); register_commands(ctx);
register_coilhead(ctx); register_coilhead(ctx);
register_jester(ctx); register_jester(ctx);
register_scrap(ctx);
} }
export function client(ctx: ClientContext) { export function client(ctx: ClientContext) {
+22
View File
@@ -0,0 +1,22 @@
import type { ServerContext } from "cubi/server";
// scrap lies around as this entity (see its items' "entity"), holding the item, and is picked up by right clicking it
export const SCRAP = "dangerous_business:scrap";
// the inventory slots scrap can be picked up into, the hotbar for now
const LOOT_SLOTS = [0, 1, 2, 3, 4, 5, 6, 7, 8];
export function register_scrap(ctx: ServerContext) {
ctx.events.before.entity_interact.subscribe((event) => {
if (event.entity.type !== SCRAP) return;
// clicking scrap never uses what's held, picked up or not
event.cancel = true;
const item = event.entity.get_item();
const inventory = event.player.inventory;
const slot = LOOT_SLOTS.find((slot) => inventory.get(slot) === undefined);
// with no free loot slot it stays where it is
if (!item || slot === undefined) return;
inventory.set(slot, item);
event.entity.remove();
});
}
+20 -11
View File
@@ -1,4 +1,4 @@
import type { SharedContext } from "cubi/shared"; import type { Face, SharedContext } from "cubi/shared";
export const FACILITY_DOOR = "dangerous_business:facility_door"; export const FACILITY_DOOR = "dangerous_business:facility_door";
export const DOOR = "dangerous_business:door"; export const DOOR = "dangerous_business:door";
@@ -41,26 +41,35 @@ function register_pipe(ctx: SharedContext) {
} }
// sets its north, east, south and west states (and top, with "up") to 1 where the same block is beside it, so it can // sets its north, east, south and west states (and top, with "up") to 1 where the same block is beside it, so it can
// hide its edges there, like floor grates joining into one floor // hide its edges there, like floor grates joining into one floor. with "solid" it joins the full sides of other blocks
// beside it too, like iron bars, fences and walls set into a wall
interface ConnectsParams {
up?: boolean;
solid?: boolean;
}
function register_connects(ctx: SharedContext) { function register_connects(ctx: SharedContext) {
const sides = (id: string | undefined, x: number, y: number, z: number, up: boolean) => { const sides = (id: string | undefined, x: number, y: number, z: number, params: ConnectsParams) => {
const same = (dx: number, dy: number, dz: number) => ctx.world.get_block(x + dx, y + dy, z + dz) === id ? 1 : 0; const same = (dx: number, dy: number, dz: number) => ctx.world.get_block(x + dx, y + dy, z + dz) === id ? 1 : 0;
// the side of the block there that faces this one
const joins = (dx: number, dz: number, face: Face) =>
same(dx, 0, dz) || (params.solid && ctx.world.is_face_sturdy(x + dx, y, z + dz, face)) ? 1 : 0;
const states: Record<string, number> = { const states: Record<string, number> = {
north: same(0, 0, -1), north: joins(0, -1, "south"),
east: same(1, 0, 0), east: joins(1, 0, "west"),
south: same(0, 0, 1), south: joins(0, 1, "north"),
west: same(-1, 0, 0), west: joins(-1, 0, "east"),
}; };
if (up) states.top = same(0, 1, 0); if (params.up) states.top = same(0, 1, 0);
return states; return states;
}; };
ctx.components.register_block<{ up?: boolean }>("dangerous_business:connects", { ctx.components.register_block<ConnectsParams>("dangerous_business:connects", {
// the block being placed is the item's // the block being placed is the item's
state_for_placement: (placement, params) => state_for_placement: (placement, params) =>
sides(placement.item, placement.x, placement.y, placement.z, params.up ?? false), sides(placement.item, placement.x, placement.y, placement.z, params),
on_neighbor_change(block, params) { on_neighbor_change(block, params) {
const id = ctx.world.get_block(block.x, block.y, block.z); const id = ctx.world.get_block(block.x, block.y, block.z);
for (const [state, value] of Object.entries(sides(id, block.x, block.y, block.z, params.up ?? false))) { for (const [state, value] of Object.entries(sides(id, block.x, block.y, block.z, params))) {
ctx.world.set_state(block.x, block.y, block.z, state, value); ctx.world.set_state(block.x, block.y, block.z, state, value);
} }
}, },
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

+13 -2
View File
@@ -16,7 +16,9 @@ import { sound_range, sound_to_play } from "@/common/mod_data.ts";
import type { ServerPlayer } from "../player.ts"; import type { ServerPlayer } from "../player.ts";
import type { ServerWorld } from "../world.ts"; import type { ServerWorld } from "../world.ts";
import type { DamageSource, Entity, EntityLevel, SavedEntity } from "./entity.ts"; import type { DamageSource, Entity, EntityLevel, SavedEntity } from "./entity.ts";
import { load_entity } from "./entity_types.ts"; import { create_entity, load_entity } from "./entity_types.ts";
import { ObjectEntity } from "./mod_entity.ts";
import { EverythingRegistry, type ItemRegistry } from "@/common/everything_registry.ts";
import { ItemEntity } from "./item_entity.ts"; import { ItemEntity } from "./item_entity.ts";
import { MOBS_PATH_THROUGH } from "./pathfinding.ts"; import { MOBS_PATH_THROUGH } from "./pathfinding.ts";
import type { LivingEntity } from "./living_entity.ts"; import type { LivingEntity } from "./living_entity.ts";
@@ -180,7 +182,16 @@ export class EntityManager implements EntityLevel {
this.#host.after_hurt(entity, amount, source); this.#host.after_hurt(entity, amount, source);
} }
spawn_item(x: number, y: number, z: number, stack: ItemStack, pickup_delay = 0): ItemEntity { // a cubi:item, or the entity the item lies around as instead, holding it (see ItemRegistry.entity)
spawn_item(x: number, y: number, z: number, stack: ItemStack, pickup_delay = 0): Entity {
const type = EverythingRegistry.get<ItemRegistry>("items", stack.type_id)?.entity;
const object = type === undefined ? undefined : create_entity(this, type);
if (object instanceof ObjectEntity) {
object.item = stack;
object.set_position(x, y, z);
this.add_entity(object);
return object;
}
const entity = new ItemEntity(this, stack, x, y, z, pickup_delay); const entity = new ItemEntity(this, stack, x, y, z, pickup_delay);
this.add_entity(entity); this.add_entity(entity);
return entity; return entity;
+32 -27
View File
@@ -43,6 +43,36 @@ export interface SavedItemEntity extends SavedEntity {
health?: number; health?: number;
} }
// one tick of falling, sliding and floating like an item lying around, for an entity whose own gravity is 0 (see
// ItemEntity.gravity)
export function move_like_item(entity: Entity) {
// covered by a block placed on it, float out the top instead of being stuck inside. only inside what it bumps
// into, like minecraft's noCollision, so it can lie in a block with a hollow, like a basin
const level = entity.level;
if (!physics.box_is_free(entity, 0, 0, 0, (x, y, z) => level.collision_shape(x, y, z))) {
entity.vy = UNSTICK_SPEED;
}
// like minecraft's ItemEntity.tick, gravity goes on its speed before it moves, not along the way like
// move_body's. the floating numbers are made for that: an item bobbing up out of the water drops straight back
// in, instead of hanging above it a tick longer and falling twice as fast
if (physics.fluid_depth(entity, (x, y, z) => level.fluid_at(x, y, z)) > FLOAT_DEPTH) {
entity.vx *= WATER_DRAG;
entity.vz *= WATER_DRAG;
if (entity.vy < FLOAT_SPEED) entity.vy += FLOAT_ACCELERATION;
} else if (!entity.no_gravity) {
entity.vy += GRAVITY * TICK_DELTA;
}
entity.move();
const friction = entity.on_ground ? GROUND_FRICTION : AIR_DRAG;
entity.vx *= friction;
entity.vy *= AIR_DRAG;
entity.vz *= friction;
if (Math.abs(entity.vx) < MIN_SPEED) entity.vx = 0;
if (Math.abs(entity.vz) < MIN_SPEED) entity.vz = 0;
}
// a stack of items lying in the world, like minecraft's ItemEntity. only the server simulates it, // a stack of items lying in the world, like minecraft's ItemEntity. only the server simulates it,
// clients draw where they're told it is // clients draw where they're told it is
export class ItemEntity extends Entity { export class ItemEntity extends Entity {
@@ -51,7 +81,7 @@ export class ItemEntity extends Entity {
override width = ITEM_SIZE; override width = ITEM_SIZE;
override height = ITEM_SIZE; override height = ITEM_SIZE;
override eye_height = ITEM_SIZE / 2; override eye_height = ITEM_SIZE / 2;
// it falls in tick() instead, see there // it falls in move_like_item instead, see there
override gravity = 0; override gravity = 0;
// ticks until a player can pick it up // ticks until a player can pick it up
@@ -79,32 +109,7 @@ export class ItemEntity extends Entity {
if (this.pickup_delay > 0) { if (this.pickup_delay > 0) {
this.pickup_delay -= 1; this.pickup_delay -= 1;
} }
move_like_item(this);
// covered by a block placed on it, float out the top instead of being stuck inside. only inside what it bumps
// into, like minecraft's noCollision, so it can lie in a block with a hollow, like a basin
const level = this.level;
if (!physics.box_is_free(this, 0, 0, 0, (x, y, z) => level.collision_shape(x, y, z))) {
this.vy = UNSTICK_SPEED;
}
// like minecraft's ItemEntity.tick, gravity goes on its speed before it moves, not along the way like
// move_body's. the floating numbers are made for that: an item bobbing up out of the water drops straight back
// in, instead of hanging above it a tick longer and falling twice as fast
if (physics.fluid_depth(this, (x, y, z) => level.fluid_at(x, y, z)) > FLOAT_DEPTH) {
this.vx *= WATER_DRAG;
this.vz *= WATER_DRAG;
if (this.vy < FLOAT_SPEED) this.vy += FLOAT_ACCELERATION;
} else if (!this.no_gravity) {
this.vy += GRAVITY * TICK_DELTA;
}
this.move();
const friction = this.on_ground ? GROUND_FRICTION : AIR_DRAG;
this.vx *= friction;
this.vy *= AIR_DRAG;
this.vz *= friction;
if (Math.abs(this.vx) < MIN_SPEED) this.vx = 0;
if (Math.abs(this.vz) < MIN_SPEED) this.vz = 0;
if (this.age >= DESPAWN_TICKS) { if (this.age >= DESPAWN_TICKS) {
this.remove(); this.remove();
+56 -3
View File
@@ -2,11 +2,14 @@
// SPDX-License-Identifier: AGPL-3.0-or-later // SPDX-License-Identifier: AGPL-3.0-or-later
// the kinds of entity mods define in entities/<name>.json (see EntityJson): animals that wander around, panic when hurt // the kinds of entity mods define in entities/<name>.json (see EntityJson): animals that wander around, panic when hurt
// and look at players now and then, like minecraft's simpler animals, monsters that go after players, and scripted // and look at players now and then, like minecraft's simpler animals, monsters that go after players, scripted ones
// ones that stay where scripts put them // that stay where scripts put them, and objects that lie around holding an item
import { type ItemData, ItemStack } from "@/common/inventory.ts";
import { entity_category, type EntityJson } from "@/common/mod_data.ts"; import { entity_category, type EntityJson } from "@/common/mod_data.ts";
import type { EntityData } from "@/common/protocol.ts";
import { ATTRIBUTES, type AttributeType } from "./attributes.ts"; import { ATTRIBUTES, type AttributeType } from "./attributes.ts";
import { Entity } from "./entity.ts"; import { Entity, type SavedEntity } from "./entity.ts";
import { move_like_item } from "./item_entity.ts";
import type { EntityFactory } from "./entity_types.ts"; import type { EntityFactory } from "./entity_types.ts";
import { import {
FloatGoal, FloatGoal,
@@ -30,6 +33,9 @@ export function mod_entity_factory(
if (json.behavior === "scripted") { if (json.behavior === "scripted") {
return (level) => new ScriptedEntity(level, json); return (level) => new ScriptedEntity(level, json);
} }
if (json.behavior === "object") {
return (level) => new ObjectEntity(level, json);
}
const monster = json.behavior === "monster"; const monster = json.behavior === "monster";
const behavior = json.behavior?.includes(":") ? json.behavior : undefined; const behavior = json.behavior?.includes(":") ? json.behavior : undefined;
@@ -110,3 +116,50 @@ class ScriptedEntity extends Entity {
return false; return false;
} }
} }
// a thing lying around, holding an item, like neoforge's custom item entities (see ItemRegistry.entity): it falls,
// slides and floats like a dropped item, but nobody picks it up by walking into it, it never despawns or merges, and it
// can't be hurt. what happens when it's clicked is up to mods
export class ObjectEntity extends Entity {
readonly type: string;
// it falls in move_like_item instead
override gravity = 0;
item: ItemStack | undefined;
constructor(level: Entity["level"], json: EntityJson) {
super(level);
this.type = json.id;
this.width = json.width;
this.height = json.height;
this.eye_height = json.height * 0.85;
}
override tick() {
this.base_tick();
if (this.removed || this.vehicle) return;
move_like_item(this);
}
// it isn't hurt by falling either
override update_fall_distance() {}
override synced_data(): EntityData {
const data = super.synced_data();
if (this.item) data.item = this.item.to_synced_data();
return data;
}
override save_additional(saved: SavedObjectEntity) {
super.save_additional(saved);
if (this.item) saved.item = this.item.to_data();
}
override load_additional(saved: SavedObjectEntity) {
super.load_additional(saved);
this.item = saved.item ? ItemStack.from_data(saved.item) : undefined;
}
}
interface SavedObjectEntity extends SavedEntity {
item?: ItemData;
}
+22 -2
View File
@@ -549,7 +549,8 @@ export class GameServer {
} }
} }
spawn_item(x: number, y: number, z: number, stack: ItemStack, pickup_delay = 0): ItemEntity { // a cubi:item, or the entity the item lies around as, see EntityManager.spawn_item
spawn_item(x: number, y: number, z: number, stack: ItemStack, pickup_delay = 0): Entity {
const entity = this.entities.spawn_item(x, y, z, stack, pickup_delay); const entity = this.entities.spawn_item(x, y, z, stack, pickup_delay);
this.world.dirty = true; this.world.dirty = true;
return entity; return entity;
@@ -588,6 +589,8 @@ export class GameServer {
entity.vx = -Math.sin(player.yaw) * cos_pitch * speed + Math.cos(spread_angle) * spread; entity.vx = -Math.sin(player.yaw) * cos_pitch * speed + Math.cos(spread_angle) * spread;
entity.vy = Math.sin(player.pitch) * speed + (0.1 + (Math.random() - Math.random()) * 0.1) * TICKS_PER_SECOND; entity.vy = Math.sin(player.pitch) * speed + (0.1 + (Math.random() - Math.random()) * 0.1) * TICKS_PER_SECOND;
entity.vz = -Math.cos(player.yaw) * cos_pitch * speed + Math.sin(spread_angle) * spread; entity.vz = -Math.cos(player.yaw) * cos_pitch * speed + Math.sin(spread_angle) * spread;
// one drawn with a model lands facing the way they threw it
entity.yaw = player.yaw;
return entity; return entity;
} }
@@ -1224,6 +1227,10 @@ export class GameServer {
this.#attack_entity(player, message.id); this.#attack_entity(player, message.id);
} }
break; break;
case "interact_entity":
// a client that hadn't heard it's using an item yet, still clicking
if (typeof message.id === "string" && !player.using) this.#interact_entity(player, message.id);
break;
case "swing": case "swing":
player.attack_strength_ticker = 0; player.attack_strength_ticker = 0;
break; break;
@@ -1380,6 +1387,19 @@ export class GameServer {
} }
// right click at nothing: eating, or the item's on_use // right click at nothing: eating, or the item's on_use
// a right click on an entity, like minecraft's ServerboundInteractPacket: mods' entity_interact, then the held item
// is used like on nothing, unless one of them stopped it. out of reach, or gone already, it's only that use
#interact_entity(player: ServerPlayer, id: string) {
const entity = this.entities.get_entity(id);
if (entity && !entity.removed && player.alive && this.#entity_in_reach(player, entity)) {
const player_api = this.mods.player(player);
const event = { player: player_api, entity: entity_ref(entity), item: player_api.held_item, cancel: false };
this.mods.before.entity_interact.emit(event);
if (event.cancel) return;
}
this.#use_item(player);
}
#use_item(player: ServerPlayer): boolean { #use_item(player: ServerPlayer): boolean {
return this.#eat(player) || this.#use_item_components(player, undefined); return this.#eat(player) || this.#use_item_components(player, undefined);
} }
@@ -2639,7 +2659,7 @@ export class GameServer {
} }
// from the eyes to the closest point of its box // from the eyes to the closest point of its box
#entity_in_reach(player: ServerPlayer, entity: LivingEntity) { #entity_in_reach(player: ServerPlayer, entity: Entity) {
const eye_y = player.y + player.eye_height; const eye_y = player.y + player.eye_height;
const half = entity.width / 2; const half = entity.width / 2;
const dx = Math.max(entity.x - half - player.x, 0, player.x - entity.x - half); const dx = Math.max(entity.x - half - player.x, 0, player.x - entity.x - half);
+10 -1
View File
@@ -92,6 +92,7 @@ import { Mob } from "./entity/mob.ts";
import { BUILTIN_GOALS, mob_goals } from "./mob_behaviors.ts"; import { BUILTIN_GOALS, mob_goals } from "./mob_behaviors.ts";
import { create_entity } from "./entity/entity_types.ts"; import { create_entity } from "./entity/entity_types.ts";
import { BLOCK_DROP_PICKUP_DELAY, ItemEntity } from "./entity/item_entity.ts"; import { BLOCK_DROP_PICKUP_DELAY, ItemEntity } from "./entity/item_entity.ts";
import { ObjectEntity } from "./entity/mod_entity.ts";
import { attribute_type, type AttributeType, MODIFIER_OPERATIONS } from "./entity/attributes.ts"; import { attribute_type, type AttributeType, MODIFIER_OPERATIONS } from "./entity/attributes.ts";
import { effect_type, EffectInstance, type EffectType } from "./entity/effects.ts"; import { effect_type, EffectInstance, type EffectType } from "./entity/effects.ts";
import { biome_season } from "@/common/worldgen/biomes.ts"; import { biome_season } from "@/common/worldgen/biomes.ts";
@@ -192,6 +193,7 @@ export class ModRuntime {
block_break: new Signal(), block_break: new Signal(),
block_place: new Signal(), block_place: new Signal(),
block_interact: new Signal(), block_interact: new Signal(),
entity_interact: new Signal(),
chat_send: new Signal(), chat_send: new Signal(),
entity_damage: new Signal(), entity_damage: new Signal(),
}; };
@@ -1853,8 +1855,15 @@ export function entity_ref(entity: Entity): EntityRef {
kill(cause = "script") { kill(cause = "script") {
entity.kill(String(cause)); entity.kill(String(cause));
}, },
get_item: () => entity instanceof ItemEntity ? item_copy(entity.item) : undefined, get_item() {
const item = entity instanceof ItemEntity || entity instanceof ObjectEntity ? entity.item : undefined;
return item ? item_copy(item) : undefined;
},
set_item(item) { set_item(item) {
if (entity instanceof ObjectEntity) {
if (!entity.removed) entity.item = item && item.count > 0 ? new_stack(item) : undefined;
return;
}
if (!(entity instanceof ItemEntity)) throw new Error(`${entity.type} isn't an item lying around`); if (!(entity instanceof ItemEntity)) throw new Error(`${entity.type} isn't an item lying around`);
if (entity.removed) return; if (entity.removed) return;
if (!item || item.count <= 0) entity.remove(); if (!item || item.count <= 0) entity.remove();
+31
View File
@@ -92,6 +92,19 @@ Deno.test("a connecting block joins the same block beside it, and parts when it'
assertEquals(state(0, 100, 0, "east"), 0); assertEquals(state(0, 100, 0, "east"), 0);
}); });
Deno.test("a connecting block that joins solid blocks joins the full side of another block too", async () => {
const { t, hold, state } = await setup();
t.send(1, { type: "chat", text: "/give dangerous_business:iron_bars" });
hold(4);
t.game.set_block(1, 100, 0, FLOOR);
t.send(1, { type: "use_block", x: 0, y: 99, z: 0, face: "top", hit: [0.5, 1, 0.5] });
assertEquals(state(0, 100, 0, "east"), 1);
assertEquals(state(0, 100, 0, "west"), 0);
t.game.set_block(1, 100, 0, "cubi:air");
assertEquals(state(0, 100, 0, "east"), 0);
});
Deno.test("a block with a random look picks the same one wherever it's placed again", async () => { Deno.test("a block with a random look picks the same one wherever it's placed again", async () => {
const { t, hold, state } = await setup(); const { t, hold, state } = await setup();
hold(2); hold(2);
@@ -472,3 +485,21 @@ Deno.test("a jester's music box and scream play from as far as it's got, for a p
set_mods_client(undefined as unknown as Client); set_mods_client(undefined as unknown as Client);
Deno.removeSync(dir, { recursive: true }); Deno.removeSync(dir, { recursive: true });
}); });
Deno.test("dropped scrap lies around as scrap, picked up by right clicking it into a free hotbar slot", async () => {
const { t } = await setup();
const alice = t.game.players()[0];
const inventory = alice.inventory;
const scrap = t.game.spawn_item(0.5, 100, 2.5, new ItemStack("dangerous_business:air_horn"));
assertEquals(scrap.type, "dangerous_business:scrap");
// with every hotbar slot taken it stays where it is
for (let slot = 0; slot < 9; slot++) inventory.set_item(slot, new ItemStack(FLOOR));
t.send(1, { type: "interact_entity", id: scrap.id });
assert(!scrap.removed);
inventory.set_item(5, undefined);
t.send(1, { type: "interact_entity", id: scrap.id });
assert(scrap.removed);
assertEquals(inventory.get_item(5)?.type_id, "dangerous_business:air_horn");
});
+44 -1
View File
@@ -5,7 +5,7 @@
import { assert, assertAlmostEquals, assertEquals } from "@std/assert"; import { assert, assertAlmostEquals, assertEquals } from "@std/assert";
import { mat4 } from "gl-matrix"; import { mat4 } from "gl-matrix";
import { display_transform, drawn_as_model, item_model_of } from "@/client/rendering/item_renderer.ts"; import { display_transform, drawn_as_model, item_model_of } from "@/client/rendering/item_renderer.ts";
import type { DisplayTransform } from "@/common/block_models.ts"; import { type DisplayTransform, FACE_INDEX } from "@/common/block_models.ts";
import { ItemStack } from "@/common/inventory.ts"; import { ItemStack } from "@/common/inventory.ts";
import { load_and_check } from "@/tools/check_mods.ts"; import { load_and_check } from "@/tools/check_mods.ts";
import { create_mod } from "@/tools/new_mod.ts"; import { create_mod } from "@/tools/new_mod.ts";
@@ -57,6 +57,49 @@ Deno.test("check-mods reports an item's model that doesn't exist", async () => {
Deno.removeSync(dir, { recursive: true }); Deno.removeSync(dir, { recursive: true });
}); });
Deno.test("an item can be drawn with an entity model, in its own texture, placed by the model's display transforms", async () => {
const dir = mods_with({ textures: { "0": "bworld:oak_planks" }, elements: [HANDLE] });
// the same handle as a bedrock model, as blockbench exports it
Deno.removeSync(`${dir}/copper_tools/models/wrench.json`);
Deno.writeTextFileSync(
`${dir}/copper_tools/models/wrench.geo.json`,
JSON.stringify({
format_version: "1.21.0",
"minecraft:geometry": [{
description: { identifier: "geometry.wrench", texture_width: 16, texture_height: 16 },
item_display_transforms: {
gui: { ...GUI, translation: [0, 0, 0], rotation_pivot: [0, 0, 0], fit_to_frame: true },
thirdperson_righthand: { rotation: [70, 45, 0] },
},
bones: [{
name: "handle",
pivot: [0, 0, 0],
cubes: [{ origin: [-1, 0, -1], size: [2, 14, 2], uv: [0, 0] }],
}],
}],
}),
);
const report = (await load_and_check(dir)).find((mod) => mod.id === "copper_tools")!.report;
assertEquals(report.errors, []);
await test_game(dir);
const wrench = new ItemStack("copper_tools:wrench", 1);
const model = item_model_of(wrench)!;
assert(drawn_as_model(wrench));
assertEquals(model.quads.length, 6);
assert(model.quads.every((quad) => quad.texture === "bworld:stick"));
// only what the engine places items with, in the places it shows them
assertEquals(model.display, { gui: { ...GUI, translation: [0, 0, 0] } });
// standing in the middle of the block, 16 pixels to it
const xs = model.quads.flatMap((quad) => quad.positions.filter((_, i) => i % 3 === 0));
const ys = model.quads.flatMap((quad) => quad.positions.filter((_, i) => i % 3 === 1));
assertEquals([Math.min(...xs), Math.max(...xs)], [7 / 16, 9 / 16]);
assertEquals([Math.min(...ys), Math.max(...ys)], [0, 14 / 16]);
// faces know which way they face, for their shading
const top = model.quads.find((quad) => quad.face === FACE_INDEX.top)!;
assert(top.positions.filter((_, i) => i % 3 === 1).every((y) => y === 14 / 16));
Deno.removeSync(dir, { recursive: true });
});
Deno.test("a display transform moves, turns around z then y then x, and scales, around the model's middle", () => { Deno.test("a display transform moves, turns around z then y then x, and scales, around the model's middle", () => {
// an item's points are centered on x and z, from 0 to 1 high // an item's points are centered on x and z, from 0 to 1 high
const near = (actual: number[], expected: number[]) => const near = (actual: number[], expected: number[]) =>
+6 -1
View File
@@ -150,11 +150,16 @@ Deno.test("an entity needs a texture and a size", () => {
Deno.test("an entity without a model is drawn as its texture, and a scripted one has no ai", () => { Deno.test("an entity without a model is drawn as its texture, and a scripted one has no ai", () => {
assertEquals(validate_entity({ id: "a:b", texture: "a:b", behavior: "scripted", width: 0.25, height: 0.25 }), []); assertEquals(validate_entity({ id: "a:b", texture: "a:b", behavior: "scripted", width: 0.25, height: 0.25 }), []);
assertEquals(validate_entity({ id: "a:b", texture: "a:b", behavior: "flying", width: 0.25, height: 0.25 }), [ assertEquals(validate_entity({ id: "a:b", texture: "a:b", behavior: "flying", width: 0.25, height: 0.25 }), [
'behavior must be "animal", "monster", "scripted" or a behavior id like "my_mod:thing"', 'behavior must be "animal", "monster", "scripted", "object" or a behavior id like "my_mod:thing"',
]); ]);
assertEquals(validate_entity({ id: "a:b", texture: "a:b", behavior: "a:flying", width: 0.25, height: 0.25 }), []); assertEquals(validate_entity({ id: "a:b", texture: "a:b", behavior: "a:flying", width: 0.25, height: 0.25 }), []);
}); });
Deno.test("only an object can go without a texture, it's drawn as the item it holds", () => {
assertEquals(validate_entity({ id: "a:b", behavior: "object", width: 0.5, height: 0.5 }), []);
assertEquals(validate_entity({ id: "a:b", width: 0.5, height: 0.5 }).length, 1);
});
Deno.test("an entity can say it doesn't jump and how far it drops, in whole blocks", () => { Deno.test("an entity can say it doesn't jump and how far it drops, in whole blocks", () => {
const entity = { id: "a:b", texture: "a:b", width: 1, height: 1 }; const entity = { id: "a:b", texture: "a:b", width: 1, height: 1 };
assertEquals(validate_entity({ ...entity, jumps: false, max_fall: 0 }), []); assertEquals(validate_entity({ ...entity, jumps: false, max_fall: 0 }), []);
+141
View File
@@ -0,0 +1,141 @@
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
// SPDX-License-Identifier: AGPL-3.0-or-later
// items that lie around as an entity of their own instead of a cubi:item, holding the stack, and right clicking
// entities, which mods' entity_interact handles
import { assert, assertEquals } from "@std/assert";
import { ItemStack } from "@/common/inventory.ts";
import { ObjectEntity } from "@/server/game/entity/mod_entity.ts";
import { load_and_check } from "@/tools/check_mods.ts";
import { copy_dir, stone_floor, test_game } from "./helpers.ts";
// logs every entity_interact, cancelling it while the player sneaks, and every use of the wrench
const SERVER_SCRIPT = `
import type { ServerContext } from "cubi/server";
export function server(ctx: ServerContext) {
const log = (key: string, value: unknown) => {
const all = ctx.storage.get<Record<string, unknown[]>>("log") ?? {};
(all[key] ??= []).push(value);
ctx.storage.set("log", all);
};
ctx.events.before.entity_interact.subscribe((event) => {
log("interact", [event.entity.type, event.entity.get_item()?.data, event.item?.id]);
if (event.player.is_sneaking()) event.cancel = true;
});
ctx.components.register_item("testmod:wrench", {
on_use() { log("wrench", true); },
});
}
`;
function test_mods(crate_entity = "testmod:crate", crate_behavior = "object") {
const dir = Deno.makeTempDirSync({ prefix: "bworld_objects_" });
copy_dir("mods/bworld", `${dir}/bworld`);
const mod = `${dir}/testmod`;
for (const folder of ["entities", "items", "scripts"]) Deno.mkdirSync(`${mod}/${folder}`, { recursive: true });
const write = (path: string, json: unknown) => Deno.writeTextFileSync(`${mod}/${path}`, JSON.stringify(json));
write("manifest.json", {
format_version: 1,
id: "testmod",
name: "Test",
version: "1.0.0",
dependencies: [{ id: "bworld", version: "*" }],
main: "scripts/main.ts",
});
write("entities/crate.json", {
format_version: 1,
entity: { id: "testmod:crate", behavior: crate_behavior, texture: "bworld:stone", width: 0.5, height: 0.5 },
});
write("items/crate.json", {
format_version: 1,
item: { id: "testmod:crate", texture: "bworld:stone", entity: crate_entity, max_stack: 1 },
});
write("items/wrench.json", {
format_version: 1,
item: { id: "testmod:wrench", texture: "bworld:stone", components: { "testmod:wrench": {} } },
});
Deno.writeTextFileSync(`${mod}/scripts/main.ts`, SERVER_SCRIPT);
return dir;
}
// alice on a stone floor at y 100, looking north at a crate a block in front of her holding data
async function setup() {
const dir = test_mods();
const t = await test_game(dir);
t.join(1, "alice");
stone_floor(t.game);
t.send(1, { type: "move", x: 0.5, y: 100, z: 2.5, yaw: 0, pitch: 0 });
const alice = t.game.players()[0];
const log = () => (t.game.mods.storage.testmod?.log ?? {}) as Record<string, unknown[]>;
return { ...t, dir, alice, log };
}
const crates = (game: Awaited<ReturnType<typeof test_game>>["game"]) =>
game.entities.all().filter((entity) => entity instanceof ObjectEntity);
Deno.test("an item with an entity drops as that entity holding the stack, which lands and is saved with it", async () => {
const { game, send, take, alice, dir } = await setup();
send(1, { type: "chat", text: "/give testmod:crate" });
alice.inventory.get_item(0)!.data = { value: 42 };
take(1);
send(1, { type: "drop_item", menu: 0, slot: 0, all: false });
assertEquals(game.item_entities(), [], "it isn't a cubi:item");
const [crate] = crates(game);
assertEquals(crate.type, "testmod:crate");
assertEquals(crate.item?.data, { value: 42 });
const added = take(1).find((m) => m.type === "add_entity");
assertEquals(added?.entity.data.item, { id: "testmod:crate", count: 1, data: { value: 42 } });
for (let i = 0; i < 60; i++) game.tick();
assert(crate.on_ground, "it fell onto the floor");
assertEquals(crate.y, 100);
assertEquals(crate.yaw, alice.yaw, "it lies the way it was thrown");
// walking into it doesn't pick it up
send(1, { type: "move", x: crate.x, y: 100, z: crate.z, yaw: 0, pitch: 0 });
for (let i = 0; i < 5; i++) game.tick();
assert(!crate.removed);
assertEquals(alice.inventory.get_item(0), undefined);
const reloaded = await test_game(dir, game.save());
const [loaded] = crates(reloaded.game);
assertEquals(loaded.item?.to_data(), { id: "testmod:crate", count: 1, data: { value: 42 } });
Deno.removeSync(dir, { recursive: true });
});
Deno.test("right clicking an entity in reach fires entity_interact, then uses the held item unless it's cancelled", async () => {
const { game, send, log, dir } = await setup();
const crate = game.spawn_item(0.5, 100, 1.5, new ItemStack("testmod:crate"));
send(1, { type: "chat", text: "/give testmod:wrench" });
send(1, { type: "interact_entity", id: crate.id });
assertEquals(log()["interact"], [["testmod:crate", undefined, "testmod:wrench"]]);
assertEquals(log()["wrench"], [true], "nothing cancelled it");
send(1, { type: "move", x: 0.5, y: 100, z: 2.5, yaw: 0, pitch: 0, sneaking: true });
send(1, { type: "interact_entity", id: crate.id });
assertEquals(log()["interact"].length, 2);
assertEquals(log()["wrench"], [true], "cancelling it stops the wrench being used");
// out of reach only the wrench is used, like a click on nothing
send(1, { type: "move", x: 0.5, y: 100, z: 2.5, yaw: 0, pitch: 0 });
crate.set_position(0.5, 100, -20);
send(1, { type: "interact_entity", id: crate.id });
assertEquals(log()["interact"].length, 2);
assertEquals(log()["wrench"], [true, true]);
Deno.removeSync(dir, { recursive: true });
});
Deno.test("check-mods reports an item's entity that doesn't exist or isn't an object", async () => {
const errors = async (dir: string) => {
const report = (await load_and_check(dir)).find((mod) => mod.id === "testmod")!.report;
Deno.removeSync(dir, { recursive: true });
return report.errors.join("\n");
};
const missing = await errors(test_mods("testmod:nothing"));
assert(missing.includes("entity testmod:nothing doesn't exist"), missing);
const animal = await errors(test_mods("testmod:crate", "animal"));
assert(animal.includes(`entity testmod:crate has to be an "object"`), animal);
assertEquals(await errors(test_mods()), "");
});