PaperMC/nms-patches/ItemDye.patch

31 lines
1.3 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ItemDye.java
+++ b/net/minecraft/server/ItemDye.java
2018-07-15 02:00:00 +02:00
@@ -3,6 +3,8 @@
import com.google.common.collect.Maps;
import java.util.Map;
+import org.bukkit.event.entity.SheepDyeWoolEvent; // CraftBukkit
+
public class ItemDye extends Item {
2018-07-15 02:00:00 +02:00
private static final Map<EnumColor, ItemDye> a = Maps.newEnumMap(EnumColor.class);
2020-06-25 02:00:00 +02:00
@@ -21,7 +23,17 @@
2019-04-23 04:00:00 +02:00
if (entitysheep.isAlive() && !entitysheep.isSheared() && entitysheep.getColor() != this.b) {
2020-06-25 02:00:00 +02:00
if (!entityhuman.world.isClientSide) {
- entitysheep.setColor(this.b);
+ // CraftBukkit start
+ byte bColor = (byte) this.b.getColorIndex();
+ SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor));
+ entitysheep.world.getServer().getPluginManager().callEvent(event);
+
2020-06-25 02:00:00 +02:00
+ if (event.isCancelled()) {
+ return EnumInteractionResult.PASS;
+ }
+
2020-06-25 02:00:00 +02:00
+ entitysheep.setColor(EnumColor.fromColorIndex((byte) event.getColor().getWoolData()));
+ // CraftBukkit end
itemstack.subtract(1);
}
2018-07-15 02:00:00 +02:00