Advertisement
Guest User

Untitled

a guest
Mar 13th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. public class ContainerArcaneStorage extends Container {
  2. public TileEntityArcaneStorage arcaneStorage;
  3.  
  4. /* Strings formatted as "Index: I is at: X: X, Y: Y", holds the location and index number of slots */
  5. public static String[] slotIndexLocations;
  6. public static String[] playerSlotIndexLocations = new String[28];
  7. /* End of Storage Strings */
  8.  
  9. /* Definition of Storage Types */
  10. public static final int ARCANE_STORAGE_COLUMNS = 24;
  11. public static final int ARCANE_STORAGE_ROWS = 16;
  12. public static final int ARCANE_STORAGE_SIZE = ARCANE_STORAGE_COLUMNS * ARCANE_STORAGE_ROWS;
  13. /* End of Storage Types */
  14.  
  15. public ContainerArcaneStorage(InventoryPlayer inventoryPlayer, TileEntityArcaneStorage tileEntityArcaneStorage) {
  16. arcaneStorage = tileEntityArcaneStorage;
  17. int arcaneStorageMeta = tileEntityArcaneStorage.blockMetadata;
  18.  
  19. int baseX = 0;
  20. int baseY = 0;
  21. int playerInvBaseX = 0;
  22. int playerInvBaseY = 50;
  23. int buffer = 20;
  24.  
  25. switch (arcaneStorageMeta) {
  26. case Metadata.ARCANE_CONTAINER_BASE:
  27. int[][] ARCANE_STORAGE_ARRAY = new int[ARCANE_STORAGE_ROWS][ARCANE_STORAGE_COLUMNS];
  28. slotIndexLocations = new String[ARCANE_STORAGE_COLUMNS * ARCANE_STORAGE_ROWS + 1];
  29. slotForger(ARCANE_STORAGE_ARRAY, baseX, baseY, buffer, tileEntityArcaneStorage);
  30. }
  31.  
  32. addPlayerInventory(playerInvBaseX, playerInvBaseY, buffer, inventoryPlayer);
  33. }
  34.  
  35. @Override
  36. public boolean canInteractWith(EntityPlayer entityPlayer) {
  37. return arcaneStorage.isUseableByPlayer(entityPlayer);
  38. }
  39.  
  40. protected void slotForger(int storageArray[][], int baseX, int baseY, int buffer, TileEntityArcaneStorage tileEntityArcaneStorage) {
  41. int indexCounter = 1;
  42. for (int slotX = 0; slotX < storageArray.length; slotX++) {
  43. for (int slotY = 0; slotY < storageArray[slotX].length; slotY++) {
  44. int xCoord = (baseX + slotY * buffer);
  45. int yCoord = (baseY + slotX * buffer);
  46. int slotIndex = storageArray[slotX][slotY];
  47.  
  48. slotIndexLocations[indexCounter] = String.format("Index: %05d is at: X: %05d, Y: %05d", indexCounter, xCoord, yCoord);
  49. addSlotToContainer(new Slot(tileEntityArcaneStorage, slotIndex, xCoord, yCoord));
  50.  
  51. indexCounter++;
  52. }
  53. }
  54. }
  55.  
  56. protected void addPlayerInventory(int baseX, int baseY, int buffer, InventoryPlayer inventoryPlayer) {
  57. int playerInvSize[][] = new int[3][9];
  58. int indexCounter = 1;
  59. for (int slotX = 0; slotX < playerInvSize.length; slotX++) {
  60. for (int slotY = 0; slotY < playerInvSize[slotX].length; slotY++) {
  61. int slotIndex = playerInvSize[slotX][slotY];
  62. int xCoord = (baseX + slotY * buffer);
  63. int yCoord = (baseY + slotX * buffer);
  64.  
  65. playerSlotIndexLocations[indexCounter] = String.format("Index: %05d is at: X: %05d, Y: %05d", indexCounter, xCoord, yCoord);
  66. addSlotToContainer(new Slot(inventoryPlayer, slotIndex, xCoord, yCoord));
  67.  
  68. indexCounter++;
  69. }
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement