Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.crilleslo.container;
- import com.crilleslo.tileentity.TileEntityWindmill;
- 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;
- public class ContainerWindmill extends Container {
- protected TileEntityWindmill tileEntity;
- public ContainerWindmill(InventoryPlayer player, TileEntityWindmill te) {
- tileEntity = te;
- //Batteryslot
- addSlotToContainer(new Slot(tileEntity, 0, 55, 37));
- addSlotToContainer(new Slot(tileEntity, 1, 103, 37));
- //Upgradeslots
- addSlotToContainer(new Slot(tileEntity, 2, 154, 6));
- addSlotToContainer(new Slot(tileEntity, 3, 154, 26));
- addSlotToContainer(new Slot(tileEntity, 4, 154, 46));
- bindPlayerInventory(player);
- }
- protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 9; j++) {
- addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
- }
- }
- for (int i = 0; i < 9; i++) {
- addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
- }
- }
- public void detectAndSendChanges() {
- super.detectAndSendChanges();
- }
- public ItemStack transferStackInSlot(EntityPlayer player, int clickedSlotNumber) {
- ItemStack itemstack = null;
- Slot slot = (Slot)this.inventorySlots.get(clickedSlotNumber);
- if(slot != null && slot.getHasStack()){
- ItemStack itemstack1 = slot.getStack();
- itemstack = itemstack1.copy();
- if(!this.mergeItemStack(itemstack1, 3, 39, false)){
- return null;
- }
- if(itemstack1.stackSize == 0){
- slot.putStack((ItemStack)null);
- }else{
- slot.onSlotChanged();
- }
- if(itemstack1.stackSize == itemstack.stackSize){
- return null;
- }
- slot.onPickupFromSlot(player, itemstack1);
- }
- return itemstack;
- }
- public void updateProgressBar(int bar, int value) {
- }
- public boolean canInteractWith(EntityPlayer player) {
- return this.tileEntity.isUseableByPlayer(player);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment