2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityHuman.java
|
|
|
|
+++ b/net/minecraft/server/EntityHuman.java
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -15,6 +15,19 @@
|
|
|
|
import java.util.function.ToIntFunction;
|
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;
|
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.PlayerBedEnterEvent;
|
|
|
|
+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 {
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
private static final DataWatcherObject<Float> a = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c);
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -24,10 +37,10 @@
|
|
|
|
protected static final DataWatcherObject<NBTTagCompound> bz = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
|
|
|
|
protected static final DataWatcherObject<NBTTagCompound> bA = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
|
2016-11-17 02:41:03 +01:00
|
|
|
public 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
|
2014-11-25 22:32:16 +01:00
|
|
|
public Container defaultContainer;
|
|
|
|
public Container activeContainer;
|
|
|
|
- protected FoodMetaData foodData = new FoodMetaData();
|
|
|
|
+ protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor
|
2018-07-15 02:00:00 +02:00
|
|
|
protected int bG;
|
|
|
|
public float bH;
|
|
|
|
public float bI;
|
|
|
|
@@ -60,6 +73,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);
|
|
|
|
this.cd = ItemStack.a;
|
2018-07-20 08:04:37 +02:00
|
|
|
@@ -184,7 +208,7 @@
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -369,7 +393,8 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean("naturalRegeneration")) {
|
|
|
|
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) {
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -393,7 +418,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
this.o((float) attributeinstance.getValue());
|
2014-11-25 22:32:16 +01:00
|
|
|
float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
|
|
|
|
- float f1 = (float) (Math.atan(-this.motY * 0.20000000298023224D) * 15.0D);
|
|
|
|
+ float f1 = (float) ( org.bukkit.craftbukkit.TrigMath.atan(-this.motY * 0.20000000298023224D) * 15.0D); // CraftBukkit
|
|
|
|
|
|
|
|
if (f > 0.1F) {
|
|
|
|
f = 0.1F;
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -516,6 +541,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-05-10 13:47:39 +02:00
|
|
|
@Nullable
|
2014-11-25 22:32:16 +01:00
|
|
|
public EntityItem a(boolean flag) {
|
|
|
|
+ // Called only when dropped by Q or CTRL-Q
|
2016-11-17 02:41:03 +01:00
|
|
|
return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && !this.inventory.getItemInHand().isEmpty() ? this.inventory.getItemInHand().getCount() : 1), false, true);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -558,6 +584,30 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
entityitem.motZ += Math.sin((double) f1) * (double) f;
|
|
|
|
}
|
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
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
ItemStack itemstack1 = this.a(entityitem);
|
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
if (flag1) {
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -655,6 +705,13 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
this.a(true, true, false);
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
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)) {
|
2018-07-15 02:00:00 +02:00
|
|
|
this.e = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
|
|
|
|
this.f = nbttagcompound.getBoolean("SpawnForced");
|
|
|
|
@@ -705,6 +762,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
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -722,10 +780,10 @@
|
2017-06-11 04:20:18 +02:00
|
|
|
this.a(true, true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
- 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) {
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -737,7 +795,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
|
|
|
}
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -751,10 +815,29 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public boolean a(EntityHuman entityhuman) {
|
2018-07-15 02:00:00 +02:00
|
|
|
- ScoreboardTeamBase scoreboardteambase = this.be();
|
|
|
|
- ScoreboardTeamBase scoreboardteambase1 = entityhuman.be();
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void damageArmor(float f) {
|
2018-07-15 02:00:00 +02:00
|
|
|
@@ -797,7 +880,12 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
return (float) i / (float) this.inventory.armor.size();
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
- protected void damageEntity0(DamageSource damagesource, float f) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
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);
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -823,6 +911,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ return false; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
public void openSign(TileEntitySign tileentitysign) {}
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -944,8 +1033,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;
|
|
|
|
+ entity.setOnFire(combustEvent.getDuration());
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2016-03-10 21:01:33 +01:00
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -976,8 +1072,11 @@
|
2016-03-31 13:50:58 +02:00
|
|
|
EntityLiving entityliving = (EntityLiving) iterator.next();
|
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
if (entityliving != this && entityliving != entity && !this.r(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.h(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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -986,11 +1085,28 @@
|
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();
|
2016-02-29 22:32:46 +01:00
|
|
|
+ org.bukkit.util.Vector velocity = new Vector( d1, d2, d3 );
|
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;
|
|
|
|
entity.motX = d1;
|
|
|
|
entity.motY = d2;
|
|
|
|
entity.motZ = d3;
|
2014-12-06 22:27:04 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
if (flag2) {
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -1039,7 +1155,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()) {
|
|
|
|
+ entity.setOnFire(combustEvent.getDuration());
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2016-12-20 21:00:00 +01:00
|
|
|
if (this.world instanceof WorldServer && f5 > 2.0F) {
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -1055,6 +1178,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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -1151,6 +1279,20 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
this.stopRiding();
|
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 PlayerBedEnterEvent
|
|
|
|
+ if (this.getBukkitEntity() instanceof Player) {
|
|
|
|
+ Player player = (Player) this.getBukkitEntity();
|
|
|
|
+ org.bukkit.block.Block bed = this.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
|
|
+
|
|
|
|
+ PlayerBedEnterEvent event = new PlayerBedEnterEvent(player, bed);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return EnumBedResult.OTHER_PROBLEM;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2017-05-14 04:00:00 +02:00
|
|
|
this.releaseShoulderEntities();
|
2018-08-26 04:00:00 +02:00
|
|
|
this.a(StatisticList.CUSTOM.b(StatisticList.TIME_SINCE_REST));
|
2015-02-26 23:41:06 +01:00
|
|
|
this.setSize(0.2F, 0.2F);
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -1212,6 +1354,23 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
this.world.everyoneSleeping();
|
|
|
|
}
|
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;
|
2016-02-29 22:32:46 +01:00
|
|
|
+ BlockPosition blockposition = this.bedPosition;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (blockposition != null) {
|
|
|
|
+ bed = this.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
|
|
+ } else {
|
|
|
|
+ bed = this.world.getWorld().getBlockAt(player.getLocation());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed);
|
|
|
|
+ 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;
|
|
|
|
if (flag2) {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.setRespawnPosition(this.bedPosition, false);
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -1263,9 +1422,11 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
if (blockposition != null) {
|
2018-07-15 02:00:00 +02:00
|
|
|
this.e = blockposition;
|
|
|
|
this.f = flag;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.spawnWorld = this.world.worldData.getName(); // CraftBukkit
|
|
|
|
} else {
|
2018-07-15 02:00:00 +02:00
|
|
|
this.e = null;
|
|
|
|
this.f = false;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.spawnWorld = ""; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -1331,7 +1492,11 @@
|
2017-11-27 23:33:40 +01:00
|
|
|
this.motY = d3 * 0.6D;
|
2018-07-15 02:00:00 +02:00
|
|
|
this.aU = f3;
|
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 {
|
|
|
|
super.a(f, f1, f2);
|
|
|
|
}
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -1631,13 +1796,17 @@
|
2017-05-14 04:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void releaseShoulderEntities() {
|
|
|
|
- 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
|
|
|
|
}
|
|
|
|
|
|
|
|
- private void spawnEntityFromShoulder(@Nullable NBTTagCompound nbttagcompound) {
|
|
|
|
+ private boolean spawnEntityFromShoulder(@Nullable NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean
|
|
|
|
if (!this.world.isClientSide && !nbttagcompound.isEmpty()) {
|
|
|
|
Entity entity = EntityTypes.a(nbttagcompound, this.world);
|
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -1646,9 +1815,10 @@
|
2017-05-14 04:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
entity.setPosition(this.locX, this.locY + 0.699999988079071D, this.locZ);
|
|
|
|
- this.world.addEntity(entity);
|
|
|
|
+ return this.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
+ return true; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract boolean isSpectator();
|
2018-08-26 04:00:00 +02:00
|
|
|
@@ -1859,7 +2029,7 @@
|
2017-05-14 04:00:00 +02:00
|
|
|
return entitymonster.c(this.a);
|
|
|
|
}
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
- public boolean test(@Nullable Object object) {
|
|
|
|
+ public boolean test(@Nullable EntityMonster object) { // CraftBukkit - decompile error
|
2017-05-14 04:00:00 +02:00
|
|
|
return this.a((EntityMonster) object);
|
|
|
|
}
|
|
|
|
|