Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ debug = true
strip = false

[workspace.dependencies]
log = "0.4"
tokio = { version = "1.49", default-features = false }
syn = { version = "2.0", default-features = false, features = ["printing"] }

Expand Down
2 changes: 1 addition & 1 deletion pumpkin-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rust-version.workspace = true
[dependencies]
pumpkin-util.workspace = true
serde.workspace = true
log.workspace = true
tracing.workspace = true
uuid.workspace = true

toml.workspace = true
Expand Down
7 changes: 4 additions & 3 deletions pumpkin-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize, de::DeserializeOwned};
use std::net::SocketAddr;
use std::path::PathBuf;
use std::{fs, num::NonZeroU8, path::Path};
use tracing::{debug, warn};
pub mod fun;
pub mod logging;
pub mod networking;
Expand Down Expand Up @@ -189,7 +190,7 @@ pub trait LoadConfiguration {
Self: Sized + Default + Serialize + DeserializeOwned,
{
if !config_dir.exists() {
log::debug!("creating new config root folder");
debug!("creating new config root folder");
fs::create_dir(config_dir).expect("Failed to create config root folder");
}
let path = config_dir.join(Self::get_path());
Expand All @@ -215,7 +216,7 @@ pub trait LoadConfiguration {
path.file_name().unwrap().display()
);
if let Err(err) = fs::write(&path, toml::to_string(&merged_config).unwrap()) {
log::warn!(
warn!(
"Couldn't write merged config to {}. Reason: {}",
path.display(),
err
Expand All @@ -227,7 +228,7 @@ pub trait LoadConfiguration {
} else {
let content = Self::default();
if let Err(err) = fs::write(&path, toml::to_string(&content).unwrap()) {
log::warn!(
warn!(
"Couldn't write default config to {:?}. Reason: {}",
path.display(),
err
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-inventory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pumpkin-data.workspace = true
pumpkin-world.workspace = true
pumpkin-util.workspace = true

log.workspace = true
tracing.workspace = true
tokio.workspace = true
thiserror.workspace = true
crossbeam-utils.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::{
ScreenHandlerFuture, ScreenHandlerListener, ScreenProperty,
},
};
use tracing::debug;

use super::furnace_like_slot::{FurnaceLikeSlot, FurnaceLikeSlotType, FurnaceOutputSlot};

Expand Down Expand Up @@ -119,7 +120,7 @@ impl ScreenHandler for FurnaceLikeScreenHandler {
const FUEL_SLOT: i32 = 1; // Note: Slots 0, 1, 2 are Furnace slots.
const OUTPUT_SLOT: i32 = 2;

log::debug!("FurnaceLikeScreenHandler::quick_move slot_index={slot_index}");
debug!("FurnaceLikeScreenHandler::quick_move slot_index={slot_index}");

let mut stack_left = ItemStack::EMPTY.clone();

Expand Down Expand Up @@ -163,7 +164,7 @@ impl ScreenHandler for FurnaceLikeScreenHandler {

// Award XP when taking from output slot (slot 2)
if slot_index == OUTPUT_SLOT {
log::debug!("quick_move: taking from output slot, calling on_take_item");
debug!("quick_move: taking from output slot, calling on_take_item");
slot.on_take_item(player, &stack_left).await;
}

Expand Down
8 changes: 5 additions & 3 deletions pumpkin-inventory/src/furnace_like/furnace_like_slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use pumpkin_world::{
block::entities::furnace_like_block_entity::ExperienceContainer, inventory::Inventory,
};

use tracing::debug;

use crate::{
screen_handler::InventoryPlayer,
slot::{BoxFuture, Slot},
Expand Down Expand Up @@ -118,12 +120,12 @@ impl Slot for FurnaceOutputSlot {
_stack: &'a pumpkin_world::item::ItemStack,
) -> BoxFuture<'a, ()> {
Box::pin(async move {
log::debug!("FurnaceOutputSlot: on_take_item called");
debug!("FurnaceOutputSlot: on_take_item called");
// Extract accumulated experience and award to player
let experience = self.experience_container.extract_experience();
log::debug!("FurnaceOutputSlot: extracted experience = {experience}");
debug!("FurnaceOutputSlot: extracted experience = {experience}");
if experience > 0 {
log::debug!("FurnaceOutputSlot: awarding {experience} xp to player");
debug!("FurnaceOutputSlot: awarding {experience} xp to player");
player.award_experience(experience).await;
}
self.mark_dirty().await;
Expand Down
10 changes: 4 additions & 6 deletions pumpkin-inventory/src/player/player_inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::pin::Pin;
use std::sync::Arc;
use std::sync::atomic::{AtomicU8, Ordering};
use tokio::sync::Mutex;
use tracing::warn;

pub struct PlayerInventory {
pub main_inventory: [Arc<Mutex<ItemStack>>; Self::MAIN_SIZE],
Expand Down Expand Up @@ -401,13 +402,10 @@ impl Inventory for PlayerInventory {
Box::pin(async move {
if slot < self.main_inventory.len() {
*self.main_inventory[slot].lock().await = stack;
} else if let Some(slot) = self.equipment_slots.get(&slot) {
self.entity_equipment.lock().await.put(slot, stack).await;
} else {
match self.equipment_slots.get(&slot) {
Some(slot) => {
self.entity_equipment.lock().await.put(slot, stack).await;
}
None => log::warn!("Failed to get Equipment Slot at {slot}"),
}
warn!("Failed to get Equipment Slot at {slot}");
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-inventory/src/screen_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{
slot::{NormalSlot, Slot},
sync_handler::{SyncHandler, TrackedStack},
};
use log::warn;
use pumpkin_data::{
data_component_impl::{EquipmentSlot, EquipmentType, EquippableImpl},
screen::WindowType,
Expand All @@ -29,6 +28,7 @@ use std::sync::atomic::{AtomicU32, Ordering};
use std::{any::Any, collections::HashMap, sync::Arc};
use std::{cmp::max, pin::Pin};
use tokio::sync::Mutex;
use tracing::warn;

const SLOT_INDEX_OUTSIDE: i32 = -999;

Expand Down
2 changes: 1 addition & 1 deletion pumpkin-world/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ uuid.workspace = true
thiserror.workspace = true
serde.workspace = true
serde_json.workspace = true
log.workspace = true
tracing.workspace = true
crossbeam.workspace = true

sha2.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-world/src/block/entities/chiseled_bookshelf.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use log::warn;
use pumpkin_data::Block;
use pumpkin_data::block_properties::{BlockProperties, ChiseledBookshelfLikeProperties};
use pumpkin_nbt::compound::NbtCompound;
Expand All @@ -13,6 +12,7 @@ use std::{
},
};
use tokio::sync::Mutex;
use tracing::warn;

use crate::inventory::InventoryFuture;
use crate::{
Expand Down
29 changes: 14 additions & 15 deletions pumpkin-world/src/chunk/format/anvil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use tokio::{
io::{AsyncSeekExt, AsyncWrite, AsyncWriteExt, BufWriter},
sync::Mutex,
};
use tracing::{debug, trace};

use crate::chunk::{
ChunkParsingError, ChunkReadingError, ChunkSerializingError, ChunkWritingError,
Expand Down Expand Up @@ -348,7 +349,7 @@ impl<S: SingleChunkDataSerializer> AnvilChunkFile<S> {
where
I: IntoIterator<Item = usize>,
{
log::trace!("Writing in place: {}", path.display());
trace!("Writing in place: {}", path.display());

let file = tokio::fs::OpenOptions::new()
.write(true)
Expand All @@ -364,11 +365,9 @@ impl<S: SingleChunkDataSerializer> AnvilChunkFile<S> {
if let Some(chunk) = metadata {
let chunk_data = &chunk.serialized_data;
let sector_count = chunk_data.sector_count();
log::trace!(
trace!(
"Writing position for chunk {} - {}:{}",
index,
chunk.file_sector_offset,
sector_count
index, chunk.file_sector_offset, sector_count
);
write
.write_u32((chunk.file_sector_offset << 8) | sector_count)
Expand Down Expand Up @@ -421,15 +420,15 @@ impl<S: SingleChunkDataSerializer> AnvilChunkFile<S> {

// Seek only if we need to
if chunk.file_sector_offset != current_sector {
log::trace!("Seeking to sector {}", chunk.file_sector_offset);
trace!("Seeking to sector {}", chunk.file_sector_offset);
let _ = write
.seek(SeekFrom::Start(
chunk.file_sector_offset as u64 * SECTOR_BYTES as u64,
))
.await?;
current_sector = chunk.file_sector_offset;
}
log::trace!(
trace!(
"Writing chunk {} - {}:{}",
index,
current_sector,
Expand All @@ -447,7 +446,7 @@ impl<S: SingleChunkDataSerializer> AnvilChunkFile<S> {
/// Write entire file, disregarding saved offsets
async fn write_all(&self, path: &Path) -> Result<(), std::io::Error> {
let temp_path = path.with_extension("tmp");
log::trace!("Writing tmp file to disk: {temp_path:?}");
trace!("Writing tmp file to disk: {temp_path:?}");

let file = tokio::fs::File::create(&temp_path).await?;

Expand Down Expand Up @@ -487,7 +486,7 @@ impl<S: SingleChunkDataSerializer> AnvilChunkFile<S> {
// that the data is not corrupted before the rename is completed
tokio::fs::rename(temp_path, path).await?;

log::trace!("Wrote file to Disk: {}", path.display());
trace!("Wrote file to Disk: {}", path.display());
Ok(())
}
}
Expand Down Expand Up @@ -531,7 +530,7 @@ impl<S: SingleChunkDataSerializer> ChunkSerializer for AnvilChunkFile<S> {
let mut write_action = self.write_action.lock().await;
match &*write_action {
WriteAction::Pass => {
log::debug!(
debug!(
"Skipping write for {}, as there were no dirty chunks",
path.display()
);
Expand Down Expand Up @@ -632,7 +631,7 @@ impl<S: SingleChunkDataSerializer> ChunkSerializer for AnvilChunkFile<S> {

match &*write_action {
WriteAction::All => {
log::trace!("Write action is all: setting chunk in place");
trace!("Write action is all: setting chunk in place");
// Doesn't matter, just add the data
self.chunks_data[index] = Some(AnvilChunkMetadata {
serialized_data: new_chunk_data,
Expand All @@ -643,7 +642,7 @@ impl<S: SingleChunkDataSerializer> ChunkSerializer for AnvilChunkFile<S> {
_ => {
match self.chunks_data[index].as_ref() {
None => {
log::trace!(
trace!(
"Chunk {} does not exist, appending to EOF: {}:{}",
index,
self.end_sector,
Expand All @@ -662,7 +661,7 @@ impl<S: SingleChunkDataSerializer> ChunkSerializer for AnvilChunkFile<S> {
Some(old_chunk) => {
if old_chunk.serialized_data.sector_count() == new_chunk_data.sector_count()
{
log::trace!(
trace!(
"Chunk {} exists, writing in place: {}:{}",
index,
old_chunk.file_sector_offset,
Expand Down Expand Up @@ -710,7 +709,7 @@ impl<S: SingleChunkDataSerializer> ChunkSerializer for AnvilChunkFile<S> {
.collect::<Vec<_>>();

if chunks_to_shift.last().is_none_or(|chunk| chunk.0 == index) {
log::trace!(
trace!(
"Unable to find a chunk to swap with; falling back to serialize all",
);

Expand Down Expand Up @@ -755,7 +754,7 @@ impl<S: SingleChunkDataSerializer> ChunkSerializer for AnvilChunkFile<S> {
// If positive, now larger -> shift right, else shift left
let offset = new_sectors as i64 - swapped_sectors as i64;

log::trace!(
trace!(
"Swapping {index} with {swapped_index}, shifting all chunks {swapped_index} and after by {offset}"
);

Expand Down
8 changes: 4 additions & 4 deletions pumpkin-world/src/chunk/format/linear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use crate::chunk::format::anvil::{AnvilChunkFile, SingleChunkDataSerializer};
use crate::chunk::io::{ChunkSerializer, LoadedData};
use crate::chunk::{ChunkReadingError, ChunkWritingError};
use bytes::{Buf, BufMut, Bytes};
use log::error;
use pumpkin_config::chunk::LinearChunkConfig;
use pumpkin_util::math::vector2::Vector2;
use ruzstd::decoding::StreamingDecoder;
use ruzstd::encoding::{CompressionLevel, compress_to_vec};
use tokio::io::{AsyncWriteExt, BufWriter};
use tracing::{error, trace, warn};

use super::anvil::CHUNK_COUNT;

Expand Down Expand Up @@ -177,7 +177,7 @@ impl<S: SingleChunkDataSerializer> ChunkSerializer for LinearFile<S> {

async fn write(&self, path: &PathBuf) -> Result<(), std::io::Error> {
let temp_path = path.with_extension("tmp");
log::trace!("Writing tmp file to disk: {}", temp_path.display());
trace!("Writing tmp file to disk: {}", temp_path.display());

let file = tokio::fs::File::create(&temp_path).await?;
let mut write = BufWriter::new(file);
Expand Down Expand Up @@ -227,7 +227,7 @@ impl<S: SingleChunkDataSerializer> ChunkSerializer for LinearFile<S> {
// that the data is not corrupted before the rename is completed
tokio::fs::rename(temp_path, &path).await?;

log::trace!("Wrote file to Disk: {}", path.display());
trace!("Wrote file to Disk: {}", path.display());
Ok(())
}

Expand Down Expand Up @@ -293,7 +293,7 @@ impl<S: SingleChunkDataSerializer> ChunkSerializer for LinearFile<S> {
let last_index = bytes_offset;
bytes_offset += header.size as usize;
if bytes_offset > buffer.len() {
log::warn!(
warn!(
"Not enough bytes are available for chunk {} ({} vs {})",
i,
header.size,
Expand Down
Loading