3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 11:00:06 +01:00
Paper/Spigot-API-Patches/0127-Expand-ArmorStand-API.patch
Spottedleaf 5c7081fecc Update upstream & fix some chunk related issues (#2177)
* Updated Upstream (Bukkit/CraftBukkit)

Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
45690fe9 SPIGOT-5047: Correct slot types for 1.14 inventories

CraftBukkit Changes:
4090d01f SPIGOT-5047: Correct slot types for 1.14 inventories
e8c08362 SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks.
d445af3b SPIGOT-5067: Add item meta for 1.14 spawn eggs

* Bring Chunk load checks in-line with spigot

As of the last upstream merge spigot now checks ticket level status
when returning loaded chunks for a world from api. Now our checks
will respect that decision.

* Fix spawn ticket levels

Vanilla would keep the inner chunks of spawn available for ticking,
however my changes made all chunks non-ticking. Resolve by changing
ticket levels for spawn chunks inside the border to respect this
behavior.


* Make World#getChunkIfLoadedImmediately return only entity ticking chunks

Mojang appears to be using chunks with level > 33 (non-ticking chunks)
as cached chunks and not actually loaded chunks.

* Bring all loaded checks in line with spigot

Loaded chunks must be at least border  chunks, or level <= 33
2019-06-14 03:27:40 +01:00

123 Zeilen
4.2 KiB
Diff

From b178b138b10df28838e9e5d73dcb424ae4fbc38f Mon Sep 17 00:00:00 2001
From: willies952002 <admin@domnian.com>
Date: Thu, 26 Jul 2018 02:22:44 -0400
Subject: [PATCH] Expand ArmorStand API
Add the following:
- Add proper methods for getting and setting items in both hands. Deprecates old methods
- Enable/Disable slot interactions
diff --git a/src/main/java/org/bukkit/entity/ArmorStand.java b/src/main/java/org/bukkit/entity/ArmorStand.java
index 492df420b..e7f71e65e 100644
--- a/src/main/java/org/bukkit/entity/ArmorStand.java
+++ b/src/main/java/org/bukkit/entity/ArmorStand.java
@@ -1,5 +1,6 @@
package org.bukkit.entity;
+import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.jetbrains.annotations.NotNull;
@@ -12,8 +13,13 @@ public interface ArmorStand extends LivingEntity {
* currently holding
*
* @return the held item
+ // Paper start - Deprecate in favor of setItemInMainHand
+ * @deprecated use {@link ArmorStand#getItem(EquipmentSlot)} instead
+ * @see ArmorStand#getItem(EquipmentSlot)
+ // Paper end
*/
@NotNull
+ @Deprecated // Paper
ItemStack getItemInHand();
/**
@@ -21,7 +27,12 @@ public interface ArmorStand extends LivingEntity {
* holding
*
* @param item the item to hold
+ // Paper start - Deprecate in favor of setItemInMainHand
+ * @deprecated use {@link ArmorStand#setItem(EquipmentSlot, ItemStack)} instead
+ * @see ArmorStand#setItem(EquipmentSlot, ItemStack)
+ // Paper end
*/
+ @Deprecated // Paper
void setItemInHand(@Nullable ItemStack item);
/**
@@ -304,5 +315,71 @@ public interface ArmorStand extends LivingEntity {
* @param tick {@code true} if this armour stand can tick, {@code false} otherwise
*/
void setCanTick(final boolean tick);
+
+ /**
+ * Returns the item the armor stand has
+ * equip in the given equipment slot
+ *
+ * @param slot the equipment slot to get
+ * @return the ItemStack in the equipment slot
+ */
+ @NotNull
+ ItemStack getItem(@NotNull final org.bukkit.inventory.EquipmentSlot slot);
+
+ /**
+ * Sets the item the armor stand has
+ * equip in the given equipment slot
+ *
+ * @param slot the equipment slot to set
+ * @param item the item to hold
+ */
+ void setItem(@NotNull final org.bukkit.inventory.EquipmentSlot slot, @Nullable final ItemStack item);
+
+ /**
+ * Get the list of disabled slots
+ *
+ * @return list of disabled slots
+ */
+ @NotNull
+ java.util.Set<org.bukkit.inventory.EquipmentSlot> getDisabledSlots();
+
+ /**
+ * Set the disabled slots
+ *
+ * This makes it so a player is unable to interact with the Armor Stand to place, remove, or replace an item in the given slot(s)
+ * Note: Once a slot is disabled, the only way to get an item back it to break the armor stand.
+ *
+ * @param slots var-arg array of slots to lock
+ */
+ void setDisabledSlots(@NotNull org.bukkit.inventory.EquipmentSlot... slots);
+
+ /**
+ * Disable specific slots, adding them
+ * to the currently disabled slots
+ *
+ * This makes it so a player is unable to interact with the Armor Stand to place, remove, or replace an item in the given slot(s)
+ * Note: Once a slot is disabled, the only way to get an item back it to break the armor stand.
+ *
+ * @param slots var-arg array of slots to lock
+ */
+ void addDisabledSlots(@NotNull final org.bukkit.inventory.EquipmentSlot... slots);
+
+ /**
+ * Remove the given slots from the disabled
+ * slots list, enabling them.
+ *
+ * This makes it so a player is able to interact with the Armor Stand to place, remove, or replace an item in the given slot(s)
+ *
+ * @param slots var-arg array of slots to unlock
+ */
+ void removeDisabledSlots(@NotNull final org.bukkit.inventory.EquipmentSlot... slots);
+
+ /**
+ * Check if a specific slot is disabled
+ *
+ * @param slot The slot to check
+ * @return {@code true} if the slot is disabled, else {@code false}.
+ */
+ boolean isSlotDisabled(@NotNull org.bukkit.inventory.EquipmentSlot slot);
// Paper end
}
--
2.21.0