Skip to content

Commit

Permalink
Revert "Datapack parsing (#455)" (#478)
Browse files Browse the repository at this point in the history
* Revert "Datapack parsing (#455)"

This reverts commit 7e46ec7.

* removed unused variable.
  • Loading branch information
Tracreed authored Sep 24, 2021
1 parent b5ccddf commit cf650cc
Show file tree
Hide file tree
Showing 21 changed files with 22 additions and 1,398 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
.cargo

world/
feather/downloaded
feather/datapacks/minecraft/
/config.toml

# Python cache files (libcraft)
Expand Down
48 changes: 2 additions & 46 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions feather/blocks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl BlockId {
VANILLA_ID_TABLE[self.kind as u16 as usize][self.state as usize]
}

/*
/// Returns the vanilla fluid ID for this block in case it is a fluid.
/// The fluid ID is used in the Tags packet.
pub fn vanilla_fluid_id(self) -> Option<u16> {
Expand All @@ -111,6 +112,7 @@ impl BlockId {
None
}
}
*/

/// Returns the block corresponding to the given vanilla ID.
///
Expand Down
1 change: 0 additions & 1 deletion feather/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ uuid = { version = "0.8", features = [ "v4" ] }
libcraft-core = { path = "../../libcraft/core" }
rayon = "1.5"
worldgen = { path = "../worldgen", package = "feather-worldgen" }
datapacks = { path = "../datapacks", package = "feather-datapacks" }
rand = "0.8"
7 changes: 0 additions & 7 deletions feather/common/src/game.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{cell::RefCell, mem, rc::Rc, sync::Arc};

use base::{BlockId, BlockPosition, ChunkPosition, Position, Text, Title};
use datapacks::{RecipeRegistry, TagRegistry};
use ecs::{
Ecs, Entity, EntityBuilder, HasEcs, HasResources, NoSuchEntity, Resources, SysResult,
SystemExecutor,
Expand Down Expand Up @@ -55,10 +54,6 @@ pub struct Game {
entity_spawn_callbacks: Vec<EntitySpawnCallback>,

entity_builder: EntityBuilder,

pub tag_registry: TagRegistry,

pub recipe_registry: RecipeRegistry,
}

impl Default for Game {
Expand All @@ -79,8 +74,6 @@ impl Game {
tick_count: 0,
entity_spawn_callbacks: Vec::new(),
entity_builder: EntityBuilder::new(),
tag_registry: TagRegistry::new(),
recipe_registry: RecipeRegistry::new(),
}
}

Expand Down
13 changes: 4 additions & 9 deletions feather/datapacks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
[package]
name = "feather-datapacks"
version = "0.1.0"
authors = [ "koskja <[email protected]>", "caelunshun <[email protected]>" ]
authors = [ "caelunshun <[email protected]>" ]
edition = "2018"

[dependencies]
ahash = "0.4"
anyhow = "1"
log = "0.4"
serde = { version = "1", features = [ "derive" ] }
serde_json = "1"
smartstring = { version = "0.2", features = [ "serde" ] }
thiserror = "1"
generated = { path = "../generated", package = "feather-generated" }
blocks = { path = "../blocks", package = "feather-blocks"}
protocol = { path = "../protocol", package = "feather-protocol" }
walkdir = "2.3.2"

[build-dependencies]
vanilla-assets = { path = "./vanilla_assets", package = "feather-vanilla-assets" }
anyhow = "1"
ureq = { version = "2", default-features = false, features = [ "tls" ] }
zip = "0.5"
8 changes: 0 additions & 8 deletions feather/datapacks/build.rs

This file was deleted.

14 changes: 0 additions & 14 deletions feather/datapacks/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,6 @@ impl NamespacedId {
pub fn name(&self) -> &str {
&self.name
}

pub fn from_parts(namespace: &str, name: &str) -> Result<Self, ParseError> {
let namespace = if namespace.is_empty() {
DEFAULT_NAMESPACE
} else {
namespace
};
validate_namespace(namespace)?;
validate_name(name)?;
Ok(Self {
namespace: SmartString::from(namespace),
name: SmartString::from(name),
})
}
}

/// Error returned when a namespaced ID was formatted incorrectly.
Expand Down
62 changes: 3 additions & 59 deletions feather/datapacks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,19 @@
//! This crate also downloads vanilla JARs and assets
//! at startup; see `download_vanilla_assets`.

use std::path::Path;

use ahash::AHashMap;
use id::ParseError;
use serde::Deserialize;
use smartstring::{LazyCompact, SmartString};

mod vanilla;
pub use vanilla::download_vanilla_assets;

mod id;
pub use id::NamespacedId;

mod serde_helpers;
pub(crate) use serde_helpers::*;

pub mod tag;
use tag::LoopError;
pub use tag::{TagRegistry, TagRegistryBuilder};

pub mod recipe;
pub use recipe::RecipeRegistry;

/// The default namespace for resource locations (NamespacedIds).
pub const DEFAULT_NAMESPACE: &str = "minecraft";

use thiserror::Error;
#[derive(Error, Debug)]
pub enum TagLoadError {
#[error("invalid namespaced id: {0}")]
Parse(#[from] ParseError),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("io error: {0}")]
WalkDir(#[from] walkdir::Error),
#[error("loop detected when parsing tags: {0}")]
FoundLoop(#[from] LoopError),
#[error("invalid tag link: {0} references {1}")]
InvalidLink(NamespacedId, NamespacedId),
#[error("json parsing error: {0}")]
Json(#[from] serde_json::Error),
}
#[derive(Error, Debug)]
pub enum RecipeLoadError {
#[error("invalid namespaced id: {0}")]
Parse(#[from] ParseError),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("json parsing error: {0}")]
Json(#[from] serde_json::Error),
}

/// The pack.mcmeta file at the root of a datapack.
///
/// Formatted with JSON.
Expand All @@ -69,23 +33,3 @@ pub struct Datapacks {
/// The metadata of loaded packs. Keyed by the datapack name.
_meta: AHashMap<SmartString<LazyCompact>, PackMeta>,
}
#[derive(Default)]
pub struct Datapack {
pub advancements: (),
pub loot_tables: (),
pub recipes: (),
pub structures: (),
pub tags: TagRegistry,
}

impl Datapack {
pub fn new() -> Self {
Self {
..Default::default()
}
}
pub fn from_folder(dir: &Path) -> Self {
assert!(dir.is_dir(), "not a directory");
todo!()
}
}
Loading

0 comments on commit cf650cc

Please sign in to comment.