|
| 1 | +/* |
| 2 | + * Minecraft Forge, Patchwork Project |
| 3 | + * Copyright (c) 2016-2020, 2019-2020 |
| 4 | + * |
| 5 | + * This library is free software; you can redistribute it and/or |
| 6 | + * modify it under the terms of the GNU Lesser General Public |
| 7 | + * License as published by the Free Software Foundation version 2.1 |
| 8 | + * of the License. |
| 9 | + * |
| 10 | + * This library is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | + * Lesser General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU Lesser General Public |
| 16 | + * License along with this library; if not, write to the Free Software |
| 17 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | + */ |
| 19 | + |
| 20 | +package net.minecraftforge.event.entity.living; |
| 21 | + |
| 22 | +import net.minecraft.entity.damage.DamageSource; |
| 23 | +import net.minecraft.entity.LivingEntity; |
| 24 | + |
| 25 | +/** |
| 26 | + * LivingDamageEvent is fired just before damage is applied to entity. |
| 27 | + * |
| 28 | + * <p>At this point armor, potion and absorption modifiers have already been applied to damage - this is FINAL value.</p> |
| 29 | + * <p>Also note that appropriate resources (like armor durability and absorption extra hearths) have already been consumed.</p> |
| 30 | + * <p>This event is fired whenever an Entity is damaged in |
| 31 | + * {@link LivingEntity#applyDamage(DamageSource, float)} and |
| 32 | + * {@link net.minecraft.entity.player.PlayerEntity#applyDamage(DamageSource, float)}.</p> |
| 33 | + * |
| 34 | + * <p>This event is fired via the {@link com.patchworkmc.impl.event.entity.EntityEvents#onLivingDamage(LivingEntity, DamageSource, float)}.</p> |
| 35 | + * |
| 36 | + * <p>{@link #source} contains the DamageSource that caused this Entity to be hurt. </p> |
| 37 | + * <p>{@link #amount} contains the final amount of damage that will be dealt to entity. </p> |
| 38 | + * |
| 39 | + * <p>This event is cancelable.</p> |
| 40 | + * <p>If this event is canceled, the Entity is not hurt. Used resources WILL NOT be restored.</p> |
| 41 | + * |
| 42 | + * <p>This event does not have a result.</p> |
| 43 | + * @see LivingHurtEvent |
| 44 | + */ |
| 45 | +public class LivingDamageEvent extends LivingEvent { |
| 46 | + private final DamageSource source; |
| 47 | + private float amount; |
| 48 | + |
| 49 | + public LivingDamageEvent(LivingEntity entity, DamageSource source, float amount) { |
| 50 | + super(entity); |
| 51 | + this.source = source; |
| 52 | + this.amount = amount; |
| 53 | + } |
| 54 | + |
| 55 | + public DamageSource getSource() { |
| 56 | + return source; |
| 57 | + } |
| 58 | + |
| 59 | + public float getAmount() { |
| 60 | + return amount; |
| 61 | + } |
| 62 | + |
| 63 | + public void setAmount(float amount) { |
| 64 | + this.amount = amount; |
| 65 | + } |
| 66 | +} |
0 commit comments