restore compatibility with inventory tweaks

This commit is contained in:
progwml6 2014-04-04 20:49:09 -04:00
parent 0d98200512
commit 103a22860b
2 changed files with 35 additions and 0 deletions

View File

@ -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 {
}
}

View File

@ -16,7 +16,9 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import invtweaks.api.container.ChestContainer;
@ChestContainer(isLargeChest = true)
public class ContainerIronChest extends Container { public class ContainerIronChest extends Container {
private IronChestType type; private IronChestType type;
private EntityPlayer player; private EntityPlayer player;
@ -115,4 +117,9 @@ public class ContainerIronChest extends Container {
{ {
return player; return player;
} }
@ChestContainer.RowSizeCallback
public int getNumColumns() {
return type.getRowLength();
}
} }