mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-10-26 14:23:57 +00:00
Add support for InventoryTweaks
This commit is contained in:
1 parent
a49eb1c5f9
commit
27daa8e1ac
18 files changed
+596
-15
No files matched your search
@@ -154,6 +154,9 @@ jar {
|
||||
into ('cofh/api') {
|
||||
from project.apiRedstoneFlux + "/LICENSE - LGPLv3.txt"
|
||||
}
|
||||
into ('invtweaks/api') {
|
||||
from "./src/main/java/invtweaks/LICENSE.txt"
|
||||
}
|
||||
|
||||
configurations.shade.each{ dep ->
|
||||
from(project.zipTree(dep)){
|
||||
|
||||
@@ -10,18 +10,28 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.gui.slots.SlotFilteredInventory;
|
||||
import forestry.core.gui.slots.SlotForestry;
|
||||
import forestry.core.gui.slots.SlotLocked;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
|
||||
import invtweaks.api.container.ContainerSection;
|
||||
import invtweaks.api.container.ContainerSectionCallback;
|
||||
|
||||
@invtweaks.api.container.ChestContainer
|
||||
public abstract class ContainerForestry extends Container {
|
||||
protected final void addPlayerInventory(InventoryPlayer playerInventory, int xInv, int yInv) {
|
||||
// Player inventory
|
||||
@@ -89,4 +99,34 @@ public abstract class ContainerForestry extends Container {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ContainerSectionCallback
|
||||
public Map<ContainerSection, List<Slot>> getContainerSections() {
|
||||
ArrayListMultimap<ContainerSection, Slot> map = ArrayListMultimap.create();
|
||||
|
||||
for (Object object : inventorySlots) {
|
||||
if (!(object instanceof Slot)) {
|
||||
continue;
|
||||
}
|
||||
Slot slot = (Slot) object;
|
||||
|
||||
if (slot.inventory instanceof InventoryPlayer) {
|
||||
map.put(ContainerSection.INVENTORY, slot);
|
||||
if (slot.slotNumber < 9) {
|
||||
map.put(ContainerSection.INVENTORY_HOTBAR, slot);
|
||||
} else if (slot.slotNumber < 36) {
|
||||
map.put(ContainerSection.INVENTORY_NOT_HOTBAR, slot);
|
||||
} else {
|
||||
map.put(ContainerSection.ARMOR, slot);
|
||||
}
|
||||
} else {
|
||||
if (!(slot instanceof SlotForestry) || slot instanceof SlotFilteredInventory) {
|
||||
map.put(ContainerSection.CHEST, slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//noinspection unchecked
|
||||
return (Map<ContainerSection, List<Slot>>) (Object) map.asMap();
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,11 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotFilteredInventory;
|
||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||
import forestry.core.tiles.IFilterSlotDelegate;
|
||||
import forestry.core.tiles.TileNaturalistChest;
|
||||
|
||||
public class ContainerNaturalistInventory extends ContainerTile<TileNaturalistChest> implements IGuiSelectable {
|
||||
@@ -24,10 +26,20 @@ public class ContainerNaturalistInventory extends ContainerTile<TileNaturalistCh
|
||||
public ContainerNaturalistInventory(InventoryPlayer player, TileNaturalistChest tile, int page) {
|
||||
super(tile, player, 18, 120);
|
||||
|
||||
// Inventory
|
||||
for (int x = 0; x < 5; x++) {
|
||||
for (int y = 0; y < 5; y++) {
|
||||
addSlotToContainer(new SlotFiltered(tile, y + page * 25 + x * 5, 100 + y * 18, 21 + x * 18));
|
||||
addInventory(this, tile, page);
|
||||
}
|
||||
|
||||
public static <T extends IInventory & IFilterSlotDelegate> void addInventory(ContainerForestry container, T inventory, int selectedPage) {
|
||||
for (int page = 0; page < 5; page++) {
|
||||
for (int x = 0; x < 5; x++) {
|
||||
for (int y = 0; y < 5; y++) {
|
||||
int slot = y + page * 25 + x * 5;
|
||||
if (page == selectedPage) {
|
||||
container.addSlotToContainer(new SlotFilteredInventory(inventory, slot, 100 + y * 18, 21 + x * 18));
|
||||
} else {
|
||||
container.addSlotToContainer(new SlotFilteredInventory(inventory, slot, -10000, -10000));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +55,7 @@ public class ContainerNaturalistInventory extends ContainerTile<TileNaturalistCh
|
||||
tile.increaseNumPlayersUsing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
tile.decreaseNumPlayersUsing();
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui.slots;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
import forestry.core.tiles.IFilterSlotDelegate;
|
||||
|
||||
/**
|
||||
* Useful for InventoryTweaks. Works like SlotFiltered but allows InventoryTweaks to sort it.
|
||||
*/
|
||||
public class SlotFilteredInventory extends SlotFiltered {
|
||||
public <T extends IInventory & IFilterSlotDelegate> SlotFilteredInventory(T inventory, int slotIndex, int xPos, int yPos) {
|
||||
super(inventory, slotIndex, xPos, yPos);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotFilteredInventory;
|
||||
import forestry.storage.inventory.ItemInventoryBackpack;
|
||||
|
||||
public class ContainerBackpack extends ContainerItemInventory<ItemInventoryBackpack> {
|
||||
@@ -47,7 +47,7 @@ public class ContainerBackpack extends ContainerItemInventory<ItemInventoryBackp
|
||||
for (int j = 0; j < size.rows; j++) {
|
||||
for (int k = 0; k < size.columns; k++) {
|
||||
int slot = k + j * size.columns;
|
||||
addSlotToContainer(new SlotFiltered(inventory, slot, size.startX + k * 18, size.startY + j * 18));
|
||||
addSlotToContainer(new SlotFilteredInventory(inventory, slot, size.startX + k * 18, size.startY + j * 18));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,22 +14,17 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.gui.ContainerNaturalistInventory;
|
||||
import forestry.core.gui.IGuiSelectable;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||
import forestry.storage.inventory.ItemInventoryBackpackPaged;
|
||||
|
||||
public class ContainerNaturalistBackpack extends ContainerItemInventory<ItemInventoryBackpackPaged> implements IGuiSelectable {
|
||||
|
||||
public ContainerNaturalistBackpack(EntityPlayer player, ItemInventoryBackpackPaged inventory, int page) {
|
||||
public ContainerNaturalistBackpack(EntityPlayer player, ItemInventoryBackpackPaged inventory, int selectedPage) {
|
||||
super(inventory, player.inventory, 18, 120);
|
||||
|
||||
// Inventory
|
||||
for (int x = 0; x < 5; x++) {
|
||||
for (int y = 0; y < 5; y++) {
|
||||
addSlotToContainer(new SlotFiltered(inventory, y + page * 25 + x * 5, 100 + y * 18, 21 + x * 18));
|
||||
}
|
||||
}
|
||||
ContainerNaturalistInventory.addInventory(this, inventory, selectedPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
## Inventory Tweaks Mod license (MIT)
|
||||
|
||||
Copyright (c) 2011-2013 Marwane Kalam-Alami
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Andrew Crocker
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package invtweaks.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface IItemTree {
|
||||
void registerOre(String category, String name, String oreName, int order);
|
||||
|
||||
boolean matches(List<IItemTreeItem> items, String keyword);
|
||||
|
||||
boolean isKeywordValid(String keyword);
|
||||
|
||||
Collection<IItemTreeCategory> getAllCategories();
|
||||
|
||||
IItemTreeCategory getRootCategory();
|
||||
|
||||
void setRootCategory(IItemTreeCategory category);
|
||||
|
||||
IItemTreeCategory getCategory(String keyword);
|
||||
|
||||
boolean isItemUnknown(String id, int damage);
|
||||
|
||||
List<IItemTreeItem> getItems(String id, int damage);
|
||||
|
||||
List<IItemTreeItem> getItems(String name);
|
||||
|
||||
IItemTreeItem getRandomItem(Random r);
|
||||
|
||||
boolean containsItem(String name);
|
||||
|
||||
boolean containsCategory(String name);
|
||||
|
||||
IItemTreeCategory addCategory(String parentCategory, String newCategory) throws NullPointerException;
|
||||
|
||||
void addCategory(String parentCategory, IItemTreeCategory newCategory) throws NullPointerException;
|
||||
|
||||
IItemTreeItem addItem(String parentCategory, String name, String id, int damage, int order)
|
||||
throws NullPointerException;
|
||||
|
||||
void addItem(String parentCategory, IItemTreeItem newItem) throws NullPointerException;
|
||||
|
||||
int getKeywordDepth(String keyword);
|
||||
|
||||
int getKeywordOrder(String keyword);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Andrew Crocker
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package invtweaks.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface IItemTreeCategory {
|
||||
boolean contains(IItemTreeItem item);
|
||||
|
||||
void addCategory(IItemTreeCategory category);
|
||||
|
||||
void addItem(IItemTreeItem item);
|
||||
|
||||
Collection<IItemTreeCategory> getSubCategories();
|
||||
|
||||
Collection<List<IItemTreeItem>> getItems();
|
||||
|
||||
String getName();
|
||||
|
||||
int getCategoryOrder();
|
||||
|
||||
int findCategoryOrder(String keyword);
|
||||
|
||||
int findKeywordDepth(String keyword);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Andrew Crocker
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package invtweaks.api;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface IItemTreeItem extends Comparable<IItemTreeItem> {
|
||||
String getName();
|
||||
|
||||
String getId();
|
||||
|
||||
int getDamage();
|
||||
|
||||
int getOrder();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Andrew Crocker
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package invtweaks.api;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface IItemTreeListener extends EventListener {
|
||||
void onTreeLoaded(IItemTree tree);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Andrew Crocker
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package invtweaks.api;
|
||||
|
||||
import invtweaks.api.container.ContainerSection;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Interface to access functions exposed by Inventory Tweaks
|
||||
* <p/>
|
||||
* The main @Mod instance of the mod implements this interface, so a refernce to it can
|
||||
* be obtained via @Instance("inventorytweaks") or methods in net.minecraftforge.fml.common.Loader
|
||||
* <p/>
|
||||
* All of these functions currently have no effect if called on a dedicated server.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public interface InvTweaksAPI {
|
||||
/**
|
||||
* Add a listener for ItemTree load events
|
||||
*/
|
||||
void addOnLoadListener(IItemTreeListener listener);
|
||||
|
||||
/**
|
||||
* Remove a listener for ItemTree load events
|
||||
*
|
||||
* @return true if the listener was previously added
|
||||
*/
|
||||
boolean removeOnLoadListener(IItemTreeListener listener);
|
||||
|
||||
/**
|
||||
* Toggle sorting shortcut state.
|
||||
*/
|
||||
void setSortKeyEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Toggle sorting shortcut supression.
|
||||
* Unlike setSortKeyEnabled, this flag is automatically cleared when GUIs are closed.
|
||||
*/
|
||||
void setTextboxMode(boolean enabled);
|
||||
|
||||
/**
|
||||
* Compare two items using the default (non-rule based) algorithm,
|
||||
* sutable for an implementation of Comparator<ItemStack>.
|
||||
*
|
||||
* @param i
|
||||
* @param j
|
||||
* @return A value with a sign representing the relative order of the item stacks
|
||||
*/
|
||||
int compareItems(ItemStack i, ItemStack j);
|
||||
|
||||
/**
|
||||
* Initiate a sort as if the player had clicked on a sorting button or pressed the sort key.
|
||||
*/
|
||||
void sort(ContainerSection section, SortingMethod method);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Andrew Crocker
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package invtweaks.api;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public enum SortingMethod {
|
||||
/**
|
||||
* Standard 'r' sorting for generic inventories
|
||||
*/
|
||||
DEFAULT,
|
||||
/**
|
||||
* Sort method creating vertical columns of items.
|
||||
* Used for chests only, requires container to have a valid row size for correct results.
|
||||
*/
|
||||
VERTICAL,
|
||||
/**
|
||||
* Sort method creating horizontal rows of items.
|
||||
* Used for chests only, requires container to have a valid row size for correct results.
|
||||
*/
|
||||
HORIZONTAL,
|
||||
/**
|
||||
* Sort method for player inventory.
|
||||
* Applies to extra player-specified sorting rules for the main inventory.
|
||||
* Will always operate on main inventory.
|
||||
*/
|
||||
INVENTORY,
|
||||
/**
|
||||
* Attempts to even the number of items in each stack of the same type of item, without moving full stacks.
|
||||
* Used in crafting grid sorting.
|
||||
*/
|
||||
EVEN_STACKS,
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
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 {
|
||||
// Set to true if the Inventory Tweaks sorting buttons should be shown for this container.
|
||||
boolean showButtons() default true;
|
||||
|
||||
// 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)
|
||||
@interface RowSizeCallback {
|
||||
}
|
||||
|
||||
// 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)
|
||||
@interface IsLargeCallback {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Andrew Crocker
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package invtweaks.api.container;
|
||||
|
||||
/**
|
||||
* Names for specific parts of containers. For unknown container types (such as mod containers), only INVENTORY and
|
||||
* CHEST sections are available.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public enum ContainerSection {
|
||||
/**
|
||||
* The player's inventory
|
||||
*/
|
||||
INVENTORY,
|
||||
/**
|
||||
* The player's inventory (only the hotbar)
|
||||
*/
|
||||
INVENTORY_HOTBAR,
|
||||
/**
|
||||
* The player's inventory (all except the hotbar)
|
||||
*/
|
||||
INVENTORY_NOT_HOTBAR,
|
||||
/**
|
||||
* The chest or dispenser contents. Also used for unknown container contents.
|
||||
*/
|
||||
CHEST,
|
||||
/**
|
||||
* The crafting input
|
||||
*/
|
||||
CRAFTING_IN,
|
||||
/**
|
||||
* The crafting input, for containters that store it internally
|
||||
*/
|
||||
CRAFTING_IN_PERSISTENT,
|
||||
/**
|
||||
* The crafting output
|
||||
*/
|
||||
CRAFTING_OUT,
|
||||
/**
|
||||
* The armor slots
|
||||
*/
|
||||
ARMOR,
|
||||
/**
|
||||
* The furnace input
|
||||
*/
|
||||
FURNACE_IN,
|
||||
/**
|
||||
* The furnace output
|
||||
*/
|
||||
FURNACE_OUT,
|
||||
/**
|
||||
* The furnace fuel
|
||||
*/
|
||||
FURNACE_FUEL,
|
||||
/**
|
||||
* The enchantment table slot
|
||||
*/
|
||||
ENCHANTMENT,
|
||||
/**
|
||||
* The three bottles slots in brewing tables
|
||||
* NOTE: Do not use without also using BREWING_INGREDIENT.
|
||||
*/
|
||||
BREWING_BOTTLES,
|
||||
/**
|
||||
* The top slot in brewing tables
|
||||
* NOTE: Do not use without also using BREWING_BOTTLES.
|
||||
*/
|
||||
BREWING_INGREDIENT
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
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 a method to call which returns the set of ContainerSections for this container.
|
||||
* <p/>
|
||||
* Signature of the method should be Map<ContainerSection, List<Slot>> func()
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface ContainerSectionCallback {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package invtweaks.api.container;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Use this annotation to override inherited annotation properties and mark a Container as unsortable.
|
||||
* This effect is inherited as well.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface IgnoreContainer {
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
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 need special treatment, such as crafting inputs or alternate player inventory positions,
|
||||
* but do not have a chest-like component.
|
||||
* <p/>
|
||||
* Does not enable the Inventory Tweaks sorting buttons for this container.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface InventoryContainer {
|
||||
// Set to true if the Inventory Tweaks options button should be shown for this container.
|
||||
// (For instance, if you are replacing a vanilla container such as the player's inventory)
|
||||
boolean showOptions() default true;
|
||||
}
|
||||
Reference in new issue
Block a user