Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.17 KB | None | 0 0
  1. package melonslise.runicinscription.common.container;
  2.  
  3. import java.util.Arrays;
  4.  
  5. import melonslise.runicinscription.RunicInscription;
  6. import melonslise.runicinscription.common.inventory.InventoryRuneInscription;
  7. import melonslise.runicinscription.common.inventory.SlotRuneInscription;
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.entity.player.InventoryPlayer;
  10. import net.minecraft.init.Items;
  11. import net.minecraft.inventory.Container;
  12. import net.minecraft.inventory.IInventory;
  13. import net.minecraft.inventory.InventoryCraftResult;
  14. import net.minecraft.inventory.Slot;
  15. import net.minecraft.item.ItemStack;
  16. import net.minecraft.world.World;
  17.  
  18. public class ContainerRuneInscription extends Container
  19. {
  20.     public boolean grid[][] = new boolean[5][7];
  21.     public InventoryRuneInscription inventoryInscription = new InventoryRuneInscription(this);
  22.     private int posX;
  23.     private int posY;
  24.     private int posZ;
  25.    
  26.     public ContainerRuneInscription(InventoryPlayer inventoryPlayer, World world, int x, int y, int z)
  27.     {
  28.         this.posX = x;
  29.         this.posY = y;
  30.         this.posZ = z;
  31.        
  32.         this.addSlotToContainer(new SlotRuneInscription(inventoryInscription, 0, 8, 47));
  33.         this.addSlotToContainer(new SlotRuneInscription(inventoryInscription, 1, 152, 47));
  34.        
  35.         for (int i = 0; i < 3; ++i)
  36.         {
  37.             for (int k = 0; k < 9; ++k)
  38.             {
  39.                 this.addSlotToContainer(new Slot(inventoryPlayer, k + i * 9 + 9, 8 + k * 18, 124 + i * 18));
  40.             }
  41.         }
  42.        
  43.         for (int i = 0; i < 9; ++i)
  44.         {
  45.             this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 182));
  46.         }
  47.     }
  48.    
  49.     @Override
  50.     public ItemStack transferStackInSlot(EntityPlayer player, int fromSlot)
  51.     {
  52.         return null;
  53.        
  54.         //On shift-click
  55.     }
  56.    
  57.     public void onContainerClosed(EntityPlayer player)
  58.     {
  59.         super.onContainerClosed(player);
  60.        
  61.         for(int x = 0; x < 5; ++x)
  62.         {
  63.             for(int y = 0; y < 7; ++y)
  64.             {
  65.                 grid[x][y] = false;
  66.             }
  67.         }
  68.        
  69.         //On closed
  70.     }
  71.    
  72.     @Override
  73.     public boolean canInteractWith(EntityPlayer player)
  74.     {
  75.         return true;
  76.     }
  77.    
  78.    
  79.    
  80.     ////
  81.     //// RECIPES
  82.     ////
  83.    
  84.    
  85.    
  86.     public void updateGrid(boolean grid, int posX, int posY)
  87.     {
  88.         this.grid[posX][posY] = grid;
  89.         this.checkRecipes();
  90.     }
  91.    
  92.     public void checkRecipes()
  93.     {
  94.         // Add dye
  95.        
  96.         boolean Firebolt[][] = new boolean[5][7];
  97.         Firebolt[0][0] = false; Firebolt[1][0] = false; Firebolt[2][0] = true; Firebolt[3][0] = false; Firebolt[4][0] = true;
  98.         Firebolt[0][1] = false; Firebolt[1][1] = false; Firebolt[2][1] = true; Firebolt[3][1] = true; Firebolt[4][1] = false;
  99.         Firebolt[0][2] = false; Firebolt[1][2] = false; Firebolt[2][2] = true; Firebolt[3][2] = false; Firebolt[4][2] = false;
  100.         Firebolt[0][3] = false; Firebolt[1][3] = false; Firebolt[2][3] = true; Firebolt[3][3] = false; Firebolt[4][3] = false;
  101.         Firebolt[0][4] = false; Firebolt[1][4] = false; Firebolt[2][4] = true; Firebolt[3][4] = false; Firebolt[4][4] = false;
  102.         Firebolt[0][5] = false; Firebolt[1][5] = true; Firebolt[2][5] = true; Firebolt[3][5] = false; Firebolt[4][5] = false;
  103.         Firebolt[0][6] = true; Firebolt[1][6] = false; Firebolt[2][6] = true; Firebolt[3][6] = false; Firebolt[4][6] = false;
  104.        
  105.         boolean Icebolt[][] = new boolean[5][7];
  106.         Icebolt[0][0] = false; Icebolt[1][0] = false; Icebolt[2][0] = true; Icebolt[3][0] = false; Icebolt[4][0] = false;
  107.         Icebolt[0][1] = false; Icebolt[1][1] = false; Icebolt[2][1] = true; Icebolt[3][1] = false; Icebolt[4][1] = false;
  108.         Icebolt[0][2] = false; Icebolt[1][2] = false; Icebolt[2][2] = true; Icebolt[3][2] = false; Icebolt[4][2] = false;
  109.         Icebolt[0][3] = false; Icebolt[1][3] = false; Icebolt[2][3] = true; Icebolt[3][3] = false; Icebolt[4][3] = false;
  110.         Icebolt[0][4] = false; Icebolt[1][4] = false; Icebolt[2][4] = true; Icebolt[3][4] = false; Icebolt[4][4] = false;
  111.         Icebolt[0][5] = false; Icebolt[1][5] = false; Icebolt[2][5] = true; Icebolt[3][5] = false; Icebolt[4][5] = false;
  112.         Icebolt[0][6] = false; Icebolt[1][6] = false; Icebolt[2][6] = true; Icebolt[3][6] = false; Icebolt[4][6] = false;
  113.        
  114.         boolean Lightningbolt[][] = new boolean[5][7];
  115.         Lightningbolt[0][0] = false; Lightningbolt[1][0] = true; Lightningbolt[2][0] = true; Lightningbolt[3][0] = false; Lightningbolt[4][0] = false;
  116.         Lightningbolt[0][1] = false; Lightningbolt[1][1] = true; Lightningbolt[2][1] = false; Lightningbolt[3][1] = true; Lightningbolt[4][1] = false;
  117.         Lightningbolt[0][2] = false; Lightningbolt[1][2] = true; Lightningbolt[2][2] = true; Lightningbolt[3][2] = false; Lightningbolt[4][2] = false;
  118.         Lightningbolt[0][3] = false; Lightningbolt[1][3] = true; Lightningbolt[2][3] = false; Lightningbolt[3][3] = true; Lightningbolt[4][3] = false;
  119.         Lightningbolt[0][4] = false; Lightningbolt[1][4] = true; Lightningbolt[2][4] = false; Lightningbolt[3][4] = false; Lightningbolt[4][4] = false;
  120.         Lightningbolt[0][5] = false; Lightningbolt[1][5] = true; Lightningbolt[2][5] = false; Lightningbolt[3][5] = false; Lightningbolt[4][5] = false;
  121.         Lightningbolt[0][6] = false; Lightningbolt[1][6] = true; Lightningbolt[2][6] = false; Lightningbolt[3][6] = false; Lightningbolt[4][6] = false;
  122.        
  123.         boolean Heal[][] = new boolean[5][7];
  124.         Heal[0][0] = true; Heal[1][0] = false; Heal[2][0] = false; Heal[3][0] = false; Heal[4][0] = true;
  125.         Heal[0][1] = true; Heal[1][1] = true; Heal[2][1] = false; Heal[3][1] = true; Heal[4][1] = true;
  126.         Heal[0][2] = true; Heal[1][2] = false; Heal[2][2] = true; Heal[3][2] = false; Heal[4][2] = true;
  127.         Heal[0][3] = true; Heal[1][3] = true; Heal[2][3] = false; Heal[3][3] = true; Heal[4][3] = true;
  128.         Heal[0][4] = true; Heal[1][4] = false; Heal[2][4] = false; Heal[3][4] = false; Heal[4][4] = true;
  129.         Heal[0][5] = true; Heal[1][5] = false; Heal[2][5] = false; Heal[3][5] = false; Heal[4][5] = true;
  130.         Heal[0][6] = true; Heal[1][6] = false; Heal[2][6] = false; Heal[3][6] = false; Heal[4][6] = true;
  131.        
  132.         boolean Dispel[][] = new boolean[5][7];
  133.         Dispel[0][0] = false; Dispel[1][0] = false; Dispel[2][0] = true; Dispel[3][0] = false; Dispel[4][0] = false;
  134.         Dispel[0][1] = true; Dispel[1][1] = false; Dispel[2][1] = true; Dispel[3][1] = false; Dispel[4][1] = false;
  135.         Dispel[0][2] = false; Dispel[1][2] = true; Dispel[2][2] = true; Dispel[3][2] = false; Dispel[4][2] = false;
  136.         Dispel[0][3] = false; Dispel[1][3] = false; Dispel[2][3] = true; Dispel[3][3] = true; Dispel[4][3] = false;
  137.         Dispel[0][4] = false; Dispel[1][4] = false; Dispel[2][4] = true; Dispel[3][4] = false; Dispel[4][4] = true;
  138.         Dispel[0][5] = false; Dispel[1][5] = false; Dispel[2][5] = true; Dispel[3][5] = false; Dispel[4][5] = false;
  139.         Dispel[0][6] = false; Dispel[1][6] = false; Dispel[2][6] = true; Dispel[3][6] = false; Dispel[4][6] = false;
  140.        
  141.         boolean Firerain[][] = new boolean[5][7];
  142.         Firerain[0][0] = false; Firerain[1][0] = false; Firerain[2][0] = false; Firerain[3][0] = false; Firerain[4][0] = false;
  143.         Firerain[0][1] = true; Firerain[1][1] = false; Firerain[2][1] = false; Firerain[3][1] = false; Firerain[4][1] = false;
  144.         Firerain[0][2] = true; Firerain[1][2] = false; Firerain[2][2] = false; Firerain[3][2] = true; Firerain[4][2] = false;
  145.         Firerain[0][3] = true; Firerain[1][3] = false; Firerain[2][3] = true; Firerain[3][3] = false; Firerain[4][3] = true;
  146.         Firerain[0][4] = false; Firerain[1][4] = true; Firerain[2][4] = false; Firerain[3][4] = false; Firerain[4][4] = true;
  147.         Firerain[0][5] = false; Firerain[1][5] = false; Firerain[2][5] = false; Firerain[3][5] = false; Firerain[4][5] = true;
  148.         Firerain[0][6] = false; Firerain[1][6] = false; Firerain[2][6] = false; Firerain[3][6] = false; Firerain[4][6] = false;
  149.        
  150.         boolean Chainlightning[][] = new boolean[5][7];
  151.         Chainlightning[0][0] = false; Chainlightning[1][0] = false; Chainlightning[2][0] = false; Chainlightning[3][0] = false; Chainlightning[4][0] = false;
  152.         Chainlightning[0][1] = true; Chainlightning[1][1] = false; Chainlightning[2][1] = false; Chainlightning[3][1] = true; Chainlightning[4][1] = false;
  153.         Chainlightning[0][2] = true; Chainlightning[1][2] = true; Chainlightning[2][2] = false; Chainlightning[3][2] = true; Chainlightning[4][2] = false;
  154.         Chainlightning[0][3] = true; Chainlightning[1][3] = false; Chainlightning[2][3] = true; Chainlightning[3][3] = true; Chainlightning[4][3] = false;
  155.         Chainlightning[0][4] = true; Chainlightning[1][4] = false; Chainlightning[2][4] = false; Chainlightning[3][4] = true; Chainlightning[4][4] = false;
  156.         Chainlightning[0][5] = true; Chainlightning[1][5] = false; Chainlightning[2][5] = false; Chainlightning[3][5] = true; Chainlightning[4][5] = false;
  157.         Chainlightning[0][6] = false; Chainlightning[1][6] = false; Chainlightning[2][6] = false; Chainlightning[3][6] = false; Chainlightning[4][6] = false;
  158.        
  159.         if(inventoryInscription.getStackInSlot(0) != null)
  160.         {
  161.             if((this.compare2DArray(this.grid, Firebolt) ==  true) && ((inventoryInscription.getStackInSlot(0).getItem() == Items.dye) && (inventoryInscription.getStackInSlot(0).getItemDamage() == 1)))
  162.             {
  163.                 inventoryInscription.setInventorySlotContents(1, new ItemStack(RunicInscription.itemRuneFirebolt, 1));
  164.             }
  165.             else if((this.compare2DArray(this.grid, Icebolt) ==  true) && ((inventoryInscription.getStackInSlot(0).getItem() == Items.dye) && (inventoryInscription.getStackInSlot(0).getItemDamage() == 12)))
  166.             {
  167.                 inventoryInscription.setInventorySlotContents(1, new ItemStack(RunicInscription.itemRuneIcebolt, 1));
  168.             }
  169.             else if((this.compare2DArray(this.grid, Lightningbolt) ==  true) && ((inventoryInscription.getStackInSlot(0).getItem() == Items.dye) && (inventoryInscription.getStackInSlot(0).getItemDamage() == 11)))
  170.             {
  171.                 inventoryInscription.setInventorySlotContents(1, new ItemStack(RunicInscription.itemRuneLightningbolt, 1));
  172.             }
  173.             else if((this.compare2DArray(this.grid, Heal) ==  true) && ((inventoryInscription.getStackInSlot(0).getItem() == Items.dye) && (inventoryInscription.getStackInSlot(0).getItemDamage() == 10)))
  174.             {
  175.                 inventoryInscription.setInventorySlotContents(1, new ItemStack(RunicInscription.itemRuneHeal, 1));
  176.             }
  177.             else if((this.compare2DArray(this.grid, Dispel) ==  true) && ((inventoryInscription.getStackInSlot(0).getItem() == Items.dye) && (inventoryInscription.getStackInSlot(0).getItemDamage() == 10)))
  178.             {
  179.                 inventoryInscription.setInventorySlotContents(1, new ItemStack(RunicInscription.itemRuneDispel, 1));
  180.             }
  181.             else if((this.compare2DArray(this.grid, Firerain) ==  true) && ((inventoryInscription.getStackInSlot(0).getItem() == Items.dye) && (inventoryInscription.getStackInSlot(0).getItemDamage() == 1)))
  182.             {
  183.                 inventoryInscription.setInventorySlotContents(1, new ItemStack(RunicInscription.itemRuneFirerain, 1));
  184.             }
  185.             else if((this.compare2DArray(this.grid, Chainlightning) ==  true) && ((inventoryInscription.getStackInSlot(0).getItem() == Items.dye) && (inventoryInscription.getStackInSlot(0).getItemDamage() == 11)))
  186.             {
  187.                 inventoryInscription.setInventorySlotContents(1, new ItemStack(RunicInscription.itemRuneChainlightning, 1));
  188.             }
  189.             else
  190.             {
  191.                 inventoryInscription.setInventorySlotContents(1, null);
  192.             }
  193.         }
  194.     }
  195.    
  196.     public static boolean compare2DArray(boolean[][] grid2, boolean[][] firebolt)
  197.     {
  198.         for (int index = 0; index < grid2.length; index ++)
  199.         {
  200.             if (!Arrays.equals(grid2[index], firebolt[index]))
  201.             {
  202.                 return false;
  203.             }
  204.         }
  205.  
  206.         return true;
  207.     }
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement