Campfire: a full campfire's use does not swing the arm
CampfireBlock.useItemOn returns SUCCESS_SERVER (a swing) only when placeFood took the item, and CONSUME (no swing) when all four slots are taken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8666,9 +8666,10 @@ impl Game<'_> {
|
||||
}
|
||||
if allow_block_actions
|
||||
&& let Some(hit) = self.pick()
|
||||
&& self.use_on_campfire(hit.pos)?
|
||||
&& let Some(placed) = self.use_on_campfire(hit.pos)?
|
||||
{
|
||||
return Ok(UseResult::Success { swing: true });
|
||||
// SUCCESS_SERVER swings; a full campfire's CONSUME does not.
|
||||
return Ok(UseResult::Success { swing: placed });
|
||||
}
|
||||
// BucketItem has no useOn: a guest's UseItemOn leaves it to UseItem.
|
||||
let bucket = horizon_client::items::bucket_contents(&stack.item);
|
||||
|
||||
@@ -22,21 +22,22 @@ impl Game<'_> {
|
||||
/// input (`RecipePropertySet.CAMPFIRE_INPUT`): on a server level the food
|
||||
/// goes into the first free slot (`placeFood`), and the use is consumed
|
||||
/// whether or not there was room. A client of a server leaves the placing
|
||||
/// to the server. False when this isn't a campfire use, so the item's own
|
||||
/// use runs.
|
||||
pub(super) fn use_on_campfire(&mut self, pos: [i32; 3]) -> Result<bool> {
|
||||
/// to the server. Whether the food went in; None when this isn't a
|
||||
/// campfire use, so the item's own use runs.
|
||||
pub(super) fn use_on_campfire(&mut self, pos: [i32; 3]) -> Result<Option<bool>> {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if !is_campfire(&self.res.facts().get(state).name) {
|
||||
return Ok(false);
|
||||
return Ok(None);
|
||||
}
|
||||
let Some(held) = self.held().cloned() else {
|
||||
return Ok(false);
|
||||
return Ok(None);
|
||||
};
|
||||
let Some(time) = self.res.recipes().cook(KIND, &held).map(|r| r.time as i32) else {
|
||||
return Ok(false);
|
||||
return Ok(None);
|
||||
};
|
||||
// A client of a server predicts the placing; the server decides.
|
||||
if self.remote.is_some() {
|
||||
return Ok(true);
|
||||
return Ok(Some(true));
|
||||
}
|
||||
let key = (pos[0], pos[1], pos[2]);
|
||||
let placed = match self.world.block_entities.get_mut(&key) {
|
||||
@@ -58,7 +59,7 @@ impl Game<'_> {
|
||||
);
|
||||
self.mark_block_entity_updated(key);
|
||||
}
|
||||
Ok(true)
|
||||
Ok(Some(placed))
|
||||
}
|
||||
|
||||
/// `CampfireBlockEntity.cookTick` of a lit campfire, `cooldownTick` of an
|
||||
|
||||
Reference in New Issue
Block a user