mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 06:24:06 +01:00
398f6983bd
Make "moved too quickly" limit configurable SpigotMC/Spigot@99a0a640e8 Undeprecate Player#updateInventory()V SpigotMC/Spigot@5c32e1cb48 Fetch complete profile for skull items, similarly to TileEntitySkull. SpigotMC/Spigot@33d758773e Move getDouble into the Spigot Configuration patch SpigotMC/Spigot@b5dd202af1 Add missing particle to particle API SpigotMC/Spigot@273c64bbad Log debug levels to the log file. SpigotMC/Spigot@348eae75f4 Fix PlayerItemDamageEvent (we already had this #badupstreamrelations) SpigotMC/Spigot@e207ea23cd Move hopper patch to top for PR180 SpigotMC/Spigot@abb775108d Don't be so spammy on Java 6 SpigotMC/Spigot@5abb82b1ca Apply NBTReadLimiter to more things SpigotMC/Spigot@408944e9f5
55 lines
2.3 KiB
Diff
55 lines
2.3 KiB
Diff
From 816009797a85563fe27578d16d24ede5d33f0a6d Mon Sep 17 00:00:00 2001
|
|
From: md_5 <md_5@live.com.au>
|
|
Date: Mon, 4 Mar 2013 18:45:52 +1100
|
|
Subject: [PATCH] PlayerItemDamageEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
|
index c9d74d3..a2ab06a 100644
|
|
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
|
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
|
@@ -279,7 +279,13 @@ public final class ItemStack {
|
|
return this.item.getMaxDurability();
|
|
}
|
|
|
|
+ // Spigot start
|
|
public boolean isDamaged(int i, Random random) {
|
|
+ return isDamaged(i, random, null);
|
|
+ }
|
|
+
|
|
+ public boolean isDamaged(int i, Random random, EntityLiving entityliving) {
|
|
+ // Spigot end
|
|
if (!this.g()) {
|
|
return false;
|
|
} else {
|
|
@@ -294,7 +300,16 @@ public final class ItemStack {
|
|
}
|
|
|
|
i -= k;
|
|
- if (i <= 0) {
|
|
+ // Spigot start
|
|
+ if (entityliving instanceof EntityPlayer) {
|
|
+ org.bukkit.craftbukkit.inventory.CraftItemStack item = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this);
|
|
+ org.bukkit.event.player.PlayerItemDamageEvent event = new org.bukkit.event.player.PlayerItemDamageEvent((org.bukkit.entity.Player) entityliving.getBukkitEntity(), item, i);
|
|
+ org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event);
|
|
+ if (event.isCancelled()) return false;
|
|
+ i = event.getDamage();
|
|
+ }
|
|
+ // Spigot end
|
|
+ if (i <= 0 ) {
|
|
return false;
|
|
}
|
|
}
|
|
@@ -307,7 +322,7 @@ public final class ItemStack {
|
|
public void damage(int i, EntityLiving entityliving) {
|
|
if (!(entityliving instanceof EntityHuman) || !((EntityHuman) entityliving).abilities.canInstantlyBuild) {
|
|
if (this.g()) {
|
|
- if (this.isDamaged(i, entityliving.aI())) {
|
|
+ if (this.isDamaged(i, entityliving.aI(), entityliving)) { // Spigot
|
|
entityliving.a(this);
|
|
--this.count;
|
|
if (entityliving instanceof EntityHuman) {
|
|
--
|
|
1.9.1
|
|
|