2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityHuman.java
|
|
|
|
+++ b/net/minecraft/server/EntityHuman.java
|
2016-03-12 10:57:32 +01:00
|
|
|
@@ -9,6 +9,19 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
|
|
+import org.bukkit.craftbukkit.entity.CraftItem;
|
2016-03-12 10:57:32 +01:00
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.entity.Player;
|
|
|
|
+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);
|
2016-03-12 10:57:32 +01:00
|
|
|
@@ -19,7 +32,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
private InventoryEnderChest enderChest = new InventoryEnderChest();
|
|
|
|
public Container defaultContainer;
|
|
|
|
public Container activeContainer;
|
|
|
|
- protected FoodMetaData foodData = new FoodMetaData();
|
|
|
|
+ protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor
|
2016-02-29 22:32:46 +01:00
|
|
|
protected int bv;
|
|
|
|
public float bw;
|
|
|
|
public float bx;
|
2016-03-12 10:57:32 +01:00
|
|
|
@@ -52,6 +65,17 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
private final ItemCooldown bU = this.l();
|
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
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
protected ItemCooldown l() {
|
|
|
|
return new ItemCooldown();
|
|
|
|
}
|
2016-03-12 10:57:32 +01:00
|
|
|
@@ -301,7 +325,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) {
|
2016-03-12 10:57:32 +01:00
|
|
|
@@ -325,7 +350,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
this.l((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;
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -416,29 +441,35 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
public void b(Entity entity, int i) {
|
2016-02-29 22:32:46 +01:00
|
|
|
if (entity != this) {
|
|
|
|
this.addScore(i);
|
|
|
|
- Collection collection = this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.f);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit - Get our scores instead
|
2016-03-02 11:29:57 +01:00
|
|
|
+ Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.f, this.getName(), new java.util.ArrayList<ScoreboardScore>());
|
2016-02-29 22:32:46 +01:00
|
|
|
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
this.b(StatisticList.D);
|
|
|
|
- collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e));
|
|
|
|
+ // CraftBukkit - Get our scores instead
|
|
|
|
+ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, this.getName(), collection);
|
|
|
|
+ // collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e));
|
|
|
|
+ // CraftBukkit end
|
|
|
|
} else {
|
|
|
|
this.b(StatisticList.B);
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-03-27 01:11:15 +01:00
|
|
|
collection.addAll(this.d(entity));
|
2016-03-02 11:29:57 +01:00
|
|
|
- Iterator iterator = collection.iterator();
|
|
|
|
+ Iterator<ScoreboardScore> iterator = collection.iterator();
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
while (iterator.hasNext()) {
|
2016-03-02 11:29:57 +01:00
|
|
|
- ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next();
|
|
|
|
- ScoreboardScore scoreboardscore = this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ // ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next();
|
|
|
|
+ // ScoreboardScore scoreboardscore = this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective);
|
|
|
|
|
|
|
|
- scoreboardscore.incrementScore();
|
|
|
|
+ iterator.next().incrementScore();
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
}
|
|
|
|
|
2016-03-27 01:11:15 +01:00
|
|
|
- private Collection<ScoreboardObjective> d(Entity entity) {
|
|
|
|
+ private Collection<ScoreboardScore> d(Entity entity) { // CraftBukkit
|
2016-02-29 22:32:46 +01:00
|
|
|
String s = entity instanceof EntityHuman ? entity.getName() : entity.getUniqueID().toString();
|
2015-02-26 23:41:06 +01:00
|
|
|
ScoreboardTeam scoreboardteam = this.getScoreboard().getPlayerTeam(this.getName());
|
2016-03-27 01:11:15 +01:00
|
|
|
|
|
|
|
@@ -463,7 +494,10 @@
|
|
|
|
int j = scoreboardteam1.m().b();
|
|
|
|
|
|
|
|
if (j >= 0 && j < IScoreboardCriteria.m.length) {
|
|
|
|
- return this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.m[j]);
|
|
|
|
+ // CraftBukkit - Get our scores instead
|
|
|
|
+ return this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.m[j], this.getName(), new java.util.ArrayList<ScoreboardScore>());
|
|
|
|
+ // return this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.m[j]);
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -471,6 +505,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public EntityItem a(boolean flag) {
|
|
|
|
+ // Called only when dropped by Q or CTRL-Q
|
|
|
|
return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && this.inventory.getItemInHand() != null ? this.inventory.getItemInHand().count : 1), false, true);
|
|
|
|
}
|
|
|
|
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -513,6 +548,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();
|
|
|
|
+ CraftItem drop = new CraftItem(this.world.getServer(), entityitem);
|
|
|
|
+
|
|
|
|
+ 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());
|
|
|
|
+ } else if (flag1 && cur.isSimilar(drop.getItemStack()) && drop.getItemStack().getAmount() == 1) {
|
|
|
|
+ // 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) {
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -612,6 +671,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)) {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.e = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
|
|
|
|
this.f = nbttagcompound.getBoolean("SpawnForced");
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -649,6 +715,12 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
this.foodData.b(nbttagcompound);
|
|
|
|
this.abilities.a(nbttagcompound);
|
|
|
|
nbttagcompound.set("EnderItems", this.enderChest.h());
|
|
|
|
+ ItemStack itemstack = this.inventory.getItemInHand();
|
|
|
|
+
|
|
|
|
+ if (itemstack != null && itemstack.getItem() != null) {
|
|
|
|
+ nbttagcompound.set("SelectedItem", itemstack.save(new NBTTagCompound()));
|
|
|
|
+ }
|
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
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
public boolean damageEntity(DamageSource damagesource, float f) {
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -667,7 +739,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
if (damagesource.r()) {
|
|
|
|
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) {
|
|
|
|
- f = 0.0F;
|
|
|
|
+ return false; // CraftBukkit - f = 0.0f -> return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.world.getDifficulty() == EnumDifficulty.EASY) {
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -679,7 +751,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (f == 0.0F) {
|
|
|
|
+ if (false && f == 0.0F) { // CraftBukkit - Don't filter out 0 damage
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
Entity entity = damagesource.getEntity();
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -695,10 +767,29 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(EntityHuman entityhuman) {
|
2016-02-29 22:32:46 +01:00
|
|
|
- ScoreboardTeamBase scoreboardteambase = this.aO();
|
|
|
|
- ScoreboardTeamBase scoreboardteambase1 = entityhuman.aO();
|
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) {
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -742,7 +833,12 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
return (float) i / (float) this.inventory.armor.length;
|
|
|
|
}
|
|
|
|
|
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);
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -762,6 +858,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ return false; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
public void openSign(TileEntitySign tileentitysign) {}
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -884,8 +981,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
|
|
|
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -925,11 +1029,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) {
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -991,7 +1112,8 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
if (itemstack3 != null && object instanceof EntityLiving) {
|
|
|
|
itemstack3.a((EntityLiving) object, this);
|
|
|
|
- if (itemstack3.count <= 0) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit - bypass infinite items; <= 0 -> == 0
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (itemstack3.count == 0) {
|
|
|
|
this.a(EnumHand.MAIN_HAND, (ItemStack) null);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
}
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -1001,7 +1123,14 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
|
|
|
|
this.a(StatisticList.y, 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-02-29 22:32:46 +01:00
|
|
|
if (this.world instanceof WorldServer && f5 > 2.0F) {
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -1090,6 +1219,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
|
|
|
+
|
|
|
|
this.setSize(0.2F, 0.2F);
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.world.isLoaded(blockposition)) {
|
2016-02-29 22:32:46 +01:00
|
|
|
EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING);
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -1172,6 +1315,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);
|
2016-03-27 01:11:15 +01:00
|
|
|
@@ -1222,9 +1382,11 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
if (blockposition != null) {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.e = blockposition;
|
|
|
|
this.f = flag;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.spawnWorld = this.world.worldData.getName(); // CraftBukkit
|
|
|
|
} else {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.e = null;
|
|
|
|
this.f = false;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.spawnWorld = ""; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|