mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 19:15:32 +01:00
Fix crash if entities other than players (somehow?) consume their item.
This commit is contained in:
parent
730bb6ac83
commit
270755dc06
@ -107,14 +107,14 @@
|
|||||||
|
|
||||||
- if (!this.world.isClientSide && (this.alwaysGivesExp() || this.lastDamageByPlayerTime > 0 && this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot"))) {
|
- if (!this.world.isClientSide && (this.alwaysGivesExp() || this.lastDamageByPlayerTime > 0 && this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot"))) {
|
||||||
- i = this.getExpValue(this.killer);
|
- i = this.getExpValue(this.killer);
|
||||||
-
|
|
||||||
- while (i > 0) {
|
|
||||||
- int j = EntityExperienceOrb.getOrbValue(i);
|
|
||||||
+ // CraftBukkit start - Update getExpReward() above if the removed if() changes!
|
+ // CraftBukkit start - Update getExpReward() above if the removed if() changes!
|
||||||
+ i = this.expToDrop;
|
+ i = this.expToDrop;
|
||||||
+ while (i > 0) {
|
+ while (i > 0) {
|
||||||
+ int j = EntityExperienceOrb.getOrbValue(i);
|
+ int j = EntityExperienceOrb.getOrbValue(i);
|
||||||
|
|
||||||
|
- while (i > 0) {
|
||||||
|
- int j = EntityExperienceOrb.getOrbValue(i);
|
||||||
|
-
|
||||||
- i -= j;
|
- i -= j;
|
||||||
- this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j));
|
- this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j));
|
||||||
- }
|
- }
|
||||||
@ -575,32 +575,36 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void ap() {
|
protected void ap() {
|
||||||
@@ -2036,7 +2309,23 @@
|
@@ -2036,7 +2309,27 @@
|
||||||
protected void v() {
|
protected void v() {
|
||||||
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
|
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
|
||||||
this.a(this.activeItem, 16);
|
this.a(this.activeItem, 16);
|
||||||
- this.a(this.cz(), this.activeItem.a(this.world, this));
|
- this.a(this.cz(), this.activeItem.a(this.world, this));
|
||||||
+ // CraftBukkit start - fire PlayerItemConsumeEvent
|
+ // CraftBukkit start - fire PlayerItemConsumeEvent
|
||||||
|
+ ItemStack itemstack;
|
||||||
|
+ if (this instanceof EntityPlayer) {
|
||||||
+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.activeItem);
|
+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.activeItem);
|
||||||
+ PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
|
+ PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
|
||||||
+ world.getServer().getPluginManager().callEvent(event);
|
+ world.getServer().getPluginManager().callEvent(event);
|
||||||
+
|
+
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ // Update client
|
+ // Update client
|
||||||
+ if (this instanceof EntityPlayer) {
|
|
||||||
+ ((EntityPlayer) this).getBukkitEntity().updateInventory();
|
+ ((EntityPlayer) this).getBukkitEntity().updateInventory();
|
||||||
+ ((EntityPlayer) this).getBukkitEntity().updateScaledHealth();
|
+ ((EntityPlayer) this).getBukkitEntity().updateScaledHealth();
|
||||||
+ }
|
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ ItemStack itemstack = (craftItem.equals(event.getItem())) ? this.activeItem.a(this.world, this) : CraftItemStack.asNMSCopy(event.getItem()).a(world, this);
|
+ itemstack = (craftItem.equals(event.getItem())) ? this.activeItem.a(this.world, this) : CraftItemStack.asNMSCopy(event.getItem()).a(world, this);
|
||||||
|
+ } else {
|
||||||
|
+ itemstack = this.activeItem.a(this.world, this);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ this.a(this.cz(), itemstack);
|
+ this.a(this.cz(), itemstack);
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
this.cF();
|
this.cF();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2115,10 +2404,18 @@
|
@@ -2115,10 +2408,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag1) {
|
if (flag1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user