geforkt von Mirrors/Paper
SPIGOT-418: Ensure vehicle events are fired.
Dieser Commit ist enthalten in:
Ursprung
e6f9fd4dc7
Commit
faa27ed298
@ -1,6 +1,6 @@
|
||||
--- ../work/decompile-8eb82bde/net/minecraft/server/EntityLiving.java 2014-12-10 18:34:37.200492561 +0000
|
||||
+++ src/main/java/net/minecraft/server/EntityLiving.java 2014-12-10 18:32:58.472493632 +0000
|
||||
@@ -8,6 +8,15 @@
|
||||
--- ../work/decompile-8eb82bde/net/minecraft/server/EntityLiving.java 2015-01-16 14:48:08.266797758 +1100
|
||||
+++ src/main/java/net/minecraft/server/EntityLiving.java 2015-01-16 14:48:08.270797751 +1100
|
||||
@@ -8,6 +8,18 @@
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -8,15 +8,18 @@
|
||||
+import java.util.ArrayList;
|
||||
+import com.google.common.base.Function;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.entity.LivingEntity;
|
||||
+import org.bukkit.entity.Vehicle;
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
+import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
+import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityLiving extends Entity {
|
||||
|
||||
private static final UUID a = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
|
||||
@@ -67,6 +76,11 @@
|
||||
@@ -67,6 +79,11 @@
|
||||
private float bk;
|
||||
private int bl;
|
||||
private float bm;
|
||||
@ -28,7 +31,7 @@
|
||||
|
||||
public void G() {
|
||||
this.damageEntity(DamageSource.OUT_OF_WORLD, Float.MAX_VALUE);
|
||||
@@ -75,7 +89,8 @@
|
||||
@@ -75,7 +92,8 @@
|
||||
public EntityLiving(World world) {
|
||||
super(world);
|
||||
this.aW();
|
||||
@ -38,7 +41,7 @@
|
||||
this.k = true;
|
||||
this.aF = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
|
||||
this.setPosition(this.locX, this.locY, this.locZ);
|
||||
@@ -116,8 +131,14 @@
|
||||
@@ -116,8 +134,14 @@
|
||||
}
|
||||
|
||||
int i = (int) (150.0D * d1);
|
||||
@ -55,7 +58,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +195,11 @@
|
||||
@@ -174,7 +198,11 @@
|
||||
this.mount((Entity) null);
|
||||
}
|
||||
} else {
|
||||
@ -68,7 +71,7 @@
|
||||
}
|
||||
|
||||
if (this.isAlive() && this.U()) {
|
||||
@@ -220,6 +245,18 @@
|
||||
@@ -220,6 +248,18 @@
|
||||
this.lastPitch = this.pitch;
|
||||
this.world.methodProfiler.b();
|
||||
}
|
||||
@ -87,7 +90,7 @@
|
||||
|
||||
public boolean isBaby() {
|
||||
return false;
|
||||
@@ -227,19 +264,18 @@
|
||||
@@ -227,19 +267,18 @@
|
||||
|
||||
protected void aY() {
|
||||
++this.deathTicks;
|
||||
@ -116,7 +119,7 @@
|
||||
|
||||
this.die();
|
||||
|
||||
@@ -375,6 +411,17 @@
|
||||
@@ -375,6 +414,17 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -134,7 +137,7 @@
|
||||
|
||||
if (nbttagcompound.hasKeyOfType("HealF", 99)) {
|
||||
this.setHealth(nbttagcompound.getFloat("HealF"));
|
||||
@@ -486,7 +533,8 @@
|
||||
@@ -486,7 +536,8 @@
|
||||
}
|
||||
|
||||
public boolean hasEffect(int i) {
|
||||
@ -144,7 +147,7 @@
|
||||
}
|
||||
|
||||
public boolean hasEffect(MobEffectList mobeffectlist) {
|
||||
@@ -560,20 +608,52 @@
|
||||
@@ -560,20 +611,52 @@
|
||||
|
||||
}
|
||||
|
||||
@ -198,7 +201,7 @@
|
||||
this.datawatcher.watch(6, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth())));
|
||||
}
|
||||
|
||||
@@ -589,7 +669,8 @@
|
||||
@@ -589,7 +672,8 @@
|
||||
} else if (damagesource.o() && this.hasEffect(MobEffectList.FIRE_RESISTANCE)) {
|
||||
return false;
|
||||
} else {
|
||||
@ -208,7 +211,7 @@
|
||||
this.getEquipment(4).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this);
|
||||
f *= 0.75F;
|
||||
}
|
||||
@@ -602,16 +683,34 @@
|
||||
@@ -602,16 +686,34 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -245,7 +248,7 @@
|
||||
this.au = 0.0F;
|
||||
Entity entity = damagesource.getEntity();
|
||||
|
||||
@@ -717,11 +816,19 @@
|
||||
@@ -717,11 +819,19 @@
|
||||
}
|
||||
|
||||
if (this.aZ() && this.world.getGameRules().getBoolean("doMobLoot")) {
|
||||
@ -266,7 +269,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -781,8 +888,13 @@
|
||||
@@ -781,8 +891,13 @@
|
||||
int i = MathHelper.f((f - 3.0F - f2) * f1);
|
||||
|
||||
if (i > 0) {
|
||||
@ -281,7 +284,7 @@
|
||||
int j = MathHelper.floor(this.locX);
|
||||
int k = MathHelper.floor(this.locY - 0.20000000298023224D);
|
||||
int l = MathHelper.floor(this.locZ);
|
||||
@@ -826,7 +938,7 @@
|
||||
@@ -826,7 +941,7 @@
|
||||
int i = 25 - this.bq();
|
||||
float f1 = f * (float) i;
|
||||
|
||||
@ -290,7 +293,7 @@
|
||||
f = f1 / 25.0F;
|
||||
}
|
||||
|
||||
@@ -840,8 +952,9 @@
|
||||
@@ -840,8 +955,9 @@
|
||||
int i;
|
||||
int j;
|
||||
float f1;
|
||||
@ -302,7 +305,7 @@
|
||||
i = (this.getEffect(MobEffectList.RESISTANCE).getAmplifier() + 1) * 5;
|
||||
j = 25 - i;
|
||||
f1 = f * (float) j;
|
||||
@@ -867,22 +980,117 @@
|
||||
@@ -867,22 +983,117 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,16 +384,16 @@
|
||||
+ }
|
||||
+ };
|
||||
+ float absorptionModifier = absorption.apply((double) f).floatValue();
|
||||
+
|
||||
|
||||
- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
|
||||
- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
|
||||
+ EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ f = (float) event.getFinalDamage();
|
||||
|
||||
- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
|
||||
- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
|
||||
+
|
||||
+ // Apply damage to helmet
|
||||
+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(4) != null) {
|
||||
+ this.getEquipment(4).damage((int) (event.getDamage() * 4.0F + this.random.nextFloat() * event.getDamage() * 2.0F), this);
|
||||
@ -426,7 +429,7 @@
|
||||
}
|
||||
|
||||
public CombatTracker br() {
|
||||
@@ -1236,7 +1444,8 @@
|
||||
@@ -1236,7 +1447,8 @@
|
||||
if (f > 0.0025000002F) {
|
||||
f3 = 1.0F;
|
||||
f2 = (float) Math.sqrt((double) f) * 3.0F;
|
||||
@ -436,7 +439,7 @@
|
||||
}
|
||||
|
||||
if (this.ax > 0.0F) {
|
||||
@@ -1400,6 +1609,13 @@
|
||||
@@ -1400,6 +1612,13 @@
|
||||
if (list != null && !list.isEmpty()) {
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
Entity entity = (Entity) list.get(i);
|
||||
@ -450,3 +453,22 @@
|
||||
|
||||
if (entity.ae()) {
|
||||
this.s(entity);
|
||||
@@ -1415,6 +1634,18 @@
|
||||
|
||||
public void mount(Entity entity) {
|
||||
if (this.vehicle != null && entity == null) {
|
||||
+ // CraftBukkit start
|
||||
+ Entity originalVehicle = this.vehicle;
|
||||
+ if ((this.bukkitEntity instanceof LivingEntity) && (this.vehicle.getBukkitEntity() instanceof Vehicle)) {
|
||||
+ VehicleExitEvent event = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
|
||||
+ getBukkitEntity().getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled() || vehicle != originalVehicle) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (!this.world.isStatic) {
|
||||
this.q(this.vehicle);
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren