fix: arrows not damage non living entities
This commit is contained in:
1 parent
7760292c2e
commit
1e196cfe34
6 files changed
+47
-10
No files matched your search
@@ -112,4 +112,4 @@ Consider joining [our Discord server](https://discord.gg/pumpkinmc) to stay up-t
|
|||||||
|
|
||||||
## Funding
|
## Funding
|
||||||
|
|
||||||
If you want to fund me and help the project, check out my [GitHub sponsors](https://github.com/sponsors/Snowiiii).
|
If you want to fund me and help the project, check out my [GitHub sponsors](https://github.com/sponsors/Pumpkin-MC).
|
||||||
@@ -113,6 +113,8 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
|
use crate::tag::{RegistryKey, Tag, Taggable};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub struct DamageType {
|
pub struct DamageType {
|
||||||
pub death_message_type: DeathMessageType,
|
pub death_message_type: DeathMessageType,
|
||||||
@@ -159,5 +161,20 @@ pub fn build() -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Taggable for DamageType {
|
||||||
|
#[inline]
|
||||||
|
fn tag_key() -> RegistryKey {
|
||||||
|
RegistryKey::DamageType
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
fn registry_key(&self) -> &str {
|
||||||
|
self.message_id
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
fn registry_id(&self) -> u16 {
|
||||||
|
self.id as u16
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
/* This file is generated. Do not edit manually. */
|
/* This file is generated. Do not edit manually. */
|
||||||
|
use crate::tag::{RegistryKey, Tag, Taggable};
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub struct DamageType {
|
pub struct DamageType {
|
||||||
pub death_message_type: DeathMessageType,
|
pub death_message_type: DeathMessageType,
|
||||||
@@ -487,3 +488,17 @@ impl DamageType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl Taggable for DamageType {
|
||||||
|
#[inline]
|
||||||
|
fn tag_key() -> RegistryKey {
|
||||||
|
RegistryKey::DamageType
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
fn registry_key(&self) -> &str {
|
||||||
|
self.message_id
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
fn registry_id(&self) -> u16 {
|
||||||
|
self.id as u16
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -203,7 +203,7 @@ impl CommandExecutor for Executor {
|
|||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text("[Donate]")
|
TextComponent::text("[Donate]")
|
||||||
.click_event(ClickEvent::OpenUrl {
|
.click_event(ClickEvent::OpenUrl {
|
||||||
url: Cow::from("https://github.com/sponsors/Snowiiii"),
|
url: Cow::from("https://github.com/sponsors/Pumpkin-MC"),
|
||||||
})
|
})
|
||||||
.hover_event(HoverEvent::show_text(TextComponent::text(
|
.hover_event(HoverEvent::show_text(TextComponent::text(
|
||||||
"Click to open Donate",
|
"Click to open Donate",
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
use core::f32;
|
use core::f32;
|
||||||
|
|
||||||
use crate::entity::{Entity, EntityBase, EntityBaseFuture, NBTStorage, living::LivingEntity};
|
use crate::entity::{Entity, EntityBase, EntityBaseFuture, NBTStorage, living::LivingEntity};
|
||||||
use pumpkin_data::{damage::DamageType, meta_data_type::MetaDataType, tracked_data::TrackedData};
|
use pumpkin_data::{
|
||||||
|
damage::DamageType,
|
||||||
|
meta_data_type::MetaDataType,
|
||||||
|
tag::{self, Taggable},
|
||||||
|
tracked_data::TrackedData,
|
||||||
|
};
|
||||||
use pumpkin_protocol::java::client::play::Metadata;
|
use pumpkin_protocol::java::client::play::Metadata;
|
||||||
use pumpkin_util::math::vector3::Vector3;
|
use pumpkin_util::math::vector3::Vector3;
|
||||||
|
|
||||||
@@ -48,7 +53,8 @@ impl EntityBase for EndCrystalEntity {
|
|||||||
_cause: Option<&'a dyn EntityBase>,
|
_cause: Option<&'a dyn EntityBase>,
|
||||||
) -> EntityBaseFuture<'a, bool> {
|
) -> EntityBaseFuture<'a, bool> {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
if damage_type != DamageType::EXPLOSION {
|
self.entity.remove().await;
|
||||||
|
if !damage_type.has_tag(&tag::DamageType::MINECRAFT_IS_EXPLOSION) {
|
||||||
self.entity
|
self.entity
|
||||||
.world
|
.world
|
||||||
.load()
|
.load()
|
||||||
@@ -57,7 +63,6 @@ impl EntityBase for EndCrystalEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
self.entity.remove().await;
|
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -390,12 +390,12 @@ impl EntityBase for ArrowEntity {
|
|||||||
let bonus = (rand::random::<u32>() % (damage / 2 + 2) as u32) as i32;
|
let bonus = (rand::random::<u32>() % (damage / 2 + 2) as u32) as i32;
|
||||||
damage = damage.saturating_add(bonus);
|
damage = damage.saturating_add(bonus);
|
||||||
}
|
}
|
||||||
|
target
|
||||||
|
.damage(&*target, damage as f32, DamageType::ARROW)
|
||||||
|
.await;
|
||||||
|
|
||||||
if let Some(living) = target.get_living_entity() {
|
if target.get_living_entity().is_some() {
|
||||||
// Apply damage to target
|
// TODO: knockback
|
||||||
living
|
|
||||||
.damage(living, damage as f32, DamageType::ARROW)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
// Play hit sound
|
// Play hit sound
|
||||||
let sound_packet = CSoundEffect::new(
|
let sound_packet = CSoundEffect::new(
|
||||||
|
|||||||
Reference in new issue
Block a user