mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-17 13:24:17 -07:00
SPIGOT-1571: Add Entity Glide Events.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/EntityLiving.java
|
||||
+++ b/net/minecraft/server/EntityLiving.java
|
||||
@@ -9,6 +9,20 @@
|
||||
@@ -9,6 +9,21 @@
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
+import org.bukkit.craftbukkit.attribute.CraftAttributeMap;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.entity.LivingEntity;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
@@ -21,7 +22,7 @@
|
||||
public abstract class EntityLiving extends Entity {
|
||||
|
||||
private static final UUID a = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
|
||||
@@ -80,6 +94,13 @@
|
||||
@@ -80,6 +95,13 @@
|
||||
protected int bn;
|
||||
protected int bo;
|
||||
private BlockPosition bC;
|
||||
@@ -35,7 +36,7 @@
|
||||
|
||||
public void Q() {
|
||||
this.damageEntity(DamageSource.OUT_OF_WORLD, Float.MAX_VALUE);
|
||||
@@ -88,7 +109,8 @@
|
||||
@@ -88,7 +110,8 @@
|
||||
public EntityLiving(World world) {
|
||||
super(world);
|
||||
this.initAttributes();
|
||||
@@ -45,7 +46,7 @@
|
||||
this.i = true;
|
||||
this.aL = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
|
||||
this.setPosition(this.locX, this.locY, this.locZ);
|
||||
@@ -125,7 +147,13 @@
|
||||
@@ -125,7 +148,13 @@
|
||||
double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
|
||||
int i = (int) (150.0D * d1);
|
||||
|
||||
@@ -60,7 +61,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +211,11 @@
|
||||
@@ -183,7 +212,11 @@
|
||||
this.stopRiding();
|
||||
}
|
||||
} else {
|
||||
@@ -73,7 +74,7 @@
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide) {
|
||||
@@ -240,6 +272,18 @@
|
||||
@@ -240,6 +273,18 @@
|
||||
this.world.methodProfiler.b();
|
||||
}
|
||||
|
||||
@@ -92,7 +93,7 @@
|
||||
protected void b(BlockPosition blockposition) {
|
||||
int i = EnchantmentManager.a(Enchantments.j, this);
|
||||
|
||||
@@ -255,19 +299,19 @@
|
||||
@@ -255,19 +300,19 @@
|
||||
|
||||
protected void bC() {
|
||||
++this.deathTicks;
|
||||
@@ -121,7 +122,7 @@
|
||||
|
||||
this.die();
|
||||
|
||||
@@ -421,6 +465,17 @@
|
||||
@@ -421,6 +466,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +140,7 @@
|
||||
if (nbttagcompound.hasKeyOfType("Health", 99)) {
|
||||
this.setHealth(nbttagcompound.getFloat("Health"));
|
||||
}
|
||||
@@ -436,9 +491,15 @@
|
||||
@@ -436,9 +492,15 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -155,7 +156,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
MobEffectList mobeffectlist = (MobEffectList) iterator.next();
|
||||
MobEffect mobeffect = (MobEffect) this.effects.get(mobeffectlist);
|
||||
@@ -452,6 +513,16 @@
|
||||
@@ -452,6 +514,16 @@
|
||||
this.a(mobeffect, false);
|
||||
}
|
||||
}
|
||||
@@ -172,7 +173,7 @@
|
||||
|
||||
if (this.updateEffects) {
|
||||
if (!this.world.isClientSide) {
|
||||
@@ -548,6 +619,12 @@
|
||||
@@ -548,6 +620,12 @@
|
||||
}
|
||||
|
||||
public void addEffect(MobEffect mobeffect) {
|
||||
@@ -185,7 +186,7 @@
|
||||
if (this.d(mobeffect)) {
|
||||
MobEffect mobeffect1 = (MobEffect) this.effects.get(mobeffect.getMobEffect());
|
||||
|
||||
@@ -579,6 +656,12 @@
|
||||
@@ -579,6 +657,12 @@
|
||||
}
|
||||
|
||||
public MobEffect c(MobEffectList mobeffectlist) {
|
||||
@@ -198,7 +199,7 @@
|
||||
return (MobEffect) this.effects.remove(mobeffectlist);
|
||||
}
|
||||
|
||||
@@ -618,20 +701,52 @@
|
||||
@@ -618,20 +702,52 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -252,7 +253,7 @@
|
||||
this.datawatcher.set(EntityLiving.HEALTH, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth())));
|
||||
}
|
||||
|
||||
@@ -647,7 +762,8 @@
|
||||
@@ -647,7 +763,8 @@
|
||||
} else if (damagesource.o() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -262,7 +263,7 @@
|
||||
this.getEquipment(EnumItemSlot.HEAD).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this);
|
||||
f *= 0.75F;
|
||||
}
|
||||
@@ -673,19 +789,38 @@
|
||||
@@ -673,19 +790,38 @@
|
||||
|
||||
if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
|
||||
if (f <= this.lastDamage) {
|
||||
@@ -303,7 +304,7 @@
|
||||
this.az = 0.0F;
|
||||
Entity entity = damagesource.getEntity();
|
||||
|
||||
@@ -825,6 +960,12 @@
|
||||
@@ -825,6 +961,12 @@
|
||||
boolean flag = this.lastDamageByPlayerTime > 0;
|
||||
|
||||
this.a(flag, i, damagesource);
|
||||
@@ -316,7 +317,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,8 +1053,13 @@
|
||||
@@ -912,8 +1054,13 @@
|
||||
int i = MathHelper.f((f - 3.0F - f2) * f1);
|
||||
|
||||
if (i > 0) {
|
||||
@@ -331,7 +332,7 @@
|
||||
int j = MathHelper.floor(this.locX);
|
||||
int k = MathHelper.floor(this.locY - 0.20000000298023224D);
|
||||
int l = MathHelper.floor(this.locZ);
|
||||
@@ -940,20 +1086,20 @@
|
||||
@@ -940,20 +1087,20 @@
|
||||
|
||||
protected float applyArmorModifier(DamageSource damagesource, float f) {
|
||||
if (!damagesource.ignoresArmor()) {
|
||||
@@ -355,7 +356,7 @@
|
||||
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
|
||||
int j = 25 - i;
|
||||
float f1 = f * (float) j;
|
||||
@@ -974,22 +1120,122 @@
|
||||
@@ -974,22 +1121,122 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,7 +486,7 @@
|
||||
}
|
||||
|
||||
public CombatTracker getCombatTracker() {
|
||||
@@ -1055,6 +1301,7 @@
|
||||
@@ -1055,6 +1302,7 @@
|
||||
public AttributeMapBase getAttributeMap() {
|
||||
if (this.bp == null) {
|
||||
this.bp = new AttributeMapServer();
|
||||
@@ -493,7 +494,23 @@
|
||||
}
|
||||
|
||||
return this.bp;
|
||||
@@ -1702,6 +1949,13 @@
|
||||
@@ -1329,6 +1577,7 @@
|
||||
}
|
||||
|
||||
if (this.onGround && !this.world.isClientSide) {
|
||||
+ if (getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit
|
||||
this.setFlag(7, false);
|
||||
}
|
||||
} else {
|
||||
@@ -1689,6 +1938,7 @@
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide) {
|
||||
+ if (!CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit
|
||||
this.setFlag(7, flag);
|
||||
}
|
||||
|
||||
@@ -1702,6 +1952,13 @@
|
||||
if (!list.isEmpty()) {
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
Entity entity = (Entity) list.get(i);
|
||||
@@ -507,7 +524,7 @@
|
||||
|
||||
this.C(entity);
|
||||
}
|
||||
@@ -1918,7 +2172,22 @@
|
||||
@@ -1918,7 +2175,22 @@
|
||||
protected void v() {
|
||||
if (this.bm != null && this.cs()) {
|
||||
this.a(this.bm, 16);
|
||||
|
Reference in New Issue
Block a user