mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
167 lines
4.5 KiB
Java
167 lines
4.5 KiB
Java
package com.hbm.gui;
|
|
|
|
import com.hbm.blocks.TileEntityDiFurnace;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
import net.minecraft.inventory.Container;
|
|
import net.minecraft.inventory.ICrafting;
|
|
import net.minecraft.inventory.Slot;
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
public class ContainerDiFurnace extends Container {
|
|
|
|
private TileEntityDiFurnace diFurnace;
|
|
private int dualCookTime;
|
|
private int dualPower;
|
|
private int lastItemBurnTime;
|
|
|
|
public ContainerDiFurnace(InventoryPlayer invPlayer, TileEntityDiFurnace tedf) {
|
|
dualCookTime = 0;
|
|
dualPower = 0;
|
|
lastItemBurnTime = 0;
|
|
|
|
diFurnace = tedf;
|
|
|
|
this.addSlotToContainer(new Slot(tedf, 0, 80, 18));
|
|
this.addSlotToContainer(new Slot(tedf, 1, 80, 54));
|
|
this.addSlotToContainer(new Slot(tedf, 2, 8, 36));
|
|
this.addSlotToContainer(new SlotDiFurnace(invPlayer.player, tedf, 3, 134, 36));
|
|
|
|
for(int i = 0; i < 3; i++)
|
|
{
|
|
for(int j = 0; j < 9; j++)
|
|
{
|
|
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
|
}
|
|
}
|
|
|
|
for(int i = 0; i < 9; i++)
|
|
{
|
|
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142));
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void addCraftingToCrafters(ICrafting crafting) {
|
|
super.addCraftingToCrafters(crafting);
|
|
crafting.sendProgressBarUpdate(this, 0, this.diFurnace.dualCookTime);
|
|
crafting.sendProgressBarUpdate(this, 1, this.diFurnace.dualPower);
|
|
/**=====We are entering the magic realm of broken shit.=====**/
|
|
}
|
|
|
|
@Override
|
|
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_)
|
|
{
|
|
/*ItemStack itemstack = null;
|
|
Slot slot = (Slot)this.inventorySlots.get(p_82846_2_);
|
|
|
|
if (slot != null && slot.getHasStack())
|
|
{
|
|
ItemStack itemstack1 = slot.getStack();
|
|
itemstack = itemstack1.copy();
|
|
|
|
if (p_82846_2_ == 2)
|
|
{
|
|
if (!this.mergeItemStack(itemstack1, 3, 39, true))
|
|
{
|
|
*/return null;/*
|
|
}
|
|
|
|
slot.onSlotChange(itemstack1, itemstack);
|
|
}
|
|
else if (p_82846_2_ != 1 && p_82846_2_ != 0)
|
|
{
|
|
if (FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null)
|
|
{
|
|
if (!this.mergeItemStack(itemstack1, 0, 1, false))
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else if (TileEntityFurnace.isItemFuel(itemstack1))
|
|
{
|
|
if (!this.mergeItemStack(itemstack1, 1, 2, false))
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else if (p_82846_2_ >= 3 && p_82846_2_ < 30)
|
|
{
|
|
if (!this.mergeItemStack(itemstack1, 30, 39, false))
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else if (p_82846_2_ >= 30 && p_82846_2_ < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else 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(p_82846_1_, itemstack1);
|
|
}
|
|
|
|
return itemstack;*/
|
|
}
|
|
|
|
@Override
|
|
public boolean canInteractWith(EntityPlayer player) {
|
|
return diFurnace.isUseableByPlayer(player);
|
|
}
|
|
|
|
@Override
|
|
public void detectAndSendChanges() {
|
|
super.detectAndSendChanges();
|
|
|
|
for(int i = 0; i < this.crafters.size(); i++)
|
|
{
|
|
ICrafting par1 = (ICrafting)this.crafters.get(i);
|
|
|
|
if(this.dualCookTime != this.diFurnace.dualCookTime)
|
|
{
|
|
par1.sendProgressBarUpdate(this, 0, this.diFurnace.dualCookTime);
|
|
}
|
|
|
|
if(this.dualPower != this.diFurnace.dualPower)
|
|
{
|
|
par1.sendProgressBarUpdate(this, 1, this.diFurnace.dualPower);
|
|
}
|
|
}
|
|
|
|
this.dualCookTime = this.diFurnace.dualCookTime;
|
|
this.dualPower = this.diFurnace.dualPower;
|
|
}
|
|
|
|
@Override
|
|
public void updateProgressBar(int i, int j) {
|
|
if(i == 0)
|
|
{
|
|
diFurnace.dualCookTime = j;
|
|
}
|
|
if(i == 1)
|
|
{
|
|
diFurnace.dualPower = j;
|
|
}
|
|
}
|
|
|
|
}
|