mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-08 08:02:13 -07:00
SPIGOT-1571: Add Entity Glide Events.
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
--- a/net/minecraft/server/EntityHuman.java
|
||||
+++ b/net/minecraft/server/EntityHuman.java
|
||||
@@ -9,6 +9,18 @@
|
||||
@@ -9,6 +9,19 @@
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.craftbukkit.entity.CraftItem;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
+import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
@@ -19,7 +20,7 @@
|
||||
public abstract class EntityHuman extends EntityLiving {
|
||||
|
||||
private static final DataWatcherObject<Float> a = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c);
|
||||
@@ -19,7 +31,7 @@
|
||||
@@ -19,7 +32,7 @@
|
||||
private InventoryEnderChest enderChest = new InventoryEnderChest();
|
||||
public Container defaultContainer;
|
||||
public Container activeContainer;
|
||||
@@ -28,7 +29,7 @@
|
||||
protected int bv;
|
||||
public float bw;
|
||||
public float bx;
|
||||
@@ -52,6 +64,17 @@
|
||||
@@ -52,6 +65,17 @@
|
||||
private final ItemCooldown bU = this.l();
|
||||
public EntityFishingHook hookedFish;
|
||||
|
||||
@@ -46,7 +47,7 @@
|
||||
protected ItemCooldown l() {
|
||||
return new ItemCooldown();
|
||||
}
|
||||
@@ -301,7 +324,8 @@
|
||||
@@ -301,7 +325,8 @@
|
||||
|
||||
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean("naturalRegeneration")) {
|
||||
if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) {
|
||||
@@ -56,7 +57,7 @@
|
||||
}
|
||||
|
||||
if (this.foodData.c() && this.ticksLived % 10 == 0) {
|
||||
@@ -325,7 +349,7 @@
|
||||
@@ -325,7 +350,7 @@
|
||||
|
||||
this.l((float) attributeinstance.getValue());
|
||||
float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
|
||||
@@ -65,7 +66,7 @@
|
||||
|
||||
if (f > 0.1F) {
|
||||
f = 0.1F;
|
||||
@@ -416,28 +440,35 @@
|
||||
@@ -416,28 +441,35 @@
|
||||
public void b(Entity entity, int i) {
|
||||
if (entity != this) {
|
||||
this.addScore(i);
|
||||
@@ -108,7 +109,7 @@
|
||||
private Collection<ScoreboardObjective> d(Entity entity) {
|
||||
String s = entity instanceof EntityHuman ? entity.getName() : entity.getUniqueID().toString();
|
||||
ScoreboardTeam scoreboardteam = this.getScoreboard().getPlayerTeam(this.getName());
|
||||
@@ -471,6 +502,7 @@
|
||||
@@ -471,6 +503,7 @@
|
||||
}
|
||||
|
||||
public EntityItem a(boolean flag) {
|
||||
@@ -116,7 +117,7 @@
|
||||
return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && this.inventory.getItemInHand() != null ? this.inventory.getItemInHand().count : 1), false, true);
|
||||
}
|
||||
|
||||
@@ -513,6 +545,30 @@
|
||||
@@ -513,6 +546,30 @@
|
||||
entityitem.motZ += Math.sin((double) f1) * (double) f;
|
||||
}
|
||||
|
||||
@@ -147,7 +148,7 @@
|
||||
ItemStack itemstack1 = this.a(entityitem);
|
||||
|
||||
if (flag1) {
|
||||
@@ -612,6 +668,13 @@
|
||||
@@ -612,6 +669,13 @@
|
||||
this.a(true, true, false);
|
||||
}
|
||||
|
||||
@@ -161,7 +162,7 @@
|
||||
if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) {
|
||||
this.e = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
|
||||
this.f = nbttagcompound.getBoolean("SpawnForced");
|
||||
@@ -649,6 +712,12 @@
|
||||
@@ -649,6 +713,12 @@
|
||||
this.foodData.b(nbttagcompound);
|
||||
this.abilities.a(nbttagcompound);
|
||||
nbttagcompound.set("EnderItems", this.enderChest.h());
|
||||
@@ -174,7 +175,7 @@
|
||||
}
|
||||
|
||||
public boolean damageEntity(DamageSource damagesource, float f) {
|
||||
@@ -667,7 +736,7 @@
|
||||
@@ -667,7 +737,7 @@
|
||||
|
||||
if (damagesource.r()) {
|
||||
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) {
|
||||
@@ -183,7 +184,7 @@
|
||||
}
|
||||
|
||||
if (this.world.getDifficulty() == EnumDifficulty.EASY) {
|
||||
@@ -679,7 +748,7 @@
|
||||
@@ -679,7 +749,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +193,7 @@
|
||||
return false;
|
||||
} else {
|
||||
Entity entity = damagesource.getEntity();
|
||||
@@ -695,10 +764,29 @@
|
||||
@@ -695,10 +765,29 @@
|
||||
}
|
||||
|
||||
public boolean a(EntityHuman entityhuman) {
|
||||
@@ -225,7 +226,7 @@
|
||||
}
|
||||
|
||||
protected void damageArmor(float f) {
|
||||
@@ -742,7 +830,12 @@
|
||||
@@ -742,7 +831,12 @@
|
||||
return (float) i / (float) this.inventory.armor.length;
|
||||
}
|
||||
|
||||
@@ -239,7 +240,7 @@
|
||||
if (!this.isInvulnerable(damagesource)) {
|
||||
f = this.applyArmorModifier(damagesource, f);
|
||||
f = this.applyMagicModifier(damagesource, f);
|
||||
@@ -762,6 +855,7 @@
|
||||
@@ -762,6 +856,7 @@
|
||||
|
||||
}
|
||||
}
|
||||
@@ -247,7 +248,7 @@
|
||||
}
|
||||
|
||||
public void openSign(TileEntitySign tileentitysign) {}
|
||||
@@ -884,8 +978,15 @@
|
||||
@@ -884,8 +979,15 @@
|
||||
if (entity instanceof EntityLiving) {
|
||||
f3 = ((EntityLiving) entity).getHealth();
|
||||
if (j > 0 && !entity.isBurning()) {
|
||||
@@ -265,7 +266,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -925,11 +1026,28 @@
|
||||
@@ -925,11 +1027,28 @@
|
||||
}
|
||||
|
||||
if (entity instanceof EntityPlayer && entity.velocityChanged) {
|
||||
@@ -294,7 +295,7 @@
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
@@ -991,7 +1109,8 @@
|
||||
@@ -991,7 +1110,8 @@
|
||||
|
||||
if (itemstack3 != null && object instanceof EntityLiving) {
|
||||
itemstack3.a((EntityLiving) object, this);
|
||||
@@ -304,7 +305,7 @@
|
||||
this.a(EnumHand.MAIN_HAND, (ItemStack) null);
|
||||
}
|
||||
}
|
||||
@@ -1001,7 +1120,14 @@
|
||||
@@ -1001,7 +1121,14 @@
|
||||
|
||||
this.a(StatisticList.y, Math.round(f5 * 10.0F));
|
||||
if (j > 0) {
|
||||
@@ -320,7 +321,7 @@
|
||||
}
|
||||
|
||||
if (this.world instanceof WorldServer && f5 > 2.0F) {
|
||||
@@ -1090,6 +1216,20 @@
|
||||
@@ -1090,6 +1217,20 @@
|
||||
this.stopRiding();
|
||||
}
|
||||
|
||||
@@ -341,7 +342,7 @@
|
||||
this.setSize(0.2F, 0.2F);
|
||||
if (this.world.isLoaded(blockposition)) {
|
||||
EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING);
|
||||
@@ -1172,6 +1312,23 @@
|
||||
@@ -1172,6 +1313,23 @@
|
||||
this.world.everyoneSleeping();
|
||||
}
|
||||
|
||||
@@ -365,7 +366,7 @@
|
||||
this.sleepTicks = flag ? 0 : 100;
|
||||
if (flag2) {
|
||||
this.setRespawnPosition(this.bedPosition, false);
|
||||
@@ -1222,9 +1379,11 @@
|
||||
@@ -1222,9 +1380,11 @@
|
||||
if (blockposition != null) {
|
||||
this.e = blockposition;
|
||||
this.f = flag;
|
||||
@@ -377,3 +378,11 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1266,6 +1426,7 @@
|
||||
this.motY = d3 * 0.6D;
|
||||
this.aQ = f2;
|
||||
this.fallDistance = 0.0F;
|
||||
+ if (!CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit
|
||||
this.setFlag(7, false);
|
||||
} else {
|
||||
super.g(f, f1);
|
||||
|
Reference in New Issue
Block a user