[WIP] Implement Potion Effects by walker27460 · Pull Request #430 · feather-rs/feather · GitHub
Skip to content
Closed
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
8 changes: 8 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
1 change: 1 addition & 0 deletions feather/plugin-host/src/host_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod plugin_message;
mod query;
mod system;


macro_rules! host_calls {
(
$($name:literal => $function:ident),* $(,)?
Expand Down
10 changes: 10 additions & 0 deletions libcraft/effects/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "libcraft-effects"
version = "0.1.0"
authors = ["Yui Tanabe <yuitanabe@aol.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1", features = ["derive"] }
84 changes: 84 additions & 0 deletions libcraft/effects/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;

#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
pub enum PotionEffect {
None = 0,
Speed = 1,
Slowness = 2,
Haste = 3,
MiningFatigue = 4,
Strength = 5,
InstantHealth = 6,
InstantDamage = 7,
JumpBoost = 8,
Nausea = 9,
Regeneration = 10,
Resistance = 11,
FireResistance = 12,
WaterBreathing = 13,
Invisibility = 14,
Blindness = 15,
NightVision = 16,
Hunger = 17,
Weakness = 18,
Poison = 19,
Wither = 20,
HealthBoost = 21,
Absorption = 22,
Saturation = 23,
Glowing = 24,
Levitation = 25,
Luck = 26,
BadLuck = 27,
SlowFalling = 28,
ConduitPower = 29,
DolphinsGrace = 30,
BadOmen = 31,
HeroOfTheVillage = 32,
}

#[derive(Debug, Copy, Clone)]
pub struct PotionEffectConvertError;

impl TryFrom<&str> for PotionEffect {
type Error = PotionEffectConvertError;

fn try_from(value: &str) -> Result<Self, Self::Error> {
match value {
"speed" => Ok(Self::Speed),
"slowness" => Ok(Self::Slowness),
"haste" => Ok(Self::Haste),
"mining_fatigue" => Ok(Self::MiningFatigue),
"strength" => Ok(Self::Strength),
"instant_health" => Ok(Self::InstantHealth),
"instant_damage" => Ok(Self::InstantDamage),
"jump_boost" => Ok(Self::JumpBoost),
"nausea" => Ok(Self::Nausea),
"regeneration" => Ok(Self::Regeneration),
"resistance" => Ok(Self::Resistance),
"fire_resistance" => Ok(Self::FireResistance),
"water_breathing" => Ok(Self::WaterBreathing),
"invisibility" => Ok(Self::Invisibility),
"blindness" => Ok(Self::Blindness),
"night_vision" => Ok(Self::NightVision),
"hunger" => Ok(Self::Hunger),
"weakness" => Ok(Self::Weakness),
"poison" => Ok(Self::Poison),
"wither" => Ok(Self::Wither),
"health_boost" => Ok(Self::HealthBoost),
"absorption" => Ok(Self::Absorption),
"saturation" => Ok(Self::Saturation),
"glowing" => Ok(Self::Glowing),
"levitation" => Ok(Self::Levitation),
"luck" => Ok(Self::Luck),
"unluck" => Ok(Self::BadLuck),
"slow_falling" => Ok(Self::SlowFalling),
"conduit_power" => Ok(Self::ConduitPower),
"dolphins_grace" => Ok(Self::DolphinsGrace),
"bad_omen" => Ok(Self::BadOmen),
"hero_of_the_village" => Ok(Self::HeroOfTheVillage),
_ => Err(PotionEffectConvertError),
}
}
}
1 change: 1 addition & 0 deletions quill/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ bytemuck = { version = "1", features = ["derive"] }
libcraft-core = { path = "../../libcraft/core" }
libcraft-particles = { path = "../../libcraft/particles" }
libcraft-text = { path = "../../libcraft/text" }
libcraft-effects = { path = "../../libcraft/effects" }
serde = { version = "1", features = ["derive"] }
smartstring = { version = "0.2", features = ["serde"] }
uuid = { version = "0.8", features = ["serde"] }
Expand Down
35 changes: 34 additions & 1 deletion quill/common/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,40 @@ host_component_enum! {
// `Pod` components
Position = 0,

// Effect Components
Speed = 1,
Slowness = 2,
Haste = 3,
MiningFatigue = 4,
Strength = 5,
InstantHealth = 6,
InstantDamage = 7,
JumpBoost = 8,
Nausea = 9,
Regeneration = 10,
Resistance = 11,
FireResistance = 12,
WaterBreathing = 13,
Invisibility = 14,
Blindness = 15,
NightVision = 16,
Hunger = 17,
Weakness = 18,
Poison = 19,
WitherEffect = 20,
HealthBoost = 21,
Absorption = 22,
Saturation = 23,
Glowing = 24,
Levitation = 25,
Luck = 26,
BadLuck = 27,
SlowFalling = 28,
ConduitPower = 29,
DolphinsGrace = 30,
BadOmen = 31,
HeroOfTheVillage = 32,

// Entity marker components
AreaEffectCloud = 100,
ArmorStand = 101,
Expand Down Expand Up @@ -189,7 +223,6 @@ host_component_enum! {
Sneaking = 1011,
SneakEvent = 1012,


}
}

Expand Down
77 changes: 77 additions & 0 deletions quill/common/src/components.rs