fix: arrows not damage non living entities
This commit is contained in:
parent
7760292c2e
commit
1e196cfe34
@ -112,4 +112,4 @@ Consider joining [our Discord server](https://discord.gg/pumpkinmc) to stay up-t
|
||||
|
||||
## 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! {
|
||||
use crate::tag::{RegistryKey, Tag, Taggable};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct DamageType {
|
||||
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. */
|
||||
use crate::tag::{RegistryKey, Tag, Taggable};
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct DamageType {
|
||||
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(
|
||||
TextComponent::text("[Donate]")
|
||||
.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(
|
||||
"Click to open Donate",
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
use core::f32;
|
||||
|
||||
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_util::math::vector3::Vector3;
|
||||
|
||||
@ -48,7 +53,8 @@ impl EntityBase for EndCrystalEntity {
|
||||
_cause: Option<&'a dyn EntityBase>,
|
||||
) -> EntityBaseFuture<'a, bool> {
|
||||
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
|
||||
.world
|
||||
.load()
|
||||
@ -57,7 +63,6 @@ impl EntityBase for EndCrystalEntity {
|
||||
}
|
||||
|
||||
// TODO
|
||||
self.entity.remove().await;
|
||||
true
|
||||
})
|
||||
}
|
||||
|
||||
@ -390,12 +390,12 @@ impl EntityBase for ArrowEntity {
|
||||
let bonus = (rand::random::<u32>() % (damage / 2 + 2) as u32) as i32;
|
||||
damage = damage.saturating_add(bonus);
|
||||
}
|
||||
target
|
||||
.damage(&*target, damage as f32, DamageType::ARROW)
|
||||
.await;
|
||||
|
||||
if let Some(living) = target.get_living_entity() {
|
||||
// Apply damage to target
|
||||
living
|
||||
.damage(living, damage as f32, DamageType::ARROW)
|
||||
.await;
|
||||
if target.get_living_entity().is_some() {
|
||||
// TODO: knockback
|
||||
|
||||
// Play hit sound
|
||||
let sound_packet = CSoundEffect::new(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user