2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityHuman.java
|
|
|
|
+++ b/net/minecraft/server/EntityHuman.java
|
2019-04-23 04:00:00 +02:00
|
|
|
@@ -15,10 +15,24 @@
|
2018-12-25 22:00:00 +01:00
|
|
|
import java.util.function.Predicate;
|
2016-05-10 13:47:39 +02:00
|
|
|
import javax.annotation.Nullable;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
2019-04-23 04:00:00 +02:00
|
|
|
+import org.bukkit.craftbukkit.util.CraftVector;
|
2018-07-30 11:29:03 +02:00
|
|
|
+import org.bukkit.entity.Item;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.entity.Player;
|
2017-05-14 04:00:00 +02:00
|
|
|
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
|
|
|
+import org.bukkit.event.player.PlayerBedLeaveEvent;
|
|
|
|
+import org.bukkit.event.player.PlayerDropItemEvent;
|
2014-12-06 22:27:04 +01:00
|
|
|
+import org.bukkit.event.player.PlayerVelocityEvent;
|
|
|
|
+import org.bukkit.util.Vector;
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public abstract class EntityHuman extends EntityLiving {
|
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
public static final EntitySize bp = EntitySize.b(0.6F, 1.8F);
|
|
|
|
- private static final Map<EntityPose, EntitySize> b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bp).put(EntityPose.SLEEPING, EntityHuman.ap).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build();
|
2019-04-23 04:00:00 +02:00
|
|
|
+ // CraftBukkit - decompile error
|
2019-12-10 23:00:00 +01:00
|
|
|
+ private static final Map<EntityPose, EntitySize> b = ImmutableMap.<EntityPose, EntitySize>builder().put(EntityPose.STANDING, EntityHuman.bp).put(EntityPose.SLEEPING, EntityHuman.ap).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build();
|
2019-04-23 04:00:00 +02:00
|
|
|
private static final DataWatcherObject<Float> c = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c);
|
|
|
|
private static final DataWatcherObject<Integer> d = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.b);
|
2019-12-10 23:00:00 +01:00
|
|
|
protected static final DataWatcherObject<Byte> bq = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
|
2019-07-20 01:00:00 +02:00
|
|
|
@@ -27,10 +41,10 @@
|
2019-12-10 23:00:00 +01:00
|
|
|
protected static final DataWatcherObject<NBTTagCompound> bt = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
|
2019-07-20 01:00:00 +02:00
|
|
|
private long e;
|
2019-04-23 04:00:00 +02:00
|
|
|
public final PlayerInventory inventory = new PlayerInventory(this);
|
2017-05-14 04:00:00 +02:00
|
|
|
- protected InventoryEnderChest enderChest = new InventoryEnderChest();
|
|
|
|
+ protected InventoryEnderChest enderChest = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor
|
2019-04-23 04:00:00 +02:00
|
|
|
public final ContainerPlayer defaultContainer;
|
2014-11-25 22:32:16 +01:00
|
|
|
public Container activeContainer;
|
|
|
|
- protected FoodMetaData foodData = new FoodMetaData();
|
|
|
|
+ protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor
|
2019-12-10 23:00:00 +01:00
|
|
|
protected int bz;
|
|
|
|
public float bA;
|
|
|
|
public float bB;
|
2019-07-20 01:00:00 +02:00
|
|
|
@@ -58,6 +72,17 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
@Nullable
|
2014-11-25 22:32:16 +01:00
|
|
|
public EntityFishingHook hookedFish;
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ public boolean fauxSleeping;
|
|
|
|
+ public String spawnWorld = "";
|
2015-06-06 11:33:48 +02:00
|
|
|
+ public int oldLevel = -1;
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CraftHumanEntity getBukkitEntity() {
|
|
|
|
+ return (CraftHumanEntity) super.getBukkitEntity();
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
public EntityHuman(World world, GameProfile gameprofile) {
|
|
|
|
super(EntityTypes.PLAYER, world);
|
2019-12-10 23:00:00 +01:00
|
|
|
this.bV = ItemStack.a;
|
|
|
|
@@ -206,7 +231,7 @@
|
2018-07-20 08:04:37 +02:00
|
|
|
ItemStack itemstack = this.getEquipment(EnumItemSlot.HEAD);
|
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
if (itemstack.getItem() == Items.TURTLE_HELMET && !this.a(TagsFluid.WATER)) {
|
2018-07-20 08:04:37 +02:00
|
|
|
- this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true));
|
|
|
|
+ this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TURTLE_HELMET); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -379,7 +404,8 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-06-21 12:00:00 +02:00
|
|
|
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean(GameRules.NATURAL_REGENERATION)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) {
|
|
|
|
- this.heal(1.0F);
|
|
|
|
+ // CraftBukkit - added regain reason of "REGEN" for filtering purposes.
|
|
|
|
+ this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.foodData.c() && this.ticksLived % 10 == 0) {
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -563,6 +589,30 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
entityitem.setMot((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - fire PlayerDropItemEvent
|
|
|
|
+ Player player = (Player) this.getBukkitEntity();
|
2018-07-30 11:29:03 +02:00
|
|
|
+ Item drop = (Item) entityitem.getBukkitEntity();
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
|
|
|
|
+ if (flag1 && (cur == null || cur.getAmount() == 0)) {
|
|
|
|
+ // The complete stack was dropped
|
|
|
|
+ player.getInventory().setItemInHand(drop.getItemStack());
|
2017-12-02 22:55:19 +01:00
|
|
|
+ } else if (flag1 && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // Only one item is dropped
|
|
|
|
+ cur.setAmount(cur.getAmount() + 1);
|
|
|
|
+ player.getInventory().setItemInHand(cur);
|
|
|
|
+ } else {
|
|
|
|
+ // Fallback
|
|
|
|
+ player.getInventory().addItem(drop.getItemStack());
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
return entityitem;
|
|
|
|
}
|
|
|
|
}
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -637,6 +687,14 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
this.setScore(nbttagcompound.getInt("Score"));
|
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ this.spawnWorld = nbttagcompound.getString("SpawnWorld");
|
|
|
|
+ if ("".equals(spawnWorld)) {
|
|
|
|
+ this.spawnWorld = this.world.getServer().getWorlds().get(0).getName();
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) {
|
2019-07-20 01:00:00 +02:00
|
|
|
this.g = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
|
2019-12-10 23:00:00 +01:00
|
|
|
this.bR = nbttagcompound.getBoolean("SpawnForced");
|
|
|
|
@@ -687,6 +745,7 @@
|
2017-05-14 04:00:00 +02:00
|
|
|
if (!this.getShoulderEntityRight().isEmpty()) {
|
|
|
|
nbttagcompound.set("ShoulderEntityRight", this.getShoulderEntityRight());
|
|
|
|
}
|
2014-12-13 23:35:37 +01:00
|
|
|
+ nbttagcompound.setString("SpawnWorld", spawnWorld); // CraftBukkit - fixes bed spawns for multiworld worlds
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2017-05-14 04:00:00 +02:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -700,16 +759,17 @@
|
2019-08-24 16:43:43 +02:00
|
|
|
if (this.isInvulnerable(damagesource)) {
|
|
|
|
return false;
|
|
|
|
} else if (this.abilities.isInvulnerable && !damagesource.ignoresInvulnerability()) {
|
|
|
|
+ this.forceExplosionKnockback = true; // SPIGOT-5258 - Make invulnerable players get knockback from explosions
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
this.ticksFarFromPlayer = 0;
|
2019-04-23 04:00:00 +02:00
|
|
|
if (this.getHealth() <= 0.0F) {
|
|
|
|
return false;
|
|
|
|
} else {
|
2017-06-11 04:20:18 +02:00
|
|
|
- this.releaseShoulderEntities();
|
|
|
|
+ // this.releaseShoulderEntities(); // CraftBukkit - moved down
|
2018-07-15 02:00:00 +02:00
|
|
|
if (damagesource.s()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) {
|
|
|
|
- f = 0.0F;
|
|
|
|
+ return false; // CraftBukkit - f = 0.0f -> return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.world.getDifficulty() == EnumDifficulty.EASY) {
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -721,7 +781,13 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-09 03:43:49 +02:00
|
|
|
- return f == 0.0F ? false : super.damageEntity(damagesource, f);
|
2017-06-11 04:20:18 +02:00
|
|
|
+ // CraftBukkit start - Don't filter out 0 damage
|
|
|
|
+ boolean damaged = super.damageEntity(damagesource, f);
|
|
|
|
+ if (damaged) {
|
|
|
|
+ this.releaseShoulderEntities();
|
|
|
|
+ }
|
|
|
|
+ return damaged;
|
|
|
|
+ // CraftBukkit end
|
2016-06-09 03:43:49 +02:00
|
|
|
}
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -736,10 +802,29 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public boolean a(EntityHuman entityhuman) {
|
2018-12-13 01:00:00 +01:00
|
|
|
- ScoreboardTeamBase scoreboardteambase = this.getScoreboardTeam();
|
|
|
|
- ScoreboardTeamBase scoreboardteambase1 = entityhuman.getScoreboardTeam();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Change to check OTHER player's scoreboard team according to API
|
|
|
|
+ // To summarize this method's logic, it's "Can parameter hurt this"
|
|
|
|
+ org.bukkit.scoreboard.Team team;
|
|
|
|
+ if (entityhuman instanceof EntityPlayer) {
|
|
|
|
+ EntityPlayer thatPlayer = (EntityPlayer) entityhuman;
|
|
|
|
+ team = thatPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thatPlayer.getBukkitEntity());
|
|
|
|
+ if (team == null || team.allowFriendlyFire()) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // This should never be called, but is implemented anyway
|
|
|
|
+ org.bukkit.OfflinePlayer thisPlayer = entityhuman.world.getServer().getOfflinePlayer(entityhuman.getName());
|
|
|
|
+ team = entityhuman.world.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
|
|
|
|
+ if (team == null || team.allowFriendlyFire()) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return scoreboardteambase == null ? true : (!scoreboardteambase.isAlly(scoreboardteambase1) ? true : scoreboardteambase.allowFriendlyFire());
|
|
|
|
+ if (this instanceof EntityPlayer) {
|
|
|
|
+ return !team.hasPlayer(((EntityPlayer) this).getBukkitEntity());
|
|
|
|
+ }
|
|
|
|
+ return !team.hasPlayer(this.world.getServer().getOfflinePlayer(this.getName()));
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -770,8 +855,13 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
|
|
|
- protected void damageEntity0(DamageSource damagesource, float f) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ protected boolean damageEntity0(DamageSource damagesource, float f) { // void -> boolean
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (true) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ return super.damageEntity0(damagesource, f);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
if (!this.isInvulnerable(damagesource)) {
|
2016-02-29 22:32:46 +01:00
|
|
|
f = this.applyArmorModifier(damagesource, f);
|
|
|
|
f = this.applyMagicModifier(damagesource, f);
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -797,6 +887,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ return false; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
public void openSign(TileEntitySign tileentitysign) {}
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -978,8 +1069,15 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
if (entity instanceof EntityLiving) {
|
|
|
|
f3 = ((EntityLiving) entity).getHealth();
|
|
|
|
if (j > 0 && !entity.isBurning()) {
|
|
|
|
- flag4 = true;
|
2016-03-10 21:01:33 +01:00
|
|
|
- entity.setOnFire(1);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
|
|
|
|
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 1);
|
|
|
|
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (!combustEvent.isCancelled()) {
|
|
|
|
+ flag4 = true;
|
2019-01-11 01:41:32 +01:00
|
|
|
+ entity.setOnFire(combustEvent.getDuration(), false);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2016-03-10 21:01:33 +01:00
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -1007,8 +1105,11 @@
|
2016-03-31 13:50:58 +02:00
|
|
|
EntityLiving entityliving = (EntityLiving) iterator.next();
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
if (entityliving != this && entityliving != entity && !this.r(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.h((Entity) entityliving) < 9.0D) {
|
2016-03-31 13:50:58 +02:00
|
|
|
+ // CraftBukkit start - Only apply knockback if the damage hits
|
2016-12-23 12:39:33 +01:00
|
|
|
+ if (entityliving.damageEntity(DamageSource.playerAttack(this).sweep(), f4)) {
|
2016-03-31 13:50:58 +02:00
|
|
|
entityliving.a(this, 0.4F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)));
|
2016-12-20 21:00:00 +01:00
|
|
|
- entityliving.damageEntity(DamageSource.playerAttack(this), f4);
|
2016-03-31 13:50:58 +02:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -1017,9 +1118,26 @@
|
2014-12-06 22:27:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (entity instanceof EntityPlayer && entity.velocityChanged) {
|
|
|
|
+ // CraftBukkit start - Add Velocity Event
|
|
|
|
+ boolean cancelled = false;
|
|
|
|
+ Player player = (Player) entity.getBukkitEntity();
|
2019-04-23 04:00:00 +02:00
|
|
|
+ org.bukkit.util.Vector velocity = CraftVector.toBukkit(vec3d);
|
2014-12-06 22:27:04 +01:00
|
|
|
+
|
2014-12-07 12:26:58 +01:00
|
|
|
+ PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
|
2014-12-06 22:27:04 +01:00
|
|
|
+ world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ cancelled = true;
|
|
|
|
+ } else if (!velocity.equals(event.getVelocity())) {
|
2015-07-20 21:42:30 +02:00
|
|
|
+ player.setVelocity(event.getVelocity());
|
2014-12-06 22:27:04 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!cancelled) {
|
2016-02-29 22:32:46 +01:00
|
|
|
((EntityPlayer) entity).playerConnection.sendPacket(new PacketPlayOutEntityVelocity(entity));
|
|
|
|
entity.velocityChanged = false;
|
2019-04-23 04:00:00 +02:00
|
|
|
entity.setMot(vec3d);
|
2014-12-06 22:27:04 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
if (flag2) {
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -1064,7 +1182,14 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
this.a(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F));
|
2014-11-25 22:32:16 +01:00
|
|
|
if (j > 0) {
|
|
|
|
- entity.setOnFire(j * 4);
|
|
|
|
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
|
|
|
|
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4);
|
|
|
|
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
|
|
|
|
+
|
|
|
|
+ if (!combustEvent.isCancelled()) {
|
2019-07-21 03:45:05 +02:00
|
|
|
+ entity.setOnFire(combustEvent.getDuration(), false);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2016-12-20 21:00:00 +01:00
|
|
|
if (this.world instanceof WorldServer && f5 > 2.0F) {
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -1080,6 +1205,11 @@
|
2016-11-20 04:13:21 +01:00
|
|
|
if (flag4) {
|
|
|
|
entity.extinguish();
|
|
|
|
}
|
|
|
|
+ // CraftBukkit start - resync on cancelled event
|
|
|
|
+ if (this instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) this).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -1139,15 +1269,15 @@
|
|
|
|
return this.bT;
|
2018-11-02 08:31:00 +01:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
- public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition) {
|
2018-11-02 08:31:00 +01:00
|
|
|
- EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING);
|
|
|
|
-
|
|
|
|
+ // CraftBukkit start - moved bed result checks from below into separate method
|
2019-04-23 04:00:00 +02:00
|
|
|
+ private Either<EntityHuman.EnumBedResult, Unit> getBedResult(BlockPosition blockposition, EnumDirection enumdirection) {
|
2018-11-02 08:31:00 +01:00
|
|
|
if (!this.world.isClientSide) {
|
|
|
|
if (this.isSleeping() || !this.isAlive()) {
|
2019-04-23 04:00:00 +02:00
|
|
|
return Either.left(EntityHuman.EnumBedResult.OTHER_PROBLEM);
|
2018-11-02 08:31:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- if (!this.world.worldProvider.isOverworld()) {
|
|
|
|
+ // CraftBukkit - moved world and biome check from BlockBed interact handling here
|
|
|
|
+ if (!world.worldProvider.canRespawn() || world.getBiome(blockposition) == Biomes.NETHER || !this.world.worldProvider.isOverworld()) {
|
2019-04-23 04:00:00 +02:00
|
|
|
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE);
|
2018-11-02 08:31:00 +01:00
|
|
|
}
|
|
|
|
|
2020-01-21 22:00:00 +01:00
|
|
|
@@ -1177,6 +1307,34 @@
|
2018-11-02 08:31:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-23 04:00:00 +02:00
|
|
|
+ return Either.right(Unit.INSTANCE);
|
2018-11-02 08:31:00 +01:00
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
+ public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition) {
|
2019-01-02 04:41:31 +01:00
|
|
|
+ // CraftBukkit start - moved checks into separate method above, add force
|
2019-04-23 04:00:00 +02:00
|
|
|
+ return this.sleep(blockposition, false);
|
2019-01-02 04:41:31 +01:00
|
|
|
+ }
|
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
+ public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition, boolean force) {
|
2018-11-02 08:31:00 +01:00
|
|
|
+ EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING);
|
2019-04-23 04:00:00 +02:00
|
|
|
+ Either<EntityHuman.EnumBedResult, Unit> bedResult = this.getBedResult(blockposition, enumdirection);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
+ if (bedResult.left().orElse(null) == EntityHuman.EnumBedResult.OTHER_PROBLEM) {
|
2018-11-02 08:31:00 +01:00
|
|
|
+ return bedResult; // return immediately if the result is not bypassable by plugins
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-13 04:48:19 +01:00
|
|
|
+ if (force) {
|
2019-04-23 04:00:00 +02:00
|
|
|
+ bedResult = Either.right(Unit.INSTANCE);
|
2019-03-13 04:48:19 +01:00
|
|
|
+ }
|
|
|
|
+
|
2018-11-02 08:31:00 +01:00
|
|
|
+ if (this.getBukkitEntity() instanceof Player) {
|
|
|
|
+ bedResult = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBedEnterEvent(this, blockposition, bedResult);
|
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
+ if (bedResult.left().isPresent()) {
|
2018-11-02 08:31:00 +01:00
|
|
|
+ return bedResult;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2018-11-02 08:31:00 +01:00
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
this.entitySleep(blockposition);
|
2019-04-23 04:00:00 +02:00
|
|
|
this.sleepTicks = 0;
|
2020-01-21 22:00:00 +01:00
|
|
|
@@ -1211,11 +1369,28 @@
|
2019-12-25 00:11:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void wakeup(boolean flag, boolean flag1) {
|
|
|
|
+ BlockPosition bedPosition = this.getBedPosition().orElse(null); // CraftBukkit
|
|
|
|
super.entityWakeup();
|
|
|
|
if (this.world instanceof WorldServer && flag1) {
|
2019-04-23 04:00:00 +02:00
|
|
|
((WorldServer) this.world).everyoneSleeping();
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - fire PlayerBedLeaveEvent
|
|
|
|
+ if (this.getBukkitEntity() instanceof Player) {
|
|
|
|
+ Player player = (Player) this.getBukkitEntity();
|
|
|
|
+
|
|
|
|
+ org.bukkit.block.Block bed;
|
2019-12-25 00:11:08 +01:00
|
|
|
+ if (bedPosition != null) {
|
|
|
|
+ bed = this.world.getWorld().getBlockAt(bedPosition.getX(), bedPosition.getY(), bedPosition.getZ());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ } else {
|
|
|
|
+ bed = this.world.getWorld().getBlockAt(player.getLocation());
|
|
|
|
+ }
|
|
|
|
+
|
2019-12-10 23:00:00 +01:00
|
|
|
+ PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, true);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
this.sleepTicks = flag ? 0 : 100;
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|
|
|
|
|
2020-01-21 22:00:00 +01:00
|
|
|
@@ -1267,9 +1442,11 @@
|
2019-12-10 23:00:00 +01:00
|
|
|
|
2019-07-20 01:00:00 +02:00
|
|
|
this.g = blockposition;
|
2019-12-10 23:00:00 +01:00
|
|
|
this.bR = flag;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.spawnWorld = this.world.worldData.getName(); // CraftBukkit
|
|
|
|
} else {
|
2019-07-20 01:00:00 +02:00
|
|
|
this.g = null;
|
2019-12-10 23:00:00 +01:00
|
|
|
this.bR = false;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.spawnWorld = ""; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-01-21 22:00:00 +01:00
|
|
|
@@ -1341,7 +1518,11 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
this.setMot(vec3d2.x, d3 * 0.6D, vec3d2.z);
|
2019-12-10 23:00:00 +01:00
|
|
|
this.aM = f;
|
2017-11-27 23:33:40 +01:00
|
|
|
this.fallDistance = 0.0F;
|
|
|
|
- this.setFlag(7, false);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (getFlag(7) && !org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
|
|
|
|
+ this.setFlag(7, false);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
} else {
|
2019-04-23 04:00:00 +02:00
|
|
|
super.e(vec3d);
|
2017-11-27 23:33:40 +01:00
|
|
|
}
|
2020-01-25 01:30:39 +01:00
|
|
|
@@ -1467,12 +1648,24 @@
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void startGliding() {
|
2020-01-25 01:30:39 +01:00
|
|
|
- this.setFlag(7, true);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, true).isCancelled()) {
|
|
|
|
+ this.setFlag(7, true);
|
|
|
|
+ } else {
|
|
|
|
+ // SPIGOT-5542: must toggle like below
|
|
|
|
+ this.setFlag(7, true);
|
|
|
|
+ this.setFlag(7, false);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void stopGliding() {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
|
|
|
|
this.setFlag(7, true);
|
|
|
|
this.setFlag(7, false);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-01-25 01:30:39 +01:00
|
|
|
@@ -1687,26 +1880,31 @@
|
2017-05-14 04:00:00 +02:00
|
|
|
|
|
|
|
protected void releaseShoulderEntities() {
|
2019-07-20 01:00:00 +02:00
|
|
|
if (this.e + 20L < this.world.getTime()) {
|
|
|
|
- this.spawnEntityFromShoulder(this.getShoulderEntityLeft());
|
|
|
|
- this.setShoulderEntityLeft(new NBTTagCompound());
|
|
|
|
- this.spawnEntityFromShoulder(this.getShoulderEntityRight());
|
|
|
|
- this.setShoulderEntityRight(new NBTTagCompound());
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (this.spawnEntityFromShoulder(this.getShoulderEntityLeft())) {
|
|
|
|
+ this.setShoulderEntityLeft(new NBTTagCompound());
|
|
|
|
+ }
|
|
|
|
+ if (this.spawnEntityFromShoulder(this.getShoulderEntityRight())) {
|
|
|
|
+ this.setShoulderEntityRight(new NBTTagCompound());
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2017-05-14 04:00:00 +02:00
|
|
|
}
|
|
|
|
|
2019-07-20 01:00:00 +02:00
|
|
|
- private void spawnEntityFromShoulder(NBTTagCompound nbttagcompound) {
|
|
|
|
+ private boolean spawnEntityFromShoulder(NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean
|
2017-05-14 04:00:00 +02:00
|
|
|
if (!this.world.isClientSide && !nbttagcompound.isEmpty()) {
|
2019-04-23 04:00:00 +02:00
|
|
|
- EntityTypes.a(nbttagcompound, this.world).ifPresent((entity) -> {
|
|
|
|
+ return EntityTypes.a(nbttagcompound, this.world).map((entity) -> { // CraftBukkit
|
|
|
|
if (entity instanceof EntityTameableAnimal) {
|
|
|
|
((EntityTameableAnimal) entity).setOwnerUUID(this.uniqueID);
|
|
|
|
}
|
2017-05-14 04:00:00 +02:00
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
entity.setPosition(this.locX(), this.locY() + 0.699999988079071D, this.locZ());
|
2019-04-23 04:00:00 +02:00
|
|
|
- ((WorldServer) this.world).addEntitySerialized(entity);
|
|
|
|
- });
|
|
|
|
+ return ((WorldServer) this.world).addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
|
|
|
|
+ }).orElse(true); // CraftBukkit
|
2017-05-14 04:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ return true; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
2019-06-02 11:51:26 +02:00
|
|
|
@Override
|