mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
Provide modifier functions to EntityDamageEvent. Fixes BUKKIT-5688
This commit is contained in:
parent
319a9c20eb
commit
c7398b9fdf
1 changed files with 9 additions and 3 deletions
|
@ -8,6 +8,7 @@ import java.util.Map;
|
|||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Functions;
|
||||
|
||||
import net.minecraft.server.ChunkCoordinates;
|
||||
import net.minecraft.server.Container;
|
||||
import net.minecraft.server.DamageSource;
|
||||
|
@ -80,8 +81,6 @@ import org.bukkit.event.server.ServerListPingEvent;
|
|||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
public class CraftEventFactory {
|
||||
public static final DamageSource MELTING = CraftDamageSource.copyOf(DamageSource.BURN);
|
||||
public static final DamageSource POISON = CraftDamageSource.copyOf(DamageSource.MAGIC);
|
||||
|
@ -570,7 +569,14 @@ public class CraftEventFactory {
|
|||
if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
|
||||
return false;
|
||||
}
|
||||
EntityDamageEvent event = handleEntityDamageEvent(entity, source, new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, (double) damage)), null);
|
||||
|
||||
final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
|
||||
final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);
|
||||
|
||||
modifiers.put(DamageModifier.BASE, damage);
|
||||
functions.put(DamageModifier.BASE, ZERO);
|
||||
|
||||
final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
|
||||
if (event == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue