From 7d31adb5f7e871581044fc8547eb723f4fad6a5d Mon Sep 17 00:00:00 2001 From: Parker Hawke Date: Fri, 28 Aug 2020 12:35:14 +1000 Subject: [PATCH] #734: Add EnderSignal ItemStack API --- nms-patches/EntityEnderSignal.patch | 6 ++++-- .../bukkit/craftbukkit/entity/CraftEnderSignal.java | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/nms-patches/EntityEnderSignal.patch b/nms-patches/EntityEnderSignal.patch index 7b86789053..42abc7028c 100644 --- a/nms-patches/EntityEnderSignal.patch +++ b/nms-patches/EntityEnderSignal.patch @@ -1,10 +1,12 @@ --- a/net/minecraft/server/EntityEnderSignal.java +++ b/net/minecraft/server/EntityEnderSignal.java -@@ -21,7 +21,7 @@ +@@ -20,8 +20,8 @@ + } public void b(ItemStack itemstack) { - if (itemstack.getItem() != Items.ENDER_EYE || itemstack.hasTag()) { +- if (itemstack.getItem() != Items.ENDER_EYE || itemstack.hasTag()) { - this.getDataWatcher().set(EntityEnderSignal.b, SystemUtils.a((Object) itemstack.cloneItemStack(), (itemstack1) -> { ++ if (true || itemstack.getItem() != Items.ENDER_EYE || itemstack.hasTag()) { // CraftBukkit - always allow item changing + this.getDataWatcher().set(EntityEnderSignal.b, SystemUtils.a(itemstack.cloneItemStack(), (itemstack1) -> { // CraftBukkit - decompile error itemstack1.setCount(1); })); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java index d771fdc6ed..dadc7635f0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java @@ -3,10 +3,13 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; import net.minecraft.server.BlockPosition; import net.minecraft.server.EntityEnderSignal; +import net.minecraft.server.Items; import org.bukkit.Location; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.EnderSignal; import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; public class CraftEnderSignal extends CraftEntity implements EnderSignal { public CraftEnderSignal(CraftServer server, EntityEnderSignal entity) { @@ -49,6 +52,16 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal { getHandle().shouldDropItem = shouldDropItem; } + @Override + public ItemStack getItem() { + return CraftItemStack.asBukkitCopy(getHandle().g()); // PAIL rename getItemStack + } + + @Override + public void setItem(ItemStack item) { + getHandle().b(item != null ? CraftItemStack.asNMSCopy(item) : Items.ENDER_EYE.r()); // PAIL rename setItemStack, createItemStack + } + @Override public int getDespawnTimer() { return getHandle().despawnTimer;