Delete pub items nothing uses, and the stubs that hid unused code
93 pub items (78 functions and methods, 14 constants, 1 struct) in horizon-client, horizon-world, horizon-core, horizon-friends and horizon-server-files had no caller anywhere in the repository: not in the crate, the other crates, the examples, the tests or the binaries. rustc can't flag them because horizon-client and the others are libraries, where a pub item counts as used. The imports and the private helpers only they used go with them (title.rs date_string, goals.rs flag_index). Also drops the #[allow(dead_code)]/#[allow(unused)] items that only hid dead code: chat_debug_fill, merchant_title and Goals::locked_by had no caller, and four stubs (_keep, _unused, _rule_kind, const _) existed only to keep an import used. LightTables::from_parts is used by its tests, so it is #[cfg(test)] instead of allowed. Protocol id tables and entity data serializer ids stay: they mirror vanilla's registries in full. The launcher's three unused items are left for a launcher PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
//! `banner_patterns` layers carried by banner items, shields and placed
|
||||
//! banners, and the loom rules of `LoomMenu` (selectable patterns, the
|
||||
//! six-layer limit and the result stack).
|
||||
use crate::{block_entity_render::DYES, item_data, items::ItemStack, items::Items};
|
||||
use crate::{block_entity_render::DYES, items::ItemStack, items::Items};
|
||||
use horizon_world::nbt::Tag;
|
||||
use serde_json::Value;
|
||||
use std::{collections::HashMap, fs, path::Path, sync::Arc};
|
||||
@@ -261,12 +261,6 @@ pub fn layers_from_nbt(tag: Option<&Tag>) -> Vec<BannerLayer> {
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
/// Keeps `item_data` linked: the `StackData` fields the banner code reads.
|
||||
pub fn set_layers(stack: &mut ItemStack, layers: Vec<BannerLayer>) {
|
||||
let data: &mut item_data::StackData = stack.data_mut();
|
||||
data.banner_patterns = layers;
|
||||
stack.tidy();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
@@ -144,9 +144,6 @@ impl BlockEntities {
|
||||
pub fn set_states(&mut self, states: Vec<Ticking>) {
|
||||
self.states = states;
|
||||
}
|
||||
pub fn take_states(&mut self) -> Vec<Ticking> {
|
||||
std::mem::take(&mut self.states)
|
||||
}
|
||||
pub fn ticking(&self, state: u32) -> Ticking {
|
||||
self.states.get(state as usize).copied().unwrap_or_default()
|
||||
}
|
||||
|
||||
@@ -382,10 +382,6 @@ impl Shulker {
|
||||
}
|
||||
out
|
||||
}
|
||||
/// `getProgress(a)`: `Mth.lerp(a, progressOld, progress)`.
|
||||
pub fn get_progress(&self, a: f32) -> f32 {
|
||||
self.progress_old + a * (self.progress - self.progress_old)
|
||||
}
|
||||
/// `ShulkerBoxBlock.canOpen`: a closed box only opens when its lid has room
|
||||
/// (`level.noCollision` of the half-block lid box, deflated by 1e-6).
|
||||
pub fn lid_box(pos: [i32; 3], facing: u8) -> [f64; 6] {
|
||||
@@ -668,14 +664,6 @@ impl Skull {
|
||||
self.animating = false;
|
||||
}
|
||||
}
|
||||
/// `getAnimation(a)`.
|
||||
pub fn get_animation(&self, a: f32) -> f32 {
|
||||
if self.animating {
|
||||
self.tick_count as f32 + a
|
||||
} else {
|
||||
self.tick_count as f32
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `DecoratedPotBlockEntity.WobbleStyle`.
|
||||
|
||||
@@ -875,13 +875,6 @@ impl BlockEntityRenderer {
|
||||
visibility: None,
|
||||
}
|
||||
}
|
||||
/// The standing banner's pole-and-bar and flag models (`BannerRenderer.submitSpecial`).
|
||||
pub fn banner_models(&self) -> Option<(&ModelPart, &ModelPart)> {
|
||||
Some((
|
||||
self.models.get("standing_banner")?,
|
||||
self.models.get("standing_banner_flag")?,
|
||||
))
|
||||
}
|
||||
fn kind(&self, state: u32) -> &Kind {
|
||||
self.kinds.get(state as usize).unwrap_or(&Kind::None)
|
||||
}
|
||||
|
||||
@@ -169,10 +169,6 @@ impl TickRateManager {
|
||||
self.frozen_ticks_to_run -= 1;
|
||||
}
|
||||
}
|
||||
/// `isEntityFrozen` for an entity that is not (and does not carry) a player.
|
||||
pub fn is_entity_frozen(&self, is_player_or_carries_player: bool) -> bool {
|
||||
!self.runs_normally() && !is_player_or_carries_player
|
||||
}
|
||||
}
|
||||
|
||||
/// What `/tick sprint` reports when it ends.
|
||||
|
||||
@@ -812,14 +812,6 @@ pub fn java_parse_int(s: &str) -> Option<i32> {
|
||||
}
|
||||
s.parse().ok()
|
||||
}
|
||||
/// Long.parseLong.
|
||||
pub fn java_parse_long(s: &str) -> Option<i64> {
|
||||
let digits = s.strip_prefix(['-', '+']).unwrap_or(s);
|
||||
if digits.is_empty() || !digits.chars().all(|c| c.is_ascii_digit()) {
|
||||
return None;
|
||||
}
|
||||
s.parse().ok()
|
||||
}
|
||||
/// Double.parseDouble over the characters StringReader reads as a number.
|
||||
pub fn java_parse_double(s: &str) -> Option<f64> {
|
||||
let t = s.trim_matches(|c: char| c <= ' ');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! ComponentSerialization.CODEC and Style.Serializer.MAP_CODEC decoding of
|
||||
//! SNBT text components, with the data-fixer-upper error messages
|
||||
//! (ComponentArgument, StyleArgument and component-valued item data).
|
||||
use super::codec::{get, no_key, not_list, not_map, snbt};
|
||||
use super::codec::{get, no_key, not_list, not_map};
|
||||
use horizon_world::nbt::{Compound, Tag};
|
||||
|
||||
/// A DataResult error: its message and whether it carries a partial result.
|
||||
@@ -362,7 +362,3 @@ pub fn decode_style(t: &Tag) -> Result<(), String> {
|
||||
_ => Err(not_map(t)),
|
||||
}
|
||||
}
|
||||
#[allow(unused)]
|
||||
fn _keep(t: &Tag) -> String {
|
||||
snbt(t)
|
||||
}
|
||||
|
||||
@@ -632,10 +632,6 @@ pub fn parse_predicate(reader: &mut Reader, reg: &Registries) -> CmdResult<ItemI
|
||||
pub fn suggest_predicate(builder: &mut SuggestionsBuilder, reg: &Registries) {
|
||||
PREDICATE.with(|g| g.parse_for_suggestions_with(builder, Some(reg)));
|
||||
}
|
||||
#[allow(unused)]
|
||||
fn _unused(t: &Tag) -> String {
|
||||
snbt(t)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
@@ -183,9 +183,6 @@ impl<'a> Reader<'a> {
|
||||
pub fn read_int(&mut self) -> CmdResult<i32> {
|
||||
self.number("int")
|
||||
}
|
||||
pub fn read_long(&mut self) -> CmdResult<i64> {
|
||||
self.number("long")
|
||||
}
|
||||
pub fn read_double(&mut self) -> CmdResult<f64> {
|
||||
self.number("double")
|
||||
}
|
||||
@@ -222,21 +219,6 @@ impl<'a> Reader<'a> {
|
||||
}
|
||||
Err(CommandError::tr_at("parsing.quote.expected.end", &[], self))
|
||||
}
|
||||
pub fn read_quoted_string(&mut self) -> CmdResult<String> {
|
||||
if !self.can_read() {
|
||||
return Ok(String::new());
|
||||
}
|
||||
let next = self.peek();
|
||||
if next != '"' && next != '\'' {
|
||||
return Err(CommandError::tr_at(
|
||||
"parsing.quote.expected.start",
|
||||
&[],
|
||||
self,
|
||||
));
|
||||
}
|
||||
self.skip();
|
||||
self.read_string_until(next)
|
||||
}
|
||||
pub fn read_string(&mut self) -> CmdResult<String> {
|
||||
if !self.can_read() {
|
||||
return Ok(String::new());
|
||||
@@ -539,18 +521,6 @@ impl<'a> SuggestionsBuilder<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
/// The same with a tooltip per candidate.
|
||||
pub fn suggest_matching_tooltip<'b>(
|
||||
&mut self,
|
||||
candidates: impl IntoIterator<Item = (&'b str, String)>,
|
||||
) {
|
||||
let lower = self.remaining_lower();
|
||||
for (c, tip) in candidates {
|
||||
if args::matches_sub_str(&lower, &c.to_lowercase()) {
|
||||
self.suggest_tooltip(c, tip);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// String.compareToIgnoreCase.
|
||||
pub fn compare_ignore_case(a: &str, b: &str) -> std::cmp::Ordering {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
//! SnbtGrammar and TagParser: vanilla's packrat SNBT grammar, with its
|
||||
//! error messages and completion suggestions, producing NBT tags.
|
||||
use super::packrat::{
|
||||
Grammar, Reason, Rule, State, Sugg, Term, Value, alt, ch, chs, look, opt, seq,
|
||||
};
|
||||
use super::packrat::{Grammar, Reason, State, Sugg, Term, Value, alt, ch, chs, look, opt, seq};
|
||||
use super::{CmdResult, CommandError, Reader, SuggestionsBuilder};
|
||||
use horizon_world::nbt::{Compound, JavaString, Tag};
|
||||
use std::rc::Rc;
|
||||
@@ -981,5 +979,3 @@ pub fn rule_in<V: super::packrat::Value>(
|
||||
}
|
||||
}
|
||||
}
|
||||
#[allow(unused)]
|
||||
fn _rule_kind(_: Rule<SV>) {}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! mode keywords are read back from the parsed literals.
|
||||
use super::{
|
||||
Dispatcher,
|
||||
args::{ArgType, GameMode, Resource, integer},
|
||||
args::{ArgType, Resource, integer},
|
||||
};
|
||||
use crate::gamerules::{RULES, Value};
|
||||
|
||||
@@ -509,10 +509,6 @@ fn clone_mode(d: &mut Dispatcher, node: usize) {
|
||||
d.executes(l, "clone");
|
||||
}
|
||||
}
|
||||
/// Game mode names for selector `gamemode=` and the argument.
|
||||
pub fn game_modes() -> [&'static str; 4] {
|
||||
GameMode::ALL.map(GameMode::name)
|
||||
}
|
||||
/// The shared vanilla tree.
|
||||
/// Reorder node children as vanilla registers them (Brigadier keeps
|
||||
/// children in registration order; smart usage lists them that way).
|
||||
@@ -559,5 +555,3 @@ pub fn release_dispatcher() -> &'static Dispatcher {
|
||||
static TREE: std::sync::OnceLock<Dispatcher> = std::sync::OnceLock::new();
|
||||
TREE.get_or_init(|| build_with(false))
|
||||
}
|
||||
#[allow(unused)]
|
||||
const _: (u8, u8) = (ALL, GAMEMASTERS);
|
||||
|
||||
@@ -252,24 +252,6 @@ impl BlockEntity {
|
||||
};
|
||||
Some(Self::Chest(vec![None; size]))
|
||||
}
|
||||
/// The vanilla block entity type id of a container block.
|
||||
pub fn id_for_block(name: &str) -> Option<&'static str> {
|
||||
Some(match name {
|
||||
"minecraft:chest" => "minecraft:chest",
|
||||
n if n.ends_with("copper_chest") => "minecraft:chest",
|
||||
"minecraft:trapped_chest" => "minecraft:trapped_chest",
|
||||
"minecraft:barrel" => "minecraft:barrel",
|
||||
"minecraft:hopper" => "minecraft:hopper",
|
||||
"minecraft:dispenser" => "minecraft:dispenser",
|
||||
"minecraft:dropper" => "minecraft:dropper",
|
||||
"minecraft:furnace" => "minecraft:furnace",
|
||||
"minecraft:blast_furnace" => "minecraft:blast_furnace",
|
||||
"minecraft:smoker" => "minecraft:smoker",
|
||||
n if n.ends_with("shulker_box") => "minecraft:shulker_box",
|
||||
"minecraft:crafter" => "minecraft:crafter",
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
pub fn id(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Chest(items) => match items.len() {
|
||||
|
||||
@@ -17,8 +17,6 @@ use std::{
|
||||
pub const CAPACITY: usize = 240;
|
||||
/// `AbstractDebugChart.CHART_HEIGHT`.
|
||||
pub const CHART_HEIGHT: i32 = 60;
|
||||
/// `TpsDebugDimensions`: a tick sample's values.
|
||||
pub const FULL_TICK: usize = 0;
|
||||
pub const TICK_SERVER_METHOD: usize = 1;
|
||||
pub const SCHEDULED_TASKS: usize = 2;
|
||||
pub const IDLE: usize = 3;
|
||||
@@ -252,10 +250,6 @@ impl Chart {
|
||||
pub fn width(max_width: i32) -> i32 {
|
||||
(CAPACITY as i32 + 2).min(max_width)
|
||||
}
|
||||
/// `getFullHeight`: the box and the min/avg/max line above it.
|
||||
pub fn full_height() -> i32 {
|
||||
CHART_HEIGHT + 9
|
||||
}
|
||||
/// `AbstractDebugChart.extractRenderState`.
|
||||
pub fn draw(
|
||||
self,
|
||||
|
||||
@@ -359,10 +359,6 @@ impl Enchantments {
|
||||
}
|
||||
out
|
||||
}
|
||||
/// Whether a stack draws the enchantment glint.
|
||||
pub fn has_glint(&self, stack: &ItemStack) -> bool {
|
||||
stack.has_any_enchantments() || self.props(&stack.item).is_some_and(|p| p.glint)
|
||||
}
|
||||
|
||||
// ---- Enchanting table (EnchantmentHelper) ----
|
||||
|
||||
@@ -514,19 +510,6 @@ impl Enchantments {
|
||||
.is_some_and(|e| e.effects.get(component).is_some())
|
||||
})
|
||||
}
|
||||
/// The highest level among enchantments on `stack` that have `component`.
|
||||
pub fn component_level(&self, stack: &ItemStack, component: &str) -> u32 {
|
||||
stack
|
||||
.enchantments()
|
||||
.iter()
|
||||
.filter(|(id, _)| {
|
||||
self.get(id)
|
||||
.is_some_and(|e| e.effects.get(component).is_some())
|
||||
})
|
||||
.map(|(_, l)| *l)
|
||||
.max()
|
||||
.unwrap_or(0)
|
||||
}
|
||||
/// `minecraft:attributes` contributions of `stack`: (attribute, id, amount, operation).
|
||||
pub fn attributes(&self, stack: &ItemStack) -> Vec<(String, String, f64, String)> {
|
||||
let mut out = Vec::new();
|
||||
|
||||
@@ -289,15 +289,6 @@ impl Default for HandHeights {
|
||||
}
|
||||
}
|
||||
}
|
||||
/// What `FirstPersonHandsAndItems.tick` decides about a hand's visible item.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct HandChange {
|
||||
/// The visible item is not the hand's item after the instant replacement
|
||||
/// (`mainHandItem != nextMainHand`): the hand lowers.
|
||||
pub changed: bool,
|
||||
/// The visible item becomes the hand's item this tick.
|
||||
pub replace: bool,
|
||||
}
|
||||
impl HandHeights {
|
||||
/// `FirstPersonHandsAndItems.tick`'s heights. `changed` says per hand
|
||||
/// whether the visible item differs from the held one once
|
||||
|
||||
@@ -5,7 +5,7 @@ use horizon_client::{
|
||||
chat::{Chat, ChatAction, ChatScreen, Commands, SYSTEM_INDICATOR},
|
||||
command::Registries,
|
||||
gamerules::GameRules,
|
||||
hud::{HudBatch, rgba},
|
||||
hud::HudBatch,
|
||||
screen_draw::Measure,
|
||||
text::{ClickEvent, Style, Text},
|
||||
};
|
||||
@@ -883,10 +883,6 @@ impl Game<'_> {
|
||||
.chat
|
||||
.add(&self.gui.atlas, message, None, self.ticks, focused);
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
fn chat_debug_fill(&self, batch: &mut HudBatch) {
|
||||
batch.fill(&self.gui.atlas, 0.0, 0.0, 1.0, 1.0, rgba(0, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
/// `yyyy-MM-dd_HH.mm.ss[_n].png` (Util.getFilenameFormattedDateTime, local time
|
||||
/// approximated as UTC).
|
||||
|
||||
@@ -129,23 +129,6 @@ impl Game<'_> {
|
||||
}
|
||||
/// The screen title: the custom name, else the profession (the client
|
||||
/// adds the level itself).
|
||||
#[allow(dead_code)]
|
||||
fn merchant_title(&self, state: &MerchantState) -> String {
|
||||
if let Some(name) = &state.name {
|
||||
return name.clone();
|
||||
}
|
||||
let e = &self.res.stations().enchantments;
|
||||
let profession = state.session.profession.trim_start_matches("minecraft:");
|
||||
if state.session.villager {
|
||||
e.translate(&format!("entity.minecraft.villager.{profession}"))
|
||||
.unwrap_or(profession)
|
||||
.to_owned()
|
||||
} else {
|
||||
e.translate("entity.minecraft.wandering_trader")
|
||||
.unwrap_or("Wandering Trader")
|
||||
.to_owned()
|
||||
}
|
||||
}
|
||||
/// `ServerPlayer.sendMerchantOffers`, when the offers changed.
|
||||
fn lan_send_offers(
|
||||
&mut self,
|
||||
|
||||
@@ -2307,10 +2307,6 @@ impl Renderer {
|
||||
view_formats: &config.view_formats,
|
||||
})
|
||||
}
|
||||
/// Rendering to a texture instead of the window (`--offscreen`).
|
||||
pub fn is_offscreen(&self) -> bool {
|
||||
self.surface.is_none()
|
||||
}
|
||||
/// Release the window surface before another renderer uses the same window.
|
||||
pub fn release_surface(&mut self) {
|
||||
self.surface = None;
|
||||
|
||||
@@ -119,10 +119,6 @@ impl Tile {
|
||||
}
|
||||
|
||||
impl Renderer {
|
||||
pub fn resident_lods(&self) -> usize {
|
||||
self.lods.len()
|
||||
}
|
||||
|
||||
pub fn upload_lod(&mut self, key: TileKey, mesh: &SectionMesh) {
|
||||
self.remove_lod(key);
|
||||
if let Some(bounds) = Bounds::mesh(mesh)
|
||||
|
||||
@@ -7,7 +7,6 @@ use std::collections::BTreeMap;
|
||||
|
||||
/// `ReputationEventType` amounts.
|
||||
pub const REPUTATION_CHANGE_PER_EVENT: i32 = 25;
|
||||
pub const REPUTATION_CHANGE_PER_EVERLASTING_MEMORY: i32 = 20;
|
||||
pub const REPUTATION_CHANGE_PER_TRADE: i32 = 2;
|
||||
/// `GossipContainer.DISCARD_THRESHOLD`: values below this are forgotten.
|
||||
const DISCARD_THRESHOLD: i32 = 2;
|
||||
|
||||
@@ -485,14 +485,6 @@ impl Item {
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
/// Caption and value text, split from the label ("Caption: Value").
|
||||
pub fn caption_value(self, s: &Settings) -> (String, String) {
|
||||
let label = self.label(s).plain();
|
||||
match label.split_once(": ") {
|
||||
Some((c, v)) => (c.to_owned(), v.to_owned()),
|
||||
None => (label, String::new()),
|
||||
}
|
||||
}
|
||||
pub fn slider(self, s: &Settings) -> Option<f32> {
|
||||
match self {
|
||||
Item::Vanilla(o) => o.slider_position(s),
|
||||
|
||||
@@ -783,24 +783,6 @@ impl HudBatch {
|
||||
};
|
||||
self.text_styled(atlas, &t, x, y, color, shadow)
|
||||
}
|
||||
/// `text_styled` under a pose: GUI positions scaled by `scale`, then
|
||||
/// moved to `origin` (Matrix3x2fStack translate + scale).
|
||||
pub fn text_posed(
|
||||
&mut self,
|
||||
atlas: &HudAtlas,
|
||||
text: &crate::text::Text,
|
||||
at: [f32; 2],
|
||||
color: u32,
|
||||
scale: f32,
|
||||
origin: [f32; 2],
|
||||
) -> f32 {
|
||||
let start = self.vertices.len();
|
||||
let advance = self.text_styled(atlas, text, at[0], at[1], color, true);
|
||||
for v in &mut self.vertices[start..] {
|
||||
v.pos = [origin[0] + v.pos[0] * scale, origin[1] + v.pos[1] * scale];
|
||||
}
|
||||
advance
|
||||
}
|
||||
/// Font.drawInternal: styled glyphs, shadows first, with bold, italic,
|
||||
/// underline and strikethrough. `color` is the default colour and alpha.
|
||||
pub fn text_styled(
|
||||
|
||||
@@ -124,17 +124,6 @@ impl ItemRenderState {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.layers.is_empty()
|
||||
}
|
||||
/// `pickParticleMaterial`: a random layer's particle sprite.
|
||||
pub fn pick_particle(
|
||||
&self,
|
||||
random: &mut impl horizon_core::random::RandomSource,
|
||||
) -> Option<String> {
|
||||
if self.layers.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let i = random.next_int_bound(self.layers.len() as i32).unwrap_or(0) as usize;
|
||||
self.layers.get(i).map(|l| l.particle.clone())
|
||||
}
|
||||
/// `usesBlockLight` of the first layer (GUI lighting choice).
|
||||
pub fn uses_block_light(&self) -> bool {
|
||||
self.layers.first().is_some_and(|l| l.uses_block_light)
|
||||
|
||||
@@ -295,15 +295,6 @@ impl KeyBinds {
|
||||
self.keys.insert(n, key.to_owned());
|
||||
}
|
||||
}
|
||||
/// Load `key_<name>` from options.txt; false for unknown mappings.
|
||||
pub fn set_saved(&mut self, name: &str, key: &str) -> bool {
|
||||
if MAPPINGS.iter().any(|m| m.0 == name) {
|
||||
self.set(name, key);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
pub fn saved(&self) -> Vec<(&'static str, String)> {
|
||||
MAPPINGS
|
||||
.iter()
|
||||
|
||||
@@ -104,8 +104,6 @@ pub const SNEAK: usize = 0;
|
||||
pub const SPRINT: usize = 1;
|
||||
/// Attack (mouse).
|
||||
pub const ATTACK: usize = 2;
|
||||
/// Use (mouse).
|
||||
pub const USE: usize = 3;
|
||||
|
||||
/// The `ToggleKeyMapping`s `Options` builds: sneak and sprint (keyboard,
|
||||
/// restored after a screen), attack (mouse, restored) and use (mouse, not
|
||||
|
||||
@@ -15,7 +15,6 @@ use std::{
|
||||
/// GameType ids.
|
||||
pub const SURVIVAL: i32 = 0;
|
||||
pub const CREATIVE: i32 = 1;
|
||||
pub const ADVENTURE: i32 = 2;
|
||||
pub const SPECTATOR: i32 = 3;
|
||||
|
||||
/// An effect as last sent in ClientboundUpdateMobEffectPacket.
|
||||
@@ -332,11 +331,6 @@ impl Guest {
|
||||
pub fn send(&self, packet: &play::Clientbound) {
|
||||
self.sender.send(packet.encode());
|
||||
}
|
||||
pub fn send_all(&self, packets: &[play::Clientbound]) {
|
||||
for p in packets {
|
||||
self.send(p);
|
||||
}
|
||||
}
|
||||
pub fn chunk(&self) -> (i32, i32) {
|
||||
(
|
||||
(self.position[0].floor() as i32) >> 4,
|
||||
|
||||
@@ -172,13 +172,6 @@ pub struct Hub {
|
||||
fn string(s: &str) -> Tag {
|
||||
Tag::String(JavaString::from(s))
|
||||
}
|
||||
pub fn yellow_translation(key: &str, args: &[&str]) -> Tag {
|
||||
let mut t = translatable(key, args);
|
||||
if let Tag::Compound(map) = &mut t {
|
||||
map.insert(JavaString::from("color"), string("yellow"));
|
||||
}
|
||||
t
|
||||
}
|
||||
|
||||
/// Player.getDisplayName for a player in no team: the name, suggesting
|
||||
/// `/tell NAME `, showing the player on hover and inserting the name.
|
||||
@@ -1360,21 +1353,6 @@ impl Hub {
|
||||
(!batch.is_empty()).then_some(batch)
|
||||
}
|
||||
|
||||
/// Resend a chunk to everyone who has it (a block entity changed, relight).
|
||||
pub fn resend_chunk(&mut self, world: &World, x: i32, z: i32) {
|
||||
let Some(chunk) = world.chunks.get(&(x, z)) else {
|
||||
return;
|
||||
};
|
||||
let body = self.encoder.body_in(chunk, world);
|
||||
for g in self
|
||||
.guests
|
||||
.iter()
|
||||
.filter(|g| g.sent_chunks.contains(&(x, z)))
|
||||
{
|
||||
g.sender.send(body.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/// `ChunkHolder.broadcastChanges`' light part: the light sections that
|
||||
/// changed in a column go to the players for whom it is on the border of
|
||||
/// what they track (`ChunkMap.isChunkOnTrackedBorder`); the others light
|
||||
|
||||
@@ -272,9 +272,6 @@ impl Shared {
|
||||
pub fn max_players(&self) -> usize {
|
||||
self.max_players.load(Ordering::Relaxed)
|
||||
}
|
||||
pub fn set_max_players(&self, n: usize) {
|
||||
self.max_players.store(n, Ordering::Relaxed);
|
||||
}
|
||||
pub fn release(&self, uuid: u128) {
|
||||
self.online.lock().unwrap().retain(|(u, _)| *u != uuid);
|
||||
}
|
||||
@@ -513,9 +510,6 @@ impl Lan {
|
||||
pub fn reserve(&self, uuid: u128) {
|
||||
self.shared.reserved.lock().unwrap().insert(uuid);
|
||||
}
|
||||
pub fn set_motd(&self, motd: &str) {
|
||||
*self.shared.motd.lock().unwrap() = motd.to_owned();
|
||||
}
|
||||
pub fn stop(&mut self) {
|
||||
self.shared.stop.store(true, Ordering::Relaxed);
|
||||
self.stop_listening();
|
||||
|
||||
@@ -77,12 +77,6 @@ pub fn apply_deprecated(map: &mut HashMap<String, String>, json: &[u8]) {
|
||||
}
|
||||
|
||||
impl Language {
|
||||
pub fn from_map(code: &str, map: HashMap<String, String>) -> Self {
|
||||
Self {
|
||||
code: code.to_owned(),
|
||||
map,
|
||||
}
|
||||
}
|
||||
/// ClientLanguage.loadFrom: en_us first, then the selected language, each
|
||||
/// from every namespace and every source in priority order (later sources
|
||||
/// override).
|
||||
|
||||
@@ -203,7 +203,7 @@ impl LightTables {
|
||||
Ok(tables)
|
||||
}
|
||||
/// Assembled tables (tests and benchmarks): derives the packed light cache.
|
||||
#[allow(dead_code)]
|
||||
#[cfg(test)]
|
||||
fn from_parts(cells: Vec<Cell>, occludes: Vec<bool>, faces: usize) -> Self {
|
||||
let mut tables = Self {
|
||||
cells,
|
||||
|
||||
@@ -239,10 +239,6 @@ pub enum ArmPose {
|
||||
/// Raising a trident to throw it (or to launch with Riptide).
|
||||
ThrowTrident,
|
||||
}
|
||||
/// HumanoidModel.setupAnim for piglins: `PiglinModel` poses the arms itself.
|
||||
pub fn humanoid_item(p: &mut Poses, s: &State, _holding: bool) {
|
||||
humanoid(p, s, &Hum::new(ArmPose::Empty, ArmPose::Empty));
|
||||
}
|
||||
/// HumanoidModel.setupAnim with empty hands (endermen).
|
||||
pub fn humanoid_pub(p: &mut Poses, s: &State, _m: &Mob) {
|
||||
humanoid(p, s, &Hum::new(ArmPose::Empty, ArmPose::Empty));
|
||||
|
||||
@@ -152,10 +152,6 @@ pub fn protector(heart: &mut CreakingHeart, host: &impl HeartHost) -> Option<u32
|
||||
}
|
||||
None
|
||||
}
|
||||
/// `isProtector`.
|
||||
pub fn is_protector(heart: &mut CreakingHeart, host: &impl HeartHost, id: u32) -> bool {
|
||||
protector(heart, host) == Some(id)
|
||||
}
|
||||
fn distance_to_creaking(heart: &mut CreakingHeart, pos: [i32; 3], host: &impl HeartHost) -> f64 {
|
||||
protector(heart, host)
|
||||
.and_then(|id| host.mob(id))
|
||||
|
||||
@@ -76,9 +76,6 @@ pub struct GoalSelector {
|
||||
locked: [Option<usize>; 4],
|
||||
pub disabled: u8,
|
||||
}
|
||||
fn flag_index(f: u8) -> usize {
|
||||
f.trailing_zeros() as usize
|
||||
}
|
||||
impl GoalSelector {
|
||||
pub fn add(&mut self, priority: i32, goal: impl Goal + 'static) {
|
||||
self.goals.push(Wrapped {
|
||||
@@ -174,10 +171,6 @@ impl GoalSelector {
|
||||
}
|
||||
self.locked = [None; 4];
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
fn locked_by(&self, flag: u8) -> Option<usize> {
|
||||
self.locked[flag_index(flag)]
|
||||
}
|
||||
}
|
||||
|
||||
// --- random positions (DefaultRandomPos / LandRandomPos / RandomPos) -------
|
||||
@@ -565,36 +558,6 @@ impl Mob {
|
||||
m.land_up_out_of_solid(w, p)
|
||||
})
|
||||
}
|
||||
/// LandRandomPos.getPosTowards
|
||||
pub fn land_random_pos_towards(
|
||||
&mut self,
|
||||
w: &MobWorld,
|
||||
h: i32,
|
||||
v: i32,
|
||||
to: [f64; 3],
|
||||
) -> Option<[f64; 3]> {
|
||||
let (xd, zd) = (to[0] - self.position.x, to[2] - self.position.z);
|
||||
self.pick_best(w, |m| {
|
||||
let d = m.random_direction_within(
|
||||
0.0,
|
||||
f64::from(h),
|
||||
v,
|
||||
0,
|
||||
xd,
|
||||
zd,
|
||||
std::f64::consts::FRAC_PI_2,
|
||||
)?;
|
||||
let p = m.toward(f64::from(h), d);
|
||||
if p[1] < crate::chunk::MIN_Y
|
||||
|| p[1] >= 320
|
||||
|| m.restricted(f64::from(h), p)
|
||||
|| !m.stable_destination(w, p)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
m.land_up_out_of_solid(w, p)
|
||||
})
|
||||
}
|
||||
pub fn target_info(&self, w: &MobWorld) -> Option<TargetInfo> {
|
||||
self.ai.target.and_then(|t| w.target_info(t))
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ use horizon_core::{
|
||||
// Happy ghast state: `head` the harness, `scratch[0]` 1 once set up as a
|
||||
// baby and 2 as an adult, `ai.home` the restriction, `counter`
|
||||
// the end tick of the follow-an-adult range pick.
|
||||
pub const BABY_SCALE: f64 = 0.2375;
|
||||
/// `Attributes.FLYING_SPEED` and the speed `travel` uses (`* 5 / 3`).
|
||||
pub const FLYING_SPEED: f64 = 0.05;
|
||||
pub const AIR_SPEED: f32 = 0.05 * 5.0 / 3.0;
|
||||
|
||||
@@ -250,10 +250,6 @@ pub fn nearest_players(m: &Mob) -> Vec<Who> {
|
||||
.and_then(|b| b.mem.nearest_players.value())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
/// The damage the brain remembers (`HURT_BY`).
|
||||
pub fn hurt_by_present(m: &Mob) -> bool {
|
||||
brain(m).is_some_and(|b| b.mem.hurt_by.present())
|
||||
}
|
||||
/// `HURT_BY`'s damage source entity, if a living one.
|
||||
fn hurt_by_entity(m: &Mob, w: &MobWorld) -> Option<Who> {
|
||||
let t = brain(m)?.mem.hurt_by.value()?;
|
||||
|
||||
@@ -76,14 +76,6 @@ pub fn finalize(m: &mut Mob, warm_ocean: bool) {
|
||||
m.extra.variant = u8::from(warm_ocean);
|
||||
}
|
||||
}
|
||||
/// `checkNautilusSpawnRules`: 5 to 25 blocks below sea level, water below
|
||||
/// and above.
|
||||
pub fn spawn_rules_ok(w: &MobWorld, x: i32, y: i32, z: i32) -> bool {
|
||||
let sea = 63;
|
||||
(sea - 25..=sea - 5).contains(&y)
|
||||
&& w.fluid(x, y - 1, z) == Fluid::Water
|
||||
&& w.block_name(x, y + 1, z) == "minecraft:water"
|
||||
}
|
||||
/// `getControllingPassenger`: a player on a saddled nautilus.
|
||||
pub fn controlled(m: &Mob) -> bool {
|
||||
m.rider.is_some() && m.extra.saddled
|
||||
|
||||
@@ -582,26 +582,4 @@ impl Mob {
|
||||
NavKind::Amphibious => !w.facts.is_air(w.world.block(p[0], p[1] - 1, p[2])),
|
||||
}
|
||||
}
|
||||
pub fn should_recompute_path(&self, p: [i32; 3]) -> bool {
|
||||
if self.ai.nav.delayed_recompute {
|
||||
return false;
|
||||
}
|
||||
let Some(path) = &self.ai.nav.path else {
|
||||
return false;
|
||||
};
|
||||
if path.is_done() || path.nodes.is_empty() {
|
||||
return false;
|
||||
}
|
||||
let Some(end) = path.end() else { return false };
|
||||
let mid = [
|
||||
(f64::from(end.x) + self.position.x) / 2.0,
|
||||
(f64::from(end.y) + self.position.y) / 2.0,
|
||||
(f64::from(end.z) + self.position.z) / 2.0,
|
||||
];
|
||||
let d = (f64::from(p[0]) + 0.5 - mid[0]).powi(2)
|
||||
+ (f64::from(p[1]) + 0.5 - mid[1]).powi(2)
|
||||
+ (f64::from(p[2]) + 0.5 - mid[2]).powi(2);
|
||||
let r = (path.nodes.len() - path.next) as f64;
|
||||
d < r * r
|
||||
}
|
||||
}
|
||||
|
||||
@@ -769,19 +769,6 @@ pub fn weighted_pick(list: &[SpawnEntry], random: &mut impl RandomSource) -> Opt
|
||||
None
|
||||
}
|
||||
|
||||
/// `NaturalSpawner.getRandomSpawnMobAt`.
|
||||
pub fn random_spawn_mob_at(
|
||||
list: &[SpawnEntry],
|
||||
category: &str,
|
||||
reduced_water_ambient: bool,
|
||||
random: &mut impl RandomSource,
|
||||
) -> Option<SpawnEntry> {
|
||||
if category == "water_ambient" && reduced_water_ambient && random.next_float() < 0.98 {
|
||||
return None;
|
||||
}
|
||||
weighted_pick(list, random)
|
||||
}
|
||||
|
||||
/// `SpawnerData.count().sample(random)`: a constant draws nothing.
|
||||
pub fn sample_count(entry: &SpawnEntry, random: &mut impl RandomSource) -> u32 {
|
||||
if entry.constant {
|
||||
|
||||
@@ -30,25 +30,6 @@ pub struct BiomeFacts {
|
||||
pub fn placement_ok(species: Species, w: &MobWorld, x: i32, y: i32, z: i32) -> bool {
|
||||
super::spawn_rules::is_spawn_position_ok(species, w, x, y, z)
|
||||
}
|
||||
/// `SpawnPlacements.checkSpawnRules` for a natural spawn.
|
||||
pub fn spawn_rules_ok(
|
||||
species: Species,
|
||||
w: &MobWorld,
|
||||
random: &mut impl RandomSource,
|
||||
x: i32,
|
||||
y: i32,
|
||||
z: i32,
|
||||
) -> bool {
|
||||
super::spawn_rules::check_spawn_rules(
|
||||
species,
|
||||
w,
|
||||
super::spawn_rules::Reason::Natural,
|
||||
random,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
)
|
||||
}
|
||||
/// Mob.finalizeSpawn for natural, chunk-generation and summoned mobs.
|
||||
/// `DifficultyInstance`: the local difficulty at a position.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//! other `GateBehavior`s shuffle with a random of their own, seeded with
|
||||
//! `Brain::shuffle_seed` when the brain is built.
|
||||
use super::{
|
||||
Mob, MobEvent, MobWorld, Seen, Species, Who,
|
||||
Mob, MobEvent, MobWorld, Species, Who,
|
||||
path::{Path, PathNode},
|
||||
};
|
||||
use horizon_core::{
|
||||
@@ -4156,10 +4156,6 @@ pub fn woken(m: &mut Mob, now: i64) {
|
||||
pub fn potential_job_site(m: &Mob) -> Option<[i32; 3]> {
|
||||
mem_ref(m).and_then(|mm| mm.potential_job_site.value())
|
||||
}
|
||||
/// Whether a seen mob is a villager wanting to breed (`AgeableMob::canBreed`).
|
||||
pub fn seen_can_breed(s: &Seen) -> bool {
|
||||
s.species == Species::Villager && s.in_love
|
||||
}
|
||||
/// The memories other villagers read: the interaction target, the path's
|
||||
/// nodes (while it is not done), whether a golem was seen lately and the
|
||||
/// last sleep.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! What mobs read from the level: block solidity, ray clipping for line of
|
||||
//! sight (`ClipContext.Block.COLLIDER`), sky visibility, light-dependent
|
||||
//! values and the positions of other entities.
|
||||
use super::{MobWorld, Seen, Species, Who, data};
|
||||
use super::{MobWorld, Seen, Who, data};
|
||||
use crate::{
|
||||
blocks::{BlockFacts, Fluid},
|
||||
collisions::SceneCollisions,
|
||||
@@ -269,12 +269,6 @@ impl MobWorld<'_> {
|
||||
});
|
||||
v.into_iter()
|
||||
}
|
||||
pub fn count_species(&self, species: Species) -> usize {
|
||||
self.others
|
||||
.iter()
|
||||
.filter(|s| s.species == species && s.alive)
|
||||
.count()
|
||||
}
|
||||
}
|
||||
|
||||
/// Level.clip with VISUAL shapes and no fluids: the block the segment first
|
||||
|
||||
@@ -804,11 +804,6 @@ impl SelectionModel {
|
||||
false
|
||||
}
|
||||
}
|
||||
/// Whether activating the entry asks first (`handlePackSelection`'s
|
||||
/// ConfirmScreen for an incompatible pack).
|
||||
pub fn needs_confirmation(&self, selected: bool, i: usize) -> bool {
|
||||
self.can_select(selected, i) && !self.unselected[i].compatible
|
||||
}
|
||||
/// `moveUp` / `moveDown` when allowed.
|
||||
pub fn move_by(&mut self, selected: bool, i: usize, up: bool) -> bool {
|
||||
let ok = if up {
|
||||
|
||||
@@ -384,21 +384,6 @@ impl Book {
|
||||
order,
|
||||
}
|
||||
}
|
||||
/// Which book a recipe id belongs to.
|
||||
pub fn book_of(&self, id: &str) -> Option<BookType> {
|
||||
let e = self.entries.iter().find(|e| e.id == id)?;
|
||||
Some(match e.category {
|
||||
Category::CraftingBuilding
|
||||
| Category::CraftingRedstone
|
||||
| Category::CraftingEquipment
|
||||
| Category::CraftingMisc => BookType::Crafting,
|
||||
Category::FurnaceFood | Category::FurnaceBlocks | Category::FurnaceMisc => {
|
||||
BookType::Furnace
|
||||
}
|
||||
Category::BlastBlocks | Category::BlastMisc => BookType::BlastFurnace,
|
||||
Category::SmokerFood => BookType::Smoker,
|
||||
})
|
||||
}
|
||||
/// `RecipeDisplayEntry.canCraft`: the recipe's placement ingredients
|
||||
/// (`craftingRequirements`) can all be found in `stock`.
|
||||
pub fn can_craft(&self, entry: &Entry, stock: &crate::menu::place::Stacked) -> bool {
|
||||
|
||||
@@ -750,12 +750,6 @@ fn heightmaps(chunk: &Chunk, tables: &SaveTables) -> Tag {
|
||||
)
|
||||
}))
|
||||
}
|
||||
/// The heightmaps a ClientboundLevelChunkPacketData carries (the types with
|
||||
/// sendToClient: WORLD_SURFACE, MOTION_BLOCKING, MOTION_BLOCKING_NO_LEAVES),
|
||||
/// as (network id, packed longs) in Heightmap.Types order.
|
||||
pub fn client_heightmaps(chunk: &Chunk, tables: &SaveTables) -> Vec<(i32, Vec<i64>)> {
|
||||
client_heightmaps_in(&chunk.sections, tables, MIN_Y, SECTIONS as i32 * 16)
|
||||
}
|
||||
/// The client heightmaps of a column's sections, in a level from `min_y`,
|
||||
/// `height` blocks high.
|
||||
pub fn client_heightmaps_in(
|
||||
|
||||
@@ -78,7 +78,6 @@ pub const RESONANCE: [&str; 15] = [
|
||||
];
|
||||
pub const SHRIEK: &str = "minecraft:shriek";
|
||||
pub const TENDRILS_CLICKING: &str = "minecraft:sculk_sensor_tendrils_clicking";
|
||||
pub const NO_VIBRATION_FREQUENCY: i32 = 0;
|
||||
|
||||
/// `VibrationSystem.getGameEventFrequency`.
|
||||
pub fn frequency(event: &str) -> i32 {
|
||||
@@ -567,10 +566,6 @@ pub struct WardenSpawnTracker {
|
||||
}
|
||||
impl WardenSpawnTracker {
|
||||
pub const MAX_WARNING_LEVEL: i32 = 4;
|
||||
/// Blocks around a shrieker within which players are warned.
|
||||
pub const PLAYER_SEARCH_RADIUS: f64 = 16.0;
|
||||
/// `AABB.ofSize(centre, 48, 48, 48)` for an existing warden.
|
||||
pub const WARNING_CHECK_DIAMETER: f64 = 48.0;
|
||||
const DECREASE_EVERY: i32 = 12000;
|
||||
const INCREASE_COOLDOWN: i32 = 200;
|
||||
pub fn tick(&mut self) {
|
||||
|
||||
@@ -81,10 +81,6 @@ pub fn sound_source(event: &str) -> usize {
|
||||
index("master")
|
||||
}
|
||||
}
|
||||
/// Volume multiplier of an event's source (master applied separately).
|
||||
pub fn event_volume(event: &str) -> f32 {
|
||||
source_volume(sound_source(event))
|
||||
}
|
||||
/// Volume multiplier of a sound source by index.
|
||||
pub fn source_volume(i: usize) -> f32 {
|
||||
if i == 0 {
|
||||
|
||||
@@ -317,9 +317,6 @@ impl TabList {
|
||||
self.visible = visible;
|
||||
}
|
||||
}
|
||||
pub fn is_visible(&self) -> bool {
|
||||
self.visible
|
||||
}
|
||||
/// `reset`.
|
||||
pub fn reset(&mut self) {
|
||||
self.header = None;
|
||||
|
||||
@@ -455,9 +455,6 @@ impl Text {
|
||||
}
|
||||
out
|
||||
}
|
||||
pub fn char_count(&self) -> usize {
|
||||
self.spans.iter().map(|s| s.text.chars().count()).sum()
|
||||
}
|
||||
}
|
||||
|
||||
/// The style fields of a component's JSON.
|
||||
|
||||
@@ -1630,26 +1630,6 @@ fn caret_field<'a>(
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
/// `yyyy/MM/dd HH:mm` (UTC) for a modification time in Unix seconds.
|
||||
pub fn date_label(secs: u64) -> String {
|
||||
date_string(secs)
|
||||
}
|
||||
fn date_string(secs: u64) -> String {
|
||||
// Civil date from Unix time (days-from-civil inverse), UTC.
|
||||
let days = (secs / 86400) as i64;
|
||||
let (h, m) = ((secs % 86400) / 3600, (secs % 3600) / 60);
|
||||
let z = days + 719_468;
|
||||
let era = z.div_euclid(146_097);
|
||||
let doe = z - era * 146_097;
|
||||
let yoe = (doe - doe / 1460 + doe / 36524 - doe / 146_096) / 365;
|
||||
let y = yoe + era * 400;
|
||||
let doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
|
||||
let mp = (5 * doy + 2) / 153;
|
||||
let d = doy - (153 * mp + 2) / 5 + 1;
|
||||
let mo = if mp < 10 { mp + 3 } else { mp - 9 };
|
||||
let y = if mo <= 2 { y + 1 } else { y };
|
||||
format!("{y}-{mo:02}-{d:02} {h:02}:{m:02}")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod classic_tests {
|
||||
|
||||
@@ -793,10 +793,6 @@ impl EditBox {
|
||||
text_color: rgba(224, 224, 224, 255),
|
||||
}
|
||||
}
|
||||
/// When the field gained focus, for the cursor's blink.
|
||||
pub fn focused_since(&mut self, at: Instant) {
|
||||
self.focused_at = at;
|
||||
}
|
||||
pub fn inner_width(&self) -> f32 {
|
||||
if self.bordered {
|
||||
self.width - 8.0
|
||||
|
||||
@@ -7,7 +7,6 @@ pub use horizon_core::geometry::border::BorderStatus;
|
||||
|
||||
/// `WorldBorder.MAX_SIZE` (the float 5.999997E7 as a double).
|
||||
pub const MAX_SIZE: f64 = 59_999_968.0;
|
||||
pub const MAX_CENTER: f64 = 2.999_998_4e7;
|
||||
|
||||
/// `BorderStatus.getColor`: the wall colour.
|
||||
pub fn status_color(status: BorderStatus) -> u32 {
|
||||
|
||||
@@ -168,9 +168,6 @@ impl Beardifier {
|
||||
self.kernel_junctions = junctions;
|
||||
self
|
||||
}
|
||||
pub fn affected_bounds(&self) -> Option<StructureBounds> {
|
||||
self.affected
|
||||
}
|
||||
fn sample_unchecked(&self, [x, y, z]: [i32; 3]) -> f32 {
|
||||
let mut value = 0.;
|
||||
// The kernel is a process-wide constant; resolving it once keeps the
|
||||
|
||||
@@ -13,8 +13,6 @@ impl ShapeOp {
|
||||
pub const XOR: Self = Self(6);
|
||||
pub const ONLY_FIRST: Self = Self(4);
|
||||
pub const ONLY_SECOND: Self = Self(2);
|
||||
pub const FIRST: Self = Self(12);
|
||||
pub const SECOND: Self = Self(10);
|
||||
pub const fn from_truth_table(bits: u8) -> Self {
|
||||
Self(bits & 15)
|
||||
}
|
||||
|
||||
@@ -466,34 +466,6 @@ impl PalettedContainer {
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Block ids as 16-bit values (callers whose registry fits in 16 bits).
|
||||
pub fn unpack_u16(&self, out: &mut [u16; 4096]) {
|
||||
debug_assert_eq!(self.strategy.entries(), 4096);
|
||||
match &self.palette {
|
||||
Palette::Single(value) => out.fill(*value as u16),
|
||||
Palette::List(list) => {
|
||||
let bits = usize::from(self.bits);
|
||||
let per = 64 / bits;
|
||||
let m = mask(self.bits);
|
||||
for (chunk, &word) in out.chunks_mut(per).zip(&self.words) {
|
||||
for (slot, cell) in chunk.iter_mut().enumerate() {
|
||||
let id = ((word >> (slot * bits)) & m) as usize;
|
||||
*cell = list[id] as u16;
|
||||
}
|
||||
}
|
||||
}
|
||||
Palette::Global => {
|
||||
let bits = usize::from(self.bits);
|
||||
let per = 64 / bits;
|
||||
let m = mask(self.bits);
|
||||
for (chunk, &word) in out.chunks_mut(per).zip(&self.words) {
|
||||
for (slot, cell) in chunk.iter_mut().enumerate() {
|
||||
*cell = ((word >> (slot * bits)) & m) as u16;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// A container holding `values` in the smallest configuration for their
|
||||
/// distinct count, with palette ids in first-occurrence order, like a
|
||||
/// container unpacked from disk.
|
||||
|
||||
@@ -91,9 +91,6 @@ impl<C: WorldGenTickContainers> WorldGenTickAccess<C> {
|
||||
pub fn containers_mut(&mut self) -> &mut C {
|
||||
&mut self.containers
|
||||
}
|
||||
pub fn into_containers(self) -> C {
|
||||
self.containers
|
||||
}
|
||||
pub fn schedule(&mut self, tick: ScheduledTick) -> Result<bool, C::Error> {
|
||||
Ok(self.containers.container_at(tick.pos)?.schedule(tick))
|
||||
}
|
||||
|
||||
@@ -636,7 +636,4 @@ impl LevelTicks {
|
||||
pub fn copy_area(&mut self, area: TickArea, offset: BlockPos) {
|
||||
self.schedule_copy(self.area_ticks(area), offset);
|
||||
}
|
||||
pub fn copy_area_from(&mut self, source: &Self, area: TickArea, offset: BlockPos) {
|
||||
self.schedule_copy(source.area_ticks(area), offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,6 @@ pub const PROTOCOL_VERSION: i32 = 777;
|
||||
pub const DATA_VERSION: i32 = 5023;
|
||||
/// `WorldVersion.packVersion(PackType.CLIENT_RESOURCES)`: (major, minor).
|
||||
pub const RESOURCE_PACK_FORMAT: (i64, i64) = (97, 1);
|
||||
/// `WorldVersion.packVersion(PackType.SERVER_DATA)`: (major, minor).
|
||||
pub const DATA_PACK_FORMAT: (i64, i64) = (121, 0);
|
||||
/// The Java major version the game runs on.
|
||||
pub const JAVA_VERSION: u32 = 25;
|
||||
/// `WorldVersion.stable()`: false for snapshots and pre-releases.
|
||||
pub const STABLE: bool = true;
|
||||
/// `WorldVersion.buildTime()` as `Date.toString()` prints it in UTC (`/version`).
|
||||
|
||||
@@ -296,14 +296,4 @@ impl Tunnel {
|
||||
})?;
|
||||
Ok((port, thread))
|
||||
}
|
||||
/// The protected stream itself (tests, or a client that reads it
|
||||
/// directly).
|
||||
pub fn into_stream(
|
||||
self,
|
||||
) -> (
|
||||
crypto::SecureReader<TcpStream>,
|
||||
crypto::SecureWriter<TcpStream>,
|
||||
) {
|
||||
self.secure
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,14 +190,6 @@ impl UserCache {
|
||||
result
|
||||
}
|
||||
|
||||
/// `get(UUID)`: a cached player by id (expired or not).
|
||||
pub fn get_by_id(&mut self, id: u128) -> Option<NameAndId> {
|
||||
let index = *self.by_uuid.get(&id)?;
|
||||
self.operations += 1;
|
||||
self.infos[index].last_access = self.operations;
|
||||
Some(self.infos[index].user.clone())
|
||||
}
|
||||
|
||||
/// The file's text: the 1000 most recently used entries, most recent
|
||||
/// first, as Gson writes them (compact, HTML-safe).
|
||||
pub fn to_json(&self) -> String {
|
||||
|
||||
@@ -416,11 +416,6 @@ pub type WhiteList = UserList<WhiteEntry>;
|
||||
pub type BanList = UserList<BanEntry<NameAndId>>;
|
||||
pub type IpBanList = UserList<BanEntry<String>>;
|
||||
|
||||
/// IpBanList.getIpFromAddress.
|
||||
pub fn ip_of(address: &std::net::SocketAddr) -> String {
|
||||
address.ip().to_string()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -62,9 +62,6 @@ impl<E> ProtoBlockEntities<E> {
|
||||
pub fn active(&self, position: BlockPos) -> Option<&E> {
|
||||
self.active.get(&position)
|
||||
}
|
||||
pub fn active_mut(&mut self, position: BlockPos) -> Option<&mut E> {
|
||||
self.active.get_mut(&position)
|
||||
}
|
||||
pub fn pending(&self, position: BlockPos) -> Option<&Tag> {
|
||||
self.pending.get(&position)
|
||||
}
|
||||
|
||||
@@ -157,12 +157,6 @@ impl FaceVisibility {
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Whether the state's occlusion face toward `direction` is the full square.
|
||||
pub fn full_face(&self, state: BlockStateId, direction: Direction) -> bool {
|
||||
self.states
|
||||
.get(state.0 as usize)
|
||||
.is_some_and(|s| s.faces[direction as usize] == 1)
|
||||
}
|
||||
/// The state's occlusion face toward `direction` (`getFaceOcclusionShape`) and
|
||||
/// its shared ID: 0 is the empty singleton, 1 the full-block singleton.
|
||||
pub fn occlusion_face(
|
||||
@@ -173,12 +167,6 @@ impl FaceVisibility {
|
||||
let id = self.states.get(state.0 as usize)?.faces[direction as usize];
|
||||
Some((id, &self.faces[id as usize]))
|
||||
}
|
||||
/// Whether the state's occlusion face toward `direction` is empty.
|
||||
pub fn empty_face(&self, state: BlockStateId, direction: Direction) -> bool {
|
||||
self.states
|
||||
.get(state.0 as usize)
|
||||
.is_none_or(|s| s.faces[direction as usize] == 0)
|
||||
}
|
||||
pub fn skip_rendering(
|
||||
&self,
|
||||
state: BlockStateId,
|
||||
|
||||
@@ -186,25 +186,6 @@ impl<'r> BlockSupportRegistry<'r> {
|
||||
pub fn registry(&self) -> &'r BlockRegistry {
|
||||
self.cached.registry()
|
||||
}
|
||||
pub fn support_shape<W: DynamicSupportWorld>(
|
||||
&self,
|
||||
world: &mut W,
|
||||
state: BlockStateId,
|
||||
position: [i32; 3],
|
||||
) -> Result<VoxelShape, SupportQueryError<W::Error>> {
|
||||
if let Some(shape) = self
|
||||
.cached
|
||||
.cached_shape(state)
|
||||
.map_err(SupportQueryError::Data)?
|
||||
{
|
||||
return Ok(shape.clone());
|
||||
}
|
||||
self.dynamic
|
||||
.get(&state)
|
||||
.ok_or(SupportQueryError::Unsupported(state))?
|
||||
.shape(world, position)
|
||||
.map_err(SupportQueryError::Dynamic)
|
||||
}
|
||||
pub fn is_face_sturdy<W: DynamicSupportWorld>(
|
||||
&self,
|
||||
world: &mut W,
|
||||
|
||||
@@ -524,14 +524,6 @@ impl<'r> BlockSurvivalRegistry<'r> {
|
||||
bubble_down: tag_states("minecraft:enables_bubble_column_drag_down")?,
|
||||
})
|
||||
}
|
||||
pub fn supported_states(&self) -> usize {
|
||||
self.rules.iter().filter(|r| r.is_some()).count()
|
||||
}
|
||||
pub fn supports_state(&self, state: BlockStateId) -> bool {
|
||||
self.rules
|
||||
.get(state.0 as usize)
|
||||
.is_some_and(Option::is_some)
|
||||
}
|
||||
fn read<W: SurvivalWorld>(
|
||||
&self,
|
||||
world: &mut W,
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
use crate::{
|
||||
component_patch::{ComponentMap, MissingPrototype, Patch, Prototype},
|
||||
item_durability::DurabilityStorage,
|
||||
item_use_catalog::UseComponents,
|
||||
};
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Key {
|
||||
@@ -52,13 +51,6 @@ impl DurabilityPrototype {
|
||||
}
|
||||
Self(Prototype::new(entries))
|
||||
}
|
||||
pub fn from_defaults(defaults: &UseComponents) -> Self {
|
||||
Self::new([
|
||||
Change::MaxDamage(defaults.max_damage),
|
||||
Change::Damage(defaults.damage),
|
||||
Change::Unbreakable(defaults.unbreakable),
|
||||
])
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct DurabilityPatch(Patch<Key, i32>);
|
||||
|
||||
@@ -157,12 +157,6 @@ pub fn map(tag: &Tag) -> Option<&Compound> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
pub fn map_mut(tag: &mut Tag) -> Option<&mut Compound> {
|
||||
match tag {
|
||||
Tag::Compound(c) => Some(c),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
/// `Dynamic.set`: only maps change.
|
||||
pub fn set(tag: &mut Tag, field: &str, value: Tag) {
|
||||
if let Tag::End = tag {
|
||||
@@ -193,12 +187,6 @@ pub fn update(tag: &mut Tag, field: &str, f: impl FnOnce(Tag) -> Tag) {
|
||||
set(tag, field, f(v));
|
||||
}
|
||||
}
|
||||
/// `Dynamic.update` in place.
|
||||
pub fn update_mut(tag: &mut Tag, field: &str, f: impl FnOnce(&mut Tag)) {
|
||||
if let Some(v) = tag.get_mut(field) {
|
||||
f(v);
|
||||
}
|
||||
}
|
||||
/// `Dynamic.renameAndFixField`: the fixed value under the new name, removed when
|
||||
/// the fix gives nothing.
|
||||
pub fn rename_and_fix(tag: &mut Tag, from: &str, to: &str, f: impl FnOnce(Tag) -> Option<Tag>) {
|
||||
@@ -223,15 +211,6 @@ pub fn is_empty_map(tag: &Tag) -> bool {
|
||||
pub fn or_empty_map(tag: Option<&Tag>) -> Tag {
|
||||
tag.cloned().unwrap_or_else(empty_map)
|
||||
}
|
||||
/// Apply `f` to every element of a list field (`Dynamic.createList(asStream().map(f))`).
|
||||
pub fn map_list(tag: &mut Tag, field: &str, mut f: impl FnMut(Tag) -> Tag) {
|
||||
if let Some(v) = tag.get(field)
|
||||
&& is_list(Some(v))
|
||||
{
|
||||
let list = stream(Some(v)).into_iter().map(&mut f).collect();
|
||||
set(tag, field, Tag::List(list));
|
||||
}
|
||||
}
|
||||
/// `NamespacedSchema.ensureNamespaced`.
|
||||
pub fn namespaced(id: &str) -> String {
|
||||
match crate::datafix::identifier(id) {
|
||||
|
||||
@@ -44,9 +44,6 @@ impl MovementHistory {
|
||||
}
|
||||
self.records.push_back(record);
|
||||
}
|
||||
pub fn remove_latest(&mut self) {
|
||||
self.records.pop_back();
|
||||
}
|
||||
pub fn clear(&mut self) {
|
||||
self.records.clear();
|
||||
}
|
||||
|
||||
@@ -73,17 +73,3 @@ pub fn is_unobstructed<W: EntityObstructionWorld>(
|
||||
}
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
/// Entity obstruction for the unit cube used by the vanilla block predicate.
|
||||
/// Translate the voxel shape in floating point: integer MAX + 1 must not wrap.
|
||||
pub fn is_block_unobstructed<W: EntityObstructionWorld>(
|
||||
world: &mut W,
|
||||
position: [i32; 3],
|
||||
) -> Result<bool, ObstructionError<W::Error>> {
|
||||
let shape = VoxelShape::block().moved(horizon_core::geometry::Vec3::new(
|
||||
f64::from(position[0]),
|
||||
f64::from(position[1]),
|
||||
f64::from(position[2]),
|
||||
));
|
||||
is_unobstructed(world, None, &shape)
|
||||
}
|
||||
|
||||
@@ -272,13 +272,6 @@ impl FluidStateTable {
|
||||
pub fn get(&self, state: BlockStateId) -> Option<FluidState> {
|
||||
self.0.get(state.0 as usize).copied()
|
||||
}
|
||||
pub fn matching_states(&self, mask: u8) -> impl Iterator<Item = BlockStateId> + '_ {
|
||||
self.0
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(move |(_, state)| state.kind.mask() & mask != 0)
|
||||
.map(|(i, _)| BlockStateId(i as u32))
|
||||
}
|
||||
}
|
||||
|
||||
/// Bound identities for converting fluid states into their legacy liquid blocks.
|
||||
|
||||
@@ -160,16 +160,6 @@ impl Behaviours {
|
||||
) -> bool {
|
||||
self.sim(level, ticks).grow_water_plant(pos, face)
|
||||
}
|
||||
/// The `BonemealableBlock.Type` particle spread of a block at level event
|
||||
/// 1505: Some(true) for `NEIGHBOR_SPREADER` (particles over a 3-block
|
||||
/// area above), Some(false) for `GROWER`, None when not bonemealable.
|
||||
pub fn bone_meal_spreads(&self, state: BlockStateId) -> Option<bool> {
|
||||
let kind = self.bonemeal_kind(state)?;
|
||||
Some(matches!(
|
||||
kind,
|
||||
Kind::Grass | Kind::Nylium | Kind::Netherrack | Kind::FeaturePlacer
|
||||
))
|
||||
}
|
||||
fn bonemeal_kind(&self, state: BlockStateId) -> Option<Kind> {
|
||||
let data = self.data(state);
|
||||
if !data.implements(Interface::Bonemealable) {
|
||||
|
||||
@@ -15,9 +15,6 @@ macro_rules! classes {
|
||||
pub fn from_java(name: &str) -> Option<Self> {
|
||||
match name { $($java => Some(Class::$name),)* _ => None }
|
||||
}
|
||||
pub const fn java_name(self) -> &'static str {
|
||||
match self { $(Class::$name => $java,)* }
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -148,7 +148,6 @@ pub mod flags {
|
||||
pub const UPDATE_NEIGHBORS: i32 = 1;
|
||||
pub const UPDATE_CLIENTS: i32 = 2;
|
||||
pub const UPDATE_INVISIBLE: i32 = 4;
|
||||
pub const UPDATE_IMMEDIATE: i32 = 8;
|
||||
pub const UPDATE_KNOWN_SHAPE: i32 = 16;
|
||||
pub const UPDATE_SUPPRESS_DROPS: i32 = 32;
|
||||
pub const UPDATE_MOVE_BY_PISTON: i32 = 64;
|
||||
|
||||
@@ -348,10 +348,4 @@ impl StateTable {
|
||||
}
|
||||
result
|
||||
}
|
||||
pub fn property_names(&self, block: BlockId) -> impl Iterator<Item = &str> {
|
||||
self.info(block)
|
||||
.slots
|
||||
.iter()
|
||||
.map(|slot| self.key_names[slot.key.0 as usize].as_str())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,9 +149,6 @@ impl Ticks {
|
||||
self.blocks
|
||||
.has_scheduled(pos, TickTypeId(u32::from(block.0)))
|
||||
}
|
||||
pub fn has_fluid_tick(&self, pos: BlockPos, fluid: FluidKind) -> bool {
|
||||
self.fluids.has_scheduled(pos, TickTypeId(fluid as u32))
|
||||
}
|
||||
pub fn will_block_tick_this_tick(&mut self, pos: BlockPos, block: BlockId) -> bool {
|
||||
self.blocks
|
||||
.will_tick_this_tick(pos, TickTypeId(u32::from(block.0)))
|
||||
|
||||
@@ -62,9 +62,6 @@ impl<'r> FluidRegistry<'r> {
|
||||
pub fn blocks_flow(&self, id: BlockStateId) -> io::Result<bool> {
|
||||
Ok(self.state(id)?.blocks_flow)
|
||||
}
|
||||
pub fn is_ice(&self, id: BlockStateId) -> io::Result<bool> {
|
||||
Ok(self.state(id)?.ice)
|
||||
}
|
||||
}
|
||||
/// Both queries return state IDs from the same registry. Separate entry points
|
||||
/// preserve native world dispatch when reading a block versus its fluid cell.
|
||||
|
||||
@@ -33,9 +33,6 @@ impl BelowZeroRetrogen {
|
||||
.get(index / 64)
|
||||
.is_some_and(|word| word & (1_u64 << (index % 64)) != 0)
|
||||
}
|
||||
pub fn missing_bedrock_words(&self) -> &[u64] {
|
||||
&self.missing_bedrock
|
||||
}
|
||||
pub fn from_nbt(tag: &Tag) -> io::Result<Self> {
|
||||
if !matches!(tag, Tag::Compound(_)) {
|
||||
return Err(invalid("retrogen is not a compound"));
|
||||
|
||||
@@ -50,11 +50,6 @@ impl GlobalFluidPicker {
|
||||
disabled: false,
|
||||
}
|
||||
}
|
||||
/// Matches the vanilla developer flag. Regular gameplay keeps this false.
|
||||
pub const fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
}
|
||||
}
|
||||
impl FluidPicker for GlobalFluidPicker {
|
||||
fn compute(&self, [_, y, _]: [i32; 3]) -> FluidStatus {
|
||||
|
||||
@@ -212,9 +212,6 @@ impl<'r, B: TerrainBlockStates> TerrainRegion<'r, B> {
|
||||
pub fn tick_clock(&self) -> (i64, i64) {
|
||||
(self.game_time, self.next_tick_order)
|
||||
}
|
||||
pub fn set_game_time(&mut self, game_time: i64) {
|
||||
self.game_time = game_time;
|
||||
}
|
||||
/// Raw tick identities are default block-state IDs for block ticks and
|
||||
/// `FluidKind` discriminants for fluid ticks, in separate namespaces.
|
||||
pub fn schedule_tick(
|
||||
@@ -224,15 +221,6 @@ impl<'r, B: TerrainBlockStates> TerrainRegion<'r, B> {
|
||||
) -> Result<bool, RegionError> {
|
||||
WorldGenTickAccess::new(RegionTickContainers { region: self, kind }).schedule(tick)
|
||||
}
|
||||
pub fn has_scheduled_tick(
|
||||
&mut self,
|
||||
kind: TickKind,
|
||||
position: BlockPos,
|
||||
tick_type: TickTypeId,
|
||||
) -> Result<bool, RegionError> {
|
||||
WorldGenTickAccess::new(RegionTickContainers { region: self, kind })
|
||||
.has_scheduled(position, tick_type)
|
||||
}
|
||||
fn request_tick(
|
||||
&mut self,
|
||||
kind: TickKind,
|
||||
@@ -251,11 +239,6 @@ impl<'r, B: TerrainBlockStates> TerrainRegion<'r, B> {
|
||||
self.schedule_tick(kind, tick)?;
|
||||
Ok(())
|
||||
}
|
||||
/// Override world sea level without changing generator placement anchors.
|
||||
pub fn with_world_sea_level(mut self, sea_level: i32) -> Self {
|
||||
self.sea_level = sea_level;
|
||||
self
|
||||
}
|
||||
/// Release the resident chunks, ordered by X then Z; match them by position.
|
||||
pub fn into_chunks(self) -> Vec<TerrainChunk<'r, B>> {
|
||||
self.chunks
|
||||
|
||||
@@ -65,12 +65,6 @@ impl MaterialConditionRegistry {
|
||||
pub fn from_json(definitions: &BTreeMap<String, String>) -> Result<Self, DecodeError> {
|
||||
Self::load(definitions, None)
|
||||
}
|
||||
pub fn from_json_with_biomes(
|
||||
definitions: &BTreeMap<String, String>,
|
||||
biomes: &BTreeSet<String>,
|
||||
) -> Result<Self, DecodeError> {
|
||||
Self::from_json_with_biome_tags(definitions, biomes, &BTreeMap::new())
|
||||
}
|
||||
/// Bind resolved biome tags, such as `TagDefinitions::build().tags`.
|
||||
/// Names and memberships remain immutable for the lifetime of this registry.
|
||||
pub fn from_json_with_biome_tags(
|
||||
|
||||
@@ -344,12 +344,6 @@ impl BlockStateProvider {
|
||||
_ => Err(DecodeError::Field("exclusive state or provider")),
|
||||
}
|
||||
}
|
||||
pub fn from_typed_json(
|
||||
json: &str,
|
||||
bindings: &StateProviderBindings<'_>,
|
||||
) -> Result<Self, DecodeError> {
|
||||
Self::decode_typed(json, bindings, 0, &mut 65536, None)
|
||||
}
|
||||
fn decode_typed(
|
||||
json: &str,
|
||||
bindings: &StateProviderBindings<'_>,
|
||||
|
||||
@@ -432,18 +432,6 @@ impl<'r, B: TerrainBlockStates> TerrainChunk<'r, B> {
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
pub fn set_heightmap_raw(
|
||||
&mut self,
|
||||
kind: HeightmapType,
|
||||
words: &[u64],
|
||||
) -> Result<(), TerrainError> {
|
||||
self.ensure_heightmap(kind);
|
||||
self.heightmaps[kind as usize]
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.set_raw_data(&self.blocks, words)?;
|
||||
Ok(())
|
||||
}
|
||||
/// Before replaying a saved chunk's `PostProcessing` lists.
|
||||
pub fn clear_postprocessing(&mut self) {
|
||||
self.postprocessing.iter_mut().for_each(Vec::clear);
|
||||
|
||||
Reference in New Issue
Block a user