mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
*Fixed incorrect repo location. *Formatting. *Fixed minor bugs in Metallurgic Infuser. *Fixed unobtainable machines.
101 lines
2.8 KiB
Java
101 lines
2.8 KiB
Java
package mekanism.generators.common;
|
|
|
|
import ic2.api.IElectricItem;
|
|
import mekanism.common.SlotEnergy;
|
|
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.Item;
|
|
import net.minecraft.item.ItemStack;
|
|
import universalelectricity.core.implement.IItemElectric;
|
|
|
|
public class ContainerSolarGenerator extends Container
|
|
{
|
|
private TileEntitySolarGenerator tileEntity;
|
|
|
|
public ContainerSolarGenerator(InventoryPlayer inventory, TileEntitySolarGenerator tentity)
|
|
{
|
|
tileEntity = tentity;
|
|
addSlotToContainer(new SlotEnergy(tentity, 0, 143, 35));
|
|
int slotX;
|
|
|
|
for (slotX = 0; slotX < 3; ++slotX)
|
|
{
|
|
for (int slotY = 0; slotY < 9; ++slotY)
|
|
{
|
|
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
|
|
}
|
|
}
|
|
|
|
for (slotX = 0; slotX < 9; ++slotX)
|
|
{
|
|
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
|
|
}
|
|
|
|
tileEntity.openChest();
|
|
}
|
|
|
|
@Override
|
|
public void onCraftGuiClosed(EntityPlayer entityplayer)
|
|
{
|
|
super.onCraftGuiClosed(entityplayer);
|
|
tileEntity.closeChest();
|
|
}
|
|
|
|
@Override
|
|
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
|
|
{
|
|
return tileEntity.isUseableByPlayer(par1EntityPlayer);
|
|
}
|
|
|
|
@Override
|
|
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
|
|
{
|
|
ItemStack stack = null;
|
|
Slot currentSlot = (Slot)inventorySlots.get(slotID);
|
|
|
|
if(currentSlot != null && currentSlot.getHasStack())
|
|
{
|
|
ItemStack slotStack = currentSlot.getStack();
|
|
stack = slotStack.copy();
|
|
|
|
if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.shiftedIndex)
|
|
{
|
|
if(slotID != 0)
|
|
{
|
|
if (!mergeItemStack(slotStack, 0, 1, false))
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else if(slotID == 1)
|
|
{
|
|
if(!mergeItemStack(slotStack, 1, inventorySlots.size(), false))
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (slotStack.stackSize == 0)
|
|
{
|
|
currentSlot.putStack((ItemStack)null);
|
|
}
|
|
else
|
|
{
|
|
currentSlot.onSlotChanged();
|
|
}
|
|
|
|
if (slotStack.stackSize == stack.stackSize)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
currentSlot.onPickupFromSlot(player, slotStack);
|
|
}
|
|
|
|
return stack;
|
|
}
|
|
}
|