github.com/df-mc/dragonfly@v0.9.13/server/entity/damage.go (about) 1 package entity 2 3 import ( 4 "github.com/df-mc/dragonfly/server/item" 5 "github.com/df-mc/dragonfly/server/item/enchantment" 6 "github.com/df-mc/dragonfly/server/world" 7 ) 8 9 type ( 10 // AttackDamageSource is used for damage caused by other entities, for 11 // example when a player attacks another player. 12 AttackDamageSource struct { 13 // Attacker holds the attacking entity. The entity may be a player or 14 // any other entity. 15 Attacker world.Entity 16 } 17 18 // VoidDamageSource is used for damage caused by an entity being in the 19 // void. 20 VoidDamageSource struct{} 21 22 // SuffocationDamageSource is used for damage caused by an entity 23 // suffocating in a block. 24 SuffocationDamageSource struct{} 25 26 // DrowningDamageSource is used for damage caused by an entity drowning in 27 // water. 28 DrowningDamageSource struct{} 29 30 // FallDamageSource is used for damage caused by falling. 31 FallDamageSource struct{} 32 33 // GlideDamageSource is used for damage caused by gliding into a block. 34 GlideDamageSource struct{} 35 36 // LightningDamageSource is used for damage caused by being struck by 37 // lightning. 38 LightningDamageSource struct{} 39 40 // ProjectileDamageSource is used for damage caused by a projectile. 41 ProjectileDamageSource struct { 42 // Projectile and Owner are the world.Entity that dealt the damage and 43 // the one that fired the projectile respectively. 44 Projectile, Owner world.Entity 45 } 46 47 // ExplosionDamageSource is used for damage caused by an explosion. 48 ExplosionDamageSource struct{} 49 ) 50 51 func (FallDamageSource) ReducedByArmour() bool { return false } 52 func (FallDamageSource) ReducedByResistance() bool { return true } 53 func (FallDamageSource) Fire() bool { return false } 54 func (FallDamageSource) AffectedByEnchantment(e item.EnchantmentType) bool { 55 _, featherFalling := e.(enchantment.FeatherFalling) 56 return featherFalling 57 } 58 func (GlideDamageSource) ReducedByArmour() bool { return false } 59 func (GlideDamageSource) ReducedByResistance() bool { return true } 60 func (GlideDamageSource) Fire() bool { return false } 61 func (LightningDamageSource) ReducedByArmour() bool { return true } 62 func (LightningDamageSource) ReducedByResistance() bool { return true } 63 func (LightningDamageSource) Fire() bool { return false } 64 func (AttackDamageSource) ReducedByArmour() bool { return true } 65 func (AttackDamageSource) ReducedByResistance() bool { return true } 66 func (AttackDamageSource) Fire() bool { return false } 67 func (VoidDamageSource) ReducedByResistance() bool { return false } 68 func (VoidDamageSource) ReducedByArmour() bool { return false } 69 func (VoidDamageSource) Fire() bool { return false } 70 func (SuffocationDamageSource) ReducedByResistance() bool { return false } 71 func (SuffocationDamageSource) ReducedByArmour() bool { return false } 72 func (SuffocationDamageSource) Fire() bool { return false } 73 func (DrowningDamageSource) ReducedByResistance() bool { return false } 74 func (DrowningDamageSource) ReducedByArmour() bool { return false } 75 func (DrowningDamageSource) Fire() bool { return false } 76 func (ProjectileDamageSource) ReducedByResistance() bool { return true } 77 func (ProjectileDamageSource) ReducedByArmour() bool { return true } 78 func (ProjectileDamageSource) Fire() bool { return false } 79 func (ProjectileDamageSource) AffectedByEnchantment(e item.EnchantmentType) bool { 80 _, prot := e.(enchantment.ProjectileProtection) 81 return prot 82 } 83 func (ExplosionDamageSource) ReducedByResistance() bool { return true } 84 func (ExplosionDamageSource) ReducedByArmour() bool { return true } 85 func (ExplosionDamageSource) Fire() bool { return false } 86 func (ExplosionDamageSource) AffectedByEnchantment(e item.EnchantmentType) bool { 87 _, prot := e.(enchantment.BlastProtection) 88 return prot 89 }