From 103a22860b5e35306e60a9fb78e3be2b7043d2cd Mon Sep 17 00:00:00 2001 From: progwml6 Date: Fri, 4 Apr 2014 20:49:09 -0400 Subject: [PATCH] restore compatibility with inventory tweaks --- .../api/container/ChestContainer.java | 28 +++++++++++++++++++ .../mods/ironchest/ContainerIronChest.java | 7 +++++ 2 files changed, 35 insertions(+) create mode 100644 src/api/java/invtweaks/api/container/ChestContainer.java diff --git a/src/api/java/invtweaks/api/container/ChestContainer.java b/src/api/java/invtweaks/api/container/ChestContainer.java new file mode 100644 index 0000000..4722921 --- /dev/null +++ b/src/api/java/invtweaks/api/container/ChestContainer.java @@ -0,0 +1,28 @@ +package invtweaks.api.container; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * A marker for containers that have a chest-like persistant storage component. Enables the Inventroy Tweaks sorting + * buttons for this container. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface ChestContainer { + // Size of a chest row + int rowSize() default 9; + + // Uses 'large chest' mode for sorting buttons + // (Renders buttons vertically down the right side of the GUI) + boolean isLargeChest() default false; + + // Annotation for method to get size of a chest row if it is not a fixed size for this container class + // Signature int func() + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + public @interface RowSizeCallback { + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/ironchest/ContainerIronChest.java b/src/main/java/cpw/mods/ironchest/ContainerIronChest.java index e4900cb..92f111d 100644 --- a/src/main/java/cpw/mods/ironchest/ContainerIronChest.java +++ b/src/main/java/cpw/mods/ironchest/ContainerIronChest.java @@ -16,7 +16,9 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import invtweaks.api.container.ChestContainer; +@ChestContainer(isLargeChest = true) public class ContainerIronChest extends Container { private IronChestType type; private EntityPlayer player; @@ -115,4 +117,9 @@ public class ContainerIronChest extends Container { { return player; } + + @ChestContainer.RowSizeCallback + public int getNumColumns() { + return type.getRowLength(); + } }