Docs » API reference » PlacedObject

PlacedObject

Something placed that is more than a block: furniture, stations, chests, beds, doors, crops, and server objects made from content packs' models.

A handle to something in the game. Once that thing is gone, its calls fail with Gone. You get one from world.objects_near(...), world.object_at(...), and events.

Methods

MethodDescription
fn item(&self) -> Result<ItemType>ItemType item()What it is.
fn at(&self) -> Result<BlockPos>BlockPos at()Its first block.
fn facing(&self) -> Result<f64>double facing()Which way it faces, in degrees.
fn station(&self) -> Result<Option<Station>>Optional<Station> station()What kind of station it is, if one.
fn open(&self) -> Result<bool>boolean open()Whether a door or lid stands open.
fn crop_percent(&self) -> Result<Option<i64>>Optional<Long> cropPercent()How grown a crop is, 0 to 100.
fn model(&self) -> Result<Option<Model>>Optional<Model> model()The content pack's model it is made from, if a server object (none while its pack is not in use).
fn container(&self) -> Result<Option<Container>>Optional<Container> container()Its contents, for a chest, barrel or shelf.
fn set_open(&self, open: bool) -> Result<()>void setOpen(boolean open) world_editOpens or shuts a door or lid.
fn remove(&self, drop: bool) -> Result<()>void remove(boolean drop) world_editTakes it down, dropping it as an item or not (a server object drops nothing).
fn play(&self, clip: &str, looping: bool) -> Result<()>void play(String clip, boolean looping) world_editHas a server object play one of its model's animations, from its start (again if it is playing), once (holding its last frame) or looping; an empty name goes back to idle (or open while it stands open).

Container

A chest's, barrel's or shelf's slots.

A handle to something in the game. Once that thing is gone, its calls fail with Gone.

MethodDescription
fn slots(&self) -> Result<i64>long slots()How many slots.
fn get(&self, slot: i64) -> Result<Option<ItemStack>>Optional<ItemStack> get(long slot)What a slot holds.
fn set(&self, slot: i64, stack: Option<ItemStack>) -> Result<()>void set(long slot, ItemStack stack) world_editSets a slot.
fn add(&self, stack: ItemStack) -> Result<Option<ItemStack>>Optional<ItemStack> add(ItemStack stack) world_editAdds where it fits; returns what did not.

Station

A crafting station.

One of a fixed set of values.

ValueMeaning
Station::WorkbenchStation.WORKBENCHThe workbench.
Station::AnvilStation.ANVILThe anvil.
Station::FletchingBenchStation.FLETCHING_BENCHThe fletching bench.
Station::ForgeStation.FORGEThe forge.
Station::CauldronStation.CAULDRONThe brewing cauldron.
Station::CampfireStation.CAMPFIREA campfire's rim.
Station::CookingPotStation.COOKING_POTA cooking pot over a campfire.

Events

Related events: ObjectPlacing, ObjectRemoved, ContainerOpening, DoorUsed.