ForgePatch/patches/minecraft/net/minecraft/inventory/container/Slot.java.patch

49 lines
1.4 KiB
Diff

--- a/net/minecraft/inventory/container/Slot.java
+++ b/net/minecraft/inventory/container/Slot.java
@@ -77,7 +77,7 @@
@Nullable
@OnlyIn(Dist.CLIENT)
public Pair<ResourceLocation, ResourceLocation> func_225517_c_() {
- return null;
+ return backgroundPair;
}
public ItemStack func_75209_a(int p_75209_1_) {
@@ -92,4 +92,36 @@
public boolean func_111238_b() {
return true;
}
+
+ /**
+ * Retrieves the index in the inventory for this slot, this value should typically not
+ * be used, but can be useful for some occasions.
+ *
+ * @return Index in associated inventory for this slot.
+ */
+ public int getSlotIndex() {
+ return field_75225_a;
+ }
+
+ /**
+ * Checks if the other slot is in the same inventory, by comparing the inventory reference.
+ * @param other
+ * @return true if the other slot is in the same inventory
+ */
+ public boolean isSameInventory(Slot other) {
+ return this.field_75224_c == other.field_75224_c;
+ }
+
+ private Pair<ResourceLocation, ResourceLocation> backgroundPair;
+ /**
+ * Sets the background atlas and sprite location.
+ *
+ * @param atlas The atlas name
+ * @param sprite The sprite located on that atlas.
+ * @return this, to allow chaining.
+ */
+ public Slot setBackground(ResourceLocation atlas, ResourceLocation sprite) {
+ this.backgroundPair = Pair.of(atlas, sprite);
+ return this;
+ }
}