mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Merge branch 'next-minor' of github.com:pmmp/PocketMine-MP into next-minor
This commit is contained in:
commit
174c9a48f5
@ -73,6 +73,8 @@ final class EnchantmentIdMap{
|
||||
$this->register(EnchantmentIds::MENDING, VanillaEnchantments::MENDING());
|
||||
|
||||
$this->register(EnchantmentIds::VANISHING, VanillaEnchantments::VANISHING());
|
||||
|
||||
$this->register(EnchantmentIds::SWIFT_SNEAK, VanillaEnchantments::SWIFT_SNEAK());
|
||||
}
|
||||
|
||||
public function register(int $mcpeId, Enchantment $enchantment) : void{
|
||||
|
@ -66,4 +66,5 @@ final class EnchantmentIds{
|
||||
public const PIERCING = 34;
|
||||
public const QUICK_CHARGE = 35;
|
||||
public const SOUL_SPEED = 36;
|
||||
public const SWIFT_SNEAK = 37;
|
||||
}
|
||||
|
@ -184,6 +184,13 @@ abstract class Living extends Entity{
|
||||
$this->attributeMap->add($this->absorptionAttr = AttributeFactory::getInstance()->mustGet(Attribute::ABSORPTION));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name used to describe this entity in chat and command outputs.
|
||||
*/
|
||||
public function getDisplayName() : string{
|
||||
return $this->nameTag !== "" ? $this->nameTag : $this->getName();
|
||||
}
|
||||
|
||||
public function setHealth(float $amount) : void{
|
||||
$wasAlive = $this->isAlive();
|
||||
parent::setHealth($amount);
|
||||
|
@ -98,17 +98,15 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
||||
if($e instanceof Player){
|
||||
return KnownTranslationFactory::death_attack_player($name, $e->getDisplayName());
|
||||
}elseif($e instanceof Living){
|
||||
return KnownTranslationFactory::death_attack_mob($name, $e->getNameTag() !== "" ? $e->getNameTag() : $e->getName());
|
||||
return KnownTranslationFactory::death_attack_mob($name, $e->getDisplayName());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EntityDamageEvent::CAUSE_PROJECTILE:
|
||||
if($deathCause instanceof EntityDamageByEntityEvent){
|
||||
$e = $deathCause->getDamager();
|
||||
if($e instanceof Player){
|
||||
if($e instanceof Living){
|
||||
return KnownTranslationFactory::death_attack_arrow($name, $e->getDisplayName());
|
||||
}elseif($e instanceof Living){
|
||||
return KnownTranslationFactory::death_attack_arrow($name, $e->getNameTag() !== "" ? $e->getNameTag() : $e->getName());
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -149,10 +147,8 @@ class PlayerDeathEvent extends EntityDeathEvent{
|
||||
case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION:
|
||||
if($deathCause instanceof EntityDamageByEntityEvent){
|
||||
$e = $deathCause->getDamager();
|
||||
if($e instanceof Player){
|
||||
if($e instanceof Living){
|
||||
return KnownTranslationFactory::death_attack_explosion_player($name, $e->getDisplayName());
|
||||
}elseif($e instanceof Living){
|
||||
return KnownTranslationFactory::death_attack_explosion_player($name, $e->getNameTag() !== "" ? $e->getNameTag() : $e->getName());
|
||||
}
|
||||
}
|
||||
return KnownTranslationFactory::death_attack_explosion($name);
|
||||
|
@ -53,6 +53,7 @@ final class StringToEnchantmentParser extends StringToTParser{
|
||||
$result->register("respiration", fn() => VanillaEnchantments::RESPIRATION());
|
||||
$result->register("sharpness", fn() => VanillaEnchantments::SHARPNESS());
|
||||
$result->register("silk_touch", fn() => VanillaEnchantments::SILK_TOUCH());
|
||||
$result->register("swift_sneak", fn() => VanillaEnchantments::SWIFT_SNEAK());
|
||||
$result->register("thorns", fn() => VanillaEnchantments::THORNS());
|
||||
$result->register("unbreaking", fn() => VanillaEnchantments::UNBREAKING());
|
||||
$result->register("vanishing", fn() => VanillaEnchantments::VANISHING());
|
||||
|
@ -49,6 +49,7 @@ use pocketmine\utils\RegistryTrait;
|
||||
* @method static Enchantment RESPIRATION()
|
||||
* @method static SharpnessEnchantment SHARPNESS()
|
||||
* @method static Enchantment SILK_TOUCH()
|
||||
* @method static Enchantment SWIFT_SNEAK()
|
||||
* @method static Enchantment THORNS()
|
||||
* @method static Enchantment UNBREAKING()
|
||||
* @method static Enchantment VANISHING()
|
||||
@ -95,6 +96,8 @@ final class VanillaEnchantments{
|
||||
self::register("MENDING", new Enchantment(KnownTranslationFactory::enchantment_mending(), Rarity::RARE, ItemFlags::NONE, ItemFlags::ALL, 1));
|
||||
|
||||
self::register("VANISHING", new Enchantment(KnownTranslationFactory::enchantment_curse_vanishing(), Rarity::MYTHIC, ItemFlags::NONE, ItemFlags::ALL, 1));
|
||||
|
||||
self::register("SWIFT_SNEAK", new Enchantment(KnownTranslationFactory::enchantment_swift_sneak(), Rarity::MYTHIC, ItemFlags::NONE, ItemFlags::LEGS, 3));
|
||||
}
|
||||
|
||||
protected static function register(string $name, Enchantment $member) : void{
|
||||
|
Loading…
x
Reference in New Issue
Block a user