Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.HexianMods.HexianOres.guicontainer;
- import com.HexianMods.HexianOres.tileentity.HexianOresTileEntity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.inventory.Container;
- import net.minecraft.inventory.IInventory;
- import net.minecraft.inventory.Slot;
- import net.minecraft.item.ItemStack;
- public class ContainerHexianOresTileEntity extends Container{
- private HexianOresTileEntity te;
- public ContainerHexianOresTileEntity(IInventory playerInv, HexianOresTileEntity te){
- this.te = te;
- int y1 = 17;
- for (int x = 0; x < 3; ++x) {
- this.addSlotToContainer(new Slot(te, x + y1 * 3, 62 + x * 18, 17 + y1 * 18));
- y1++;
- }
- for (int y = 0; y < 3; ++y) {
- for (int x = 0; x < 9; ++x) {
- this.addSlotToContainer(new Slot(playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
- }
- }
- for (int x = 0; x < 9; ++x) {
- this.addSlotToContainer(new Slot(playerInv, x, 8 + x * 18, 142));
- }
- }
- @Override
- public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot){
- ItemStack previous = null;
- Slot slot = (Slot) this.inventorySlots.get(fromSlot);
- if(slot != null && slot.getHasStack()){
- ItemStack current = slot.getStack();
- previous = current.copy();
- if(fromSlot < 3){
- if(!this.mergeItemStack(current, 3, 39, true)){
- return null;
- }
- }else{
- if(!this.mergeItemStack(current, 0, 3, false)){
- return null;
- }
- }
- if(current.stackSize == 0){
- slot.putStack((ItemStack) null);
- }else{
- slot.onSlotChanged();
- }
- if(current.stackSize == previous.stackSize){
- return null;
- }
- slot.onPickupFromSlot(playerIn, current);
- }
- return previous;
- }
- @Override
- public boolean canInteractWith(EntityPlayer playerIn){
- return this.te.isUseableByPlayer(playerIn);
- }
- }
Add Comment
Please, Sign In to add comment