Guest User

Untitled

a guest
Sep 28th, 2014
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. package com.crilleslo.container;
  2.  
  3. import com.crilleslo.tileentity.TileEntityWindmill;
  4.  
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.entity.player.InventoryPlayer;
  7. import net.minecraft.inventory.Container;
  8. import net.minecraft.inventory.Slot;
  9. import net.minecraft.item.ItemStack;
  10.  
  11. public class ContainerWindmill extends Container {
  12.  
  13. protected TileEntityWindmill tileEntity;
  14.  
  15. public ContainerWindmill(InventoryPlayer player, TileEntityWindmill te) {
  16. tileEntity = te;
  17.  
  18. //Batteryslot
  19. addSlotToContainer(new Slot(tileEntity, 0, 55, 37));
  20. addSlotToContainer(new Slot(tileEntity, 1, 103, 37));
  21.  
  22. //Upgradeslots
  23. addSlotToContainer(new Slot(tileEntity, 2, 154, 6));
  24. addSlotToContainer(new Slot(tileEntity, 3, 154, 26));
  25. addSlotToContainer(new Slot(tileEntity, 4, 154, 46));
  26.  
  27. bindPlayerInventory(player);
  28. }
  29.  
  30. protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
  31. for (int i = 0; i < 3; i++) {
  32. for (int j = 0; j < 9; j++) {
  33. addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
  34. }
  35. }
  36.  
  37. for (int i = 0; i < 9; i++) {
  38. addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
  39. }
  40. }
  41.  
  42. public void detectAndSendChanges() {
  43. super.detectAndSendChanges();
  44. }
  45.  
  46. public ItemStack transferStackInSlot(EntityPlayer player, int clickedSlotNumber) {
  47. ItemStack itemstack = null;
  48. Slot slot = (Slot)this.inventorySlots.get(clickedSlotNumber);
  49.  
  50. if(slot != null && slot.getHasStack()){
  51. ItemStack itemstack1 = slot.getStack();
  52. itemstack = itemstack1.copy();
  53.  
  54. if(!this.mergeItemStack(itemstack1, 3, 39, false)){
  55. return null;
  56. }
  57.  
  58. if(itemstack1.stackSize == 0){
  59. slot.putStack((ItemStack)null);
  60. }else{
  61. slot.onSlotChanged();
  62. }
  63.  
  64. if(itemstack1.stackSize == itemstack.stackSize){
  65. return null;
  66. }
  67.  
  68. slot.onPickupFromSlot(player, itemstack1);
  69. }
  70.  
  71. return itemstack;
  72. }
  73.  
  74. public void updateProgressBar(int bar, int value) {
  75.  
  76. }
  77.  
  78. public boolean canInteractWith(EntityPlayer player) {
  79. return this.tileEntity.isUseableByPlayer(player);
  80. }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment