This commit is contained in:
Gig 2015-04-24 14:20:09 +01:00
parent 6e0ec1d861
commit 4ac26ac086
137 changed files with 10339 additions and 7322 deletions

View file

@ -1,63 +1,106 @@
package techreborn.client;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import techreborn.client.container.*;
import techreborn.client.gui.*;
import techreborn.client.container.ContainerBlastFurnace;
import techreborn.client.container.ContainerCentrifuge;
import techreborn.client.container.ContainerQuantumChest;
import techreborn.client.container.ContainerQuantumTank;
import techreborn.client.container.ContainerRollingMachine;
import techreborn.client.container.ContainerThermalGenerator;
import techreborn.client.gui.GuiBlastFurnace;
import techreborn.client.gui.GuiCentrifuge;
import techreborn.client.gui.GuiQuantumChest;
import techreborn.client.gui.GuiQuantumTank;
import techreborn.client.gui.GuiRollingMachine;
import techreborn.client.gui.GuiThermalGenerator;
import techreborn.pda.GuiPda;
import techreborn.tiles.*;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileCentrifuge;
import techreborn.tiles.TileQuantumChest;
import techreborn.tiles.TileQuantumTank;
import techreborn.tiles.TileRollingMachine;
import techreborn.tiles.TileThermalGenerator;
import cpw.mods.fml.common.network.IGuiHandler;
public class GuiHandler implements IGuiHandler {
public static final int thermalGeneratorID = 0;
public static final int quantumTankID = 1;
public static final int quantumChestID = 2;
public static final int centrifugeID = 3;
public static final int rollingMachineID = 4;
public static final int blastFurnaceID = 5;
public static final int pdaID = 6;
public static final int thermalGeneratorID = 0;
public static final int quantumTankID = 1;
public static final int quantumChestID = 2;
public static final int centrifugeID = 3;
public static final int rollingMachineID = 4;
public static final int blastFurnaceID = 5;
public static final int pdaID = 6;
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z)
{
if (ID == thermalGeneratorID)
{
return new ContainerThermalGenerator(
(TileThermalGenerator) world.getTileEntity(x, y, z), player);
} else if (ID == quantumTankID)
{
return new ContainerQuantumTank(
(TileQuantumTank) world.getTileEntity(x, y, z), player);
} else if (ID == quantumChestID)
{
return new ContainerQuantumChest(
(TileQuantumChest) world.getTileEntity(x, y, z), player);
} else if (ID == centrifugeID)
{
return new ContainerCentrifuge(
(TileCentrifuge) world.getTileEntity(x, y, z), player);
} else if (ID == rollingMachineID)
{
return new ContainerRollingMachine(
(TileRollingMachine) world.getTileEntity(x, y, z), player);
} else if (ID == blastFurnaceID)
{
return new ContainerBlastFurnace(
(TileBlastFurnace) world.getTileEntity(x, y, z), player);
} else if (ID == pdaID)
{
return null;
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == thermalGeneratorID) {
return new ContainerThermalGenerator((TileThermalGenerator) world.getTileEntity(x, y, z), player);
} else if (ID == quantumTankID) {
return new ContainerQuantumTank((TileQuantumTank) world.getTileEntity(x, y, z), player);
} else if (ID == quantumChestID) {
return new ContainerQuantumChest((TileQuantumChest) world.getTileEntity(x, y, z), player);
} else if (ID == centrifugeID) {
return new ContainerCentrifuge((TileCentrifuge) world.getTileEntity(x, y, z), player);
} else if (ID == rollingMachineID) {
return new ContainerRollingMachine((TileRollingMachine) world.getTileEntity(x, y, z), player);
} else if (ID == blastFurnaceID) {
return new ContainerBlastFurnace((TileBlastFurnace) world.getTileEntity(x, y, z), player);
} else if (ID == pdaID) {
return null;
}
return null;
}
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == thermalGeneratorID) {
return new GuiThermalGenerator(player, (TileThermalGenerator) world.getTileEntity(x, y, z));
} else if (ID == quantumTankID) {
return new GuiQuantumTank(player, (TileQuantumTank) world.getTileEntity(x, y, z));
} else if (ID == quantumChestID) {
return new GuiQuantumChest(player, (TileQuantumChest) world.getTileEntity(x, y, z));
} else if (ID == centrifugeID) {
return new GuiCentrifuge(player, (TileCentrifuge) world.getTileEntity(x, y, z));
} else if (ID == rollingMachineID) {
return new GuiRollingMachine(player, (TileRollingMachine) world.getTileEntity(x, y, z));
} else if (ID == blastFurnaceID) {
return new GuiBlastFurnace(player, (TileBlastFurnace) world.getTileEntity(x, y, z));
} else if (ID == pdaID) {
return new GuiPda(player);
}
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z)
{
if (ID == thermalGeneratorID)
{
return new GuiThermalGenerator(player,
(TileThermalGenerator) world.getTileEntity(x, y, z));
} else if (ID == quantumTankID)
{
return new GuiQuantumTank(player,
(TileQuantumTank) world.getTileEntity(x, y, z));
} else if (ID == quantumChestID)
{
return new GuiQuantumChest(player,
(TileQuantumChest) world.getTileEntity(x, y, z));
} else if (ID == centrifugeID)
{
return new GuiCentrifuge(player,
(TileCentrifuge) world.getTileEntity(x, y, z));
} else if (ID == rollingMachineID)
{
return new GuiRollingMachine(player,
(TileRollingMachine) world.getTileEntity(x, y, z));
} else if (ID == blastFurnaceID)
{
return new GuiBlastFurnace(player,
(TileBlastFurnace) world.getTileEntity(x, y, z));
} else if (ID == pdaID)
{
return new GuiPda(player);
}
return null;
}
}

View file

@ -4,34 +4,38 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotFake extends Slot {
public boolean mCanInsertItem;
public boolean mCanStackItem;
public int mMaxStacksize = 127;
public boolean mCanInsertItem;
public boolean mCanStackItem;
public int mMaxStacksize = 127;
public SlotFake(IInventory par1iInventory, int par2, int par3, int par4,
boolean aCanInsertItem, boolean aCanStackItem, int aMaxStacksize)
{
super(par1iInventory, par2, par3, par4);
this.mCanInsertItem = aCanInsertItem;
this.mCanStackItem = aCanStackItem;
this.mMaxStacksize = aMaxStacksize;
}
public SlotFake(IInventory par1iInventory, int par2, int par3, int par4, boolean aCanInsertItem, boolean aCanStackItem, int aMaxStacksize) {
super(par1iInventory, par2, par3, par4);
this.mCanInsertItem = aCanInsertItem;
this.mCanStackItem = aCanStackItem;
this.mMaxStacksize = aMaxStacksize;
}
public boolean isItemValid(ItemStack par1ItemStack)
{
return this.mCanInsertItem;
}
public boolean isItemValid(ItemStack par1ItemStack) {
return this.mCanInsertItem;
}
public int getSlotStackLimit()
{
return this.mMaxStacksize;
}
public int getSlotStackLimit() {
return this.mMaxStacksize;
}
public boolean getHasStack()
{
return false;
}
public boolean getHasStack() {
return false;
}
public ItemStack decrStackSize(int par1) {
return !this.mCanStackItem ? null : super.decrStackSize(par1);
}
public ItemStack decrStackSize(int par1)
{
return !this.mCanStackItem ? null : super.decrStackSize(par1);
}
}

View file

@ -6,15 +6,18 @@ import net.minecraft.item.ItemStack;
public class SlotInput extends Slot {
public SlotInput(IInventory par1iInventory, int par2, int par3, int par4) {
super(par1iInventory, par2, par3, par4);
}
public SlotInput(IInventory par1iInventory, int par2, int par3, int par4)
{
super(par1iInventory, par2, par3, par4);
}
public boolean isItemValid(ItemStack par1ItemStack) {
return false;
}
public boolean isItemValid(ItemStack par1ItemStack)
{
return false;
}
public int getSlotStackLimit() {
return 64;
}
public int getSlotStackLimit()
{
return 64;
}
}

View file

@ -6,15 +6,18 @@ import net.minecraft.item.ItemStack;
public class SlotOutput extends Slot {
public SlotOutput(IInventory par1iInventory, int par2, int par3, int par4) {
super(par1iInventory, par2, par3, par4);
}
public SlotOutput(IInventory par1iInventory, int par2, int par3, int par4)
{
super(par1iInventory, par2, par3, par4);
}
public boolean isItemValid(ItemStack par1ItemStack) {
return false;
}
public boolean isItemValid(ItemStack par1ItemStack)
{
return false;
}
public int getSlotStackLimit() {
return 64;
}
public int getSlotStackLimit()
{
return 64;
}
}

View file

@ -6,14 +6,16 @@ import techreborn.init.ModBlocks;
public class TechRebornCreativeTab extends CreativeTabs {
public static TechRebornCreativeTab instance = new TechRebornCreativeTab();
public static TechRebornCreativeTab instance = new TechRebornCreativeTab();
public TechRebornCreativeTab() {
super("techreborn");
}
public TechRebornCreativeTab()
{
super("techreborn");
}
@Override
public Item getTabIconItem() {
return Item.getItemFromBlock(ModBlocks.thermalGenerator);
}
@Override
public Item getTabIconItem()
{
return Item.getItemFromBlock(ModBlocks.thermalGenerator);
}
}

View file

@ -4,19 +4,19 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import techreborn.init.ModItems;
public class TechRebornCreativeTabMisc extends CreativeTabs{
public static TechRebornCreativeTabMisc instance = new TechRebornCreativeTabMisc();
public class TechRebornCreativeTabMisc extends CreativeTabs {
public TechRebornCreativeTabMisc()
{
super("techreborn");
}
public static TechRebornCreativeTabMisc instance = new TechRebornCreativeTabMisc();
@Override
public Item getTabIconItem()
{
return ModItems.cells;
}
public TechRebornCreativeTabMisc()
{
super("techreborn");
}
@Override
public Item getTabIconItem()
{
return ModItems.cells;
}
}

View file

@ -1,48 +1,53 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import techreborn.client.SlotOutput;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileCentrifuge;
public class ContainerBlastFurnace extends TechRebornContainer {
EntityPlayer player;
EntityPlayer player;
TileBlastFurnace tile;
TileBlastFurnace tile;
@Override
public boolean canInteractWith(EntityPlayer player)
public boolean canInteractWith(EntityPlayer player)
{
return true;
}
public int tickTime;
public int tickTime;
public ContainerBlastFurnace(TileBlastFurnace tileblastfurnace, EntityPlayer player) {
tile = tileblastfurnace;
this.player = player;
public ContainerBlastFurnace(TileBlastFurnace tileblastfurnace,
EntityPlayer player)
{
tile = tileblastfurnace;
this.player = player;
//input
this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 0, 56, 25));
this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 1, 56, 43));
//outputs
this.addSlotToContainer(new SlotOutput(tileblastfurnace.inventory, 2, 116, 35));
// input
this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 0, 56, 25));
this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 1, 56, 43));
// outputs
this.addSlotToContainer(new SlotOutput(tileblastfurnace.inventory, 2,
116, 35));
int i;
int i;
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
}
}
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
}

View file

@ -8,61 +8,77 @@ import techreborn.tiles.TileCentrifuge;
public class ContainerCentrifuge extends TechRebornContainer {
EntityPlayer player;
EntityPlayer player;
TileCentrifuge tile;
TileCentrifuge tile;
public int tickTime;
public int tickTime;
public ContainerCentrifuge(TileCentrifuge tileCentrifuge, EntityPlayer player) {
tile = tileCentrifuge;
this.player = player;
public ContainerCentrifuge(TileCentrifuge tileCentrifuge,
EntityPlayer player)
{
tile = tileCentrifuge;
this.player = player;
//input
this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 0, 80, 35));
//cells
this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 1, 50, 5));
//outputs
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 2, 80, 5));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 3, 110, 35));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 4, 80, 65));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 5, 50, 35));
// input
this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 0, 80, 35));
// cells
this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 1, 50, 5));
// outputs
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 2, 80,
5));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 3,
110, 35));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 4, 80,
65));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 5, 50,
35));
int i;
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
}
}
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return true;
}
@Override
public void addCraftingToCrafters(ICrafting crafting) {
super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, tile.tickTime);
}
@Override
public void addCraftingToCrafters(ICrafting crafting)
{
super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, tile.tickTime);
}
/**
* Looks for changes made in the container, sends them to every listener.
*/
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < this.crafters.size(); ++i) {
ICrafting icrafting = (ICrafting) this.crafters.get(i);
if (this.tickTime != this.tile.tickTime) {
icrafting.sendProgressBarUpdate(this, 0, this.tile.tickTime);
}
}
this.tickTime = this.tile.tickTime;
}
/**
* Looks for changes made in the container, sends them to every listener.
*/
public void detectAndSendChanges()
{
super.detectAndSendChanges();
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get(i);
if (this.tickTime != this.tile.tickTime)
{
icrafting.sendProgressBarUpdate(this, 0, this.tile.tickTime);
}
}
this.tickTime = this.tile.tickTime;
}
}

View file

@ -7,34 +7,44 @@ import techreborn.client.SlotOutput;
import techreborn.tiles.TileQuantumChest;
public class ContainerQuantumChest extends TechRebornContainer {
public TileQuantumChest tileQuantumChest;
public EntityPlayer player;
public TileQuantumChest tileQuantumChest;
public EntityPlayer player;
public ContainerQuantumChest(TileQuantumChest tileQuantumChest, EntityPlayer player) {
super();
this.tileQuantumChest = tileQuantumChest;
this.player = player;
public ContainerQuantumChest(TileQuantumChest tileQuantumChest,
EntityPlayer player)
{
super();
this.tileQuantumChest = tileQuantumChest;
this.player = player;
this.addSlotToContainer(new Slot(tileQuantumChest.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tileQuantumChest.inventory, 1, 80, 53));
this.addSlotToContainer(new SlotFake(tileQuantumChest.inventory, 2, 59, 42, false, false, Integer.MAX_VALUE));
this.addSlotToContainer(new Slot(tileQuantumChest.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tileQuantumChest.inventory, 1,
80, 53));
this.addSlotToContainer(new SlotFake(tileQuantumChest.inventory, 2, 59,
42, false, false, Integer.MAX_VALUE));
int i;
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
}
}
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return true;
}
}

View file

@ -7,33 +7,43 @@ import techreborn.client.SlotOutput;
import techreborn.tiles.TileQuantumTank;
public class ContainerQuantumTank extends TechRebornContainer {
public TileQuantumTank tileQuantumTank;
public EntityPlayer player;
public TileQuantumTank tileQuantumTank;
public EntityPlayer player;
public ContainerQuantumTank(TileQuantumTank tileQuantumTank, EntityPlayer player) {
super();
this.tileQuantumTank = tileQuantumTank;
this.player = player;
public ContainerQuantumTank(TileQuantumTank tileQuantumTank,
EntityPlayer player)
{
super();
this.tileQuantumTank = tileQuantumTank;
this.player = player;
this.addSlotToContainer(new Slot(tileQuantumTank.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tileQuantumTank.inventory, 1, 80, 53));
this.addSlotToContainer(new SlotFake(tileQuantumTank.inventory, 2, 59, 42, false, false, 1));
this.addSlotToContainer(new Slot(tileQuantumTank.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tileQuantumTank.inventory, 1,
80, 53));
this.addSlotToContainer(new SlotFake(tileQuantumTank.inventory, 2, 59,
42, false, false, 1));
int i;
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
}
}
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return true;
}
}

View file

@ -11,50 +11,63 @@ import techreborn.tiles.TileRollingMachine;
public class ContainerRollingMachine extends TechRebornContainer {
EntityPlayer player;
TileRollingMachine tile;
EntityPlayer player;
TileRollingMachine tile;
public ContainerRollingMachine(TileRollingMachine tileRollingmachine, EntityPlayer player) {
tile = tileRollingmachine;
this.player = player;
public ContainerRollingMachine(TileRollingMachine tileRollingmachine,
EntityPlayer player)
{
tile = tileRollingmachine;
this.player = player;
for (int l = 0; l < 3; l++)
{
for (int k1 = 0; k1 < 3; k1++)
{
this.addSlotToContainer(new Slot(
tileRollingmachine.craftMatrix, k1 + l * 3,
30 + k1 * 18, 17 + l * 18));
}
}
for (int l = 0; l < 3; l++) {
for (int k1 = 0; k1 < 3; k1++) {
this.addSlotToContainer(new Slot(tileRollingmachine.craftMatrix, k1 + l * 3, 30 + k1 * 18, 17 + l * 18));
}
}
// output
this.addSlotToContainer(new SlotOutput(tileRollingmachine.inventory, 0,
124, 35));
//output
this.addSlotToContainer(new SlotOutput(tileRollingmachine.inventory, 0, 124, 35));
// fakeOutput
this.addSlotToContainer(new SlotFake(tileRollingmachine.inventory, 1,
124, 10, false, false, 1));
//fakeOutput
this.addSlotToContainer(new SlotFake(tileRollingmachine.inventory, 1, 124, 10, false, false, 1));
int i;
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
int i;
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
@Override
public final void onCraftMatrixChanged(IInventory inv) {
ItemStack output = RollingMachineRecipe.instance.findMatchingRecipe(tile.craftMatrix, tile.getWorldObj());
tile.inventory.setInventorySlotContents(1, output);
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return true;
}
@Override
public final void onCraftMatrixChanged(IInventory inv)
{
ItemStack output = RollingMachineRecipe.instance.findMatchingRecipe(
tile.craftMatrix, tile.getWorldObj());
tile.inventory.setInventorySlotContents(1, output);
}
}

View file

@ -7,33 +7,44 @@ import techreborn.client.SlotOutput;
import techreborn.tiles.TileThermalGenerator;
public class ContainerThermalGenerator extends TechRebornContainer {
public TileThermalGenerator tileThermalGenerator;
public EntityPlayer player;
public TileThermalGenerator tileThermalGenerator;
public EntityPlayer player;
public ContainerThermalGenerator(TileThermalGenerator tileThermalGenerator, EntityPlayer player) {
super();
this.tileThermalGenerator = tileThermalGenerator;
this.player = player;
public ContainerThermalGenerator(TileThermalGenerator tileThermalGenerator,
EntityPlayer player)
{
super();
this.tileThermalGenerator = tileThermalGenerator;
this.player = player;
this.addSlotToContainer(new Slot(tileThermalGenerator.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tileThermalGenerator.inventory, 1, 80, 53));
this.addSlotToContainer(new SlotFake(tileThermalGenerator.inventory, 2, 59, 42, false, false, 1));
this.addSlotToContainer(new Slot(tileThermalGenerator.inventory, 0, 80,
17));
this.addSlotToContainer(new SlotOutput(tileThermalGenerator.inventory,
1, 80, 53));
this.addSlotToContainer(new SlotFake(tileThermalGenerator.inventory, 2,
59, 42, false, false, 1));
int i;
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
}
}
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return true;
}
}

View file

@ -7,88 +7,112 @@ import net.minecraft.item.ItemStack;
import techreborn.client.SlotFake;
import techreborn.util.ItemUtils;
public abstract class TechRebornContainer extends Container {
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
ItemStack originalStack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
int numSlots = inventorySlots.size();
if (slot != null && slot.getHasStack()) {
ItemStack stackInSlot = slot.getStack();
originalStack = stackInSlot.copy();
if (slotIndex >= numSlots - 9 * 4 && tryShiftItem(stackInSlot, numSlots)) {
// NOOP
} else if (slotIndex >= numSlots - 9 * 4 && slotIndex < numSlots - 9) {
if (!shiftItemStack(stackInSlot, numSlots - 9, numSlots))
return null;
} else if (slotIndex >= numSlots - 9 && slotIndex < numSlots) {
if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots - 9))
return null;
} else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots))
return null;
slot.onSlotChange(stackInSlot, originalStack);
if (stackInSlot.stackSize <= 0)
slot.putStack(null);
else
slot.onSlotChanged();
if (stackInSlot.stackSize == originalStack.stackSize)
return null;
slot.onPickupFromSlot(player, stackInSlot);
}
return originalStack;
}
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)
{
ItemStack originalStack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
int numSlots = inventorySlots.size();
if (slot != null && slot.getHasStack())
{
ItemStack stackInSlot = slot.getStack();
originalStack = stackInSlot.copy();
if (slotIndex >= numSlots - 9 * 4
&& tryShiftItem(stackInSlot, numSlots))
{
// NOOP
} else if (slotIndex >= numSlots - 9 * 4
&& slotIndex < numSlots - 9)
{
if (!shiftItemStack(stackInSlot, numSlots - 9, numSlots))
return null;
} else if (slotIndex >= numSlots - 9 && slotIndex < numSlots)
{
if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots - 9))
return null;
} else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots))
return null;
slot.onSlotChange(stackInSlot, originalStack);
if (stackInSlot.stackSize <= 0)
slot.putStack(null);
else
slot.onSlotChanged();
if (stackInSlot.stackSize == originalStack.stackSize)
return null;
slot.onPickupFromSlot(player, stackInSlot);
}
return originalStack;
}
protected boolean shiftItemStack(ItemStack stackToShift, int start, int end) {
boolean changed = false;
if (stackToShift.isStackable())
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) {
Slot slot = (Slot) inventorySlots.get(slotIndex);
ItemStack stackInSlot = slot.getStack();
if (stackInSlot != null && ItemUtils.isItemEqual(stackInSlot, stackToShift, true, true)) {
int resultingStackSize = stackInSlot.stackSize + stackToShift.stackSize;
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
if (resultingStackSize <= max) {
stackToShift.stackSize = 0;
stackInSlot.stackSize = resultingStackSize;
slot.onSlotChanged();
changed = true;
} else if (stackInSlot.stackSize < max) {
stackToShift.stackSize -= max - stackInSlot.stackSize;
stackInSlot.stackSize = max;
slot.onSlotChanged();
changed = true;
}
}
}
if (stackToShift.stackSize > 0)
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) {
Slot slot = (Slot) inventorySlots.get(slotIndex);
ItemStack stackInSlot = slot.getStack();
if (stackInSlot == null) {
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
stackInSlot = stackToShift.copy();
stackInSlot.stackSize = Math.min(stackToShift.stackSize, max);
stackToShift.stackSize -= stackInSlot.stackSize;
slot.putStack(stackInSlot);
slot.onSlotChanged();
changed = true;
}
}
return changed;
}
protected boolean shiftItemStack(ItemStack stackToShift, int start, int end)
{
boolean changed = false;
if (stackToShift.isStackable())
for (int slotIndex = start; stackToShift.stackSize > 0
&& slotIndex < end; slotIndex++)
{
Slot slot = (Slot) inventorySlots.get(slotIndex);
ItemStack stackInSlot = slot.getStack();
if (stackInSlot != null
&& ItemUtils.isItemEqual(stackInSlot, stackToShift,
true, true))
{
int resultingStackSize = stackInSlot.stackSize
+ stackToShift.stackSize;
int max = Math.min(stackToShift.getMaxStackSize(),
slot.getSlotStackLimit());
if (resultingStackSize <= max)
{
stackToShift.stackSize = 0;
stackInSlot.stackSize = resultingStackSize;
slot.onSlotChanged();
changed = true;
} else if (stackInSlot.stackSize < max)
{
stackToShift.stackSize -= max - stackInSlot.stackSize;
stackInSlot.stackSize = max;
slot.onSlotChanged();
changed = true;
}
}
}
if (stackToShift.stackSize > 0)
for (int slotIndex = start; stackToShift.stackSize > 0
&& slotIndex < end; slotIndex++)
{
Slot slot = (Slot) inventorySlots.get(slotIndex);
ItemStack stackInSlot = slot.getStack();
if (stackInSlot == null)
{
int max = Math.min(stackToShift.getMaxStackSize(),
slot.getSlotStackLimit());
stackInSlot = stackToShift.copy();
stackInSlot.stackSize = Math.min(stackToShift.stackSize,
max);
stackToShift.stackSize -= stackInSlot.stackSize;
slot.putStack(stackInSlot);
slot.onSlotChanged();
changed = true;
}
}
return changed;
}
private boolean tryShiftItem(ItemStack stackToShift, int numSlots) {
for (int machineIndex = 0; machineIndex < numSlots - 9 * 4; machineIndex++) {
Slot slot = (Slot) inventorySlots.get(machineIndex);
if (slot instanceof SlotFake) {
continue;
}
if (!slot.isItemValid(stackToShift))
continue;
if (shiftItemStack(stackToShift, machineIndex, machineIndex + 1))
return true;
}
return false;
}
private boolean tryShiftItem(ItemStack stackToShift, int numSlots)
{
for (int machineIndex = 0; machineIndex < numSlots - 9 * 4; machineIndex++)
{
Slot slot = (Slot) inventorySlots.get(machineIndex);
if (slot instanceof SlotFake)
{
continue;
}
if (!slot.isItemValid(stackToShift))
continue;
if (shiftItemStack(stackToShift, machineIndex, machineIndex + 1))
return true;
}
return false;
}
}

View file

@ -5,33 +5,40 @@ import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import techreborn.client.container.ContainerBlastFurnace;
import techreborn.client.container.ContainerCentrifuge;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileCentrifuge;
public class GuiBlastFurnace extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_blast_furnace.png");
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/industrial_blast_furnace.png");
TileBlastFurnace blastfurnace;
TileBlastFurnace blastfurnace;
public GuiBlastFurnace(EntityPlayer player, TileBlastFurnace tileblastfurnace) {
super(new ContainerBlastFurnace(tileblastfurnace, player));
this.xSize = 176;
this.ySize = 167;
blastfurnace = tileblastfurnace;
}
public GuiBlastFurnace(EntityPlayer player,
TileBlastFurnace tileblastfurnace)
{
super(new ContainerBlastFurnace(tileblastfurnace, player));
this.xSize = 176;
this.ySize = 167;
blastfurnace = tileblastfurnace;
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
int p_146976_2_, int p_146976_3_)
{
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
this.fontRendererObj.drawString("Blastfurnace", 60, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_)
{
this.fontRendererObj.drawString("Blastfurnace", 60, 6, 4210752);
this.fontRendererObj.drawString(
I18n.format("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
}
}

View file

@ -9,28 +9,37 @@ import techreborn.tiles.TileCentrifuge;
public class GuiCentrifuge extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/centrifuge.png");
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/centrifuge.png");
TileCentrifuge centrifuge;
TileCentrifuge centrifuge;
public GuiCentrifuge(EntityPlayer player, TileCentrifuge tileCentrifuge) {
super(new ContainerCentrifuge(tileCentrifuge, player));
this.xSize = 176;
this.ySize = 167;
centrifuge = tileCentrifuge;
}
public GuiCentrifuge(EntityPlayer player, TileCentrifuge tileCentrifuge)
{
super(new ContainerCentrifuge(tileCentrifuge, player));
this.xSize = 176;
this.ySize = 167;
centrifuge = tileCentrifuge;
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
int p_146976_2_, int p_146976_3_)
{
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
this.fontRendererObj.drawString("Centrifuge", 110, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(centrifuge.tickTime + " " + centrifuge.isRunning, 110, this.ySize - 96 + 2, 4210752);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_)
{
this.fontRendererObj.drawString("Centrifuge", 110, 6, 4210752);
this.fontRendererObj.drawString(
I18n.format("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(centrifuge.tickTime + " "
+ centrifuge.isRunning, 110, this.ySize - 96 + 2, 4210752);
}
}

View file

@ -1,6 +1,5 @@
package techreborn.client.gui;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
@ -10,31 +9,39 @@ import techreborn.tiles.TileQuantumChest;
public class GuiQuantumChest extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/ThermalGenerator.png");
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/ThermalGenerator.png");
TileQuantumChest tile;
TileQuantumChest tile;
public GuiQuantumChest(EntityPlayer player, TileQuantumChest tile) {
super(new ContainerQuantumChest(tile, player));
this.xSize = 176;
this.ySize = 167;
this.tile = tile;
}
public GuiQuantumChest(EntityPlayer player, TileQuantumChest tile)
{
super(new ContainerQuantumChest(tile, player));
this.xSize = 176;
this.ySize = 167;
this.tile = tile;
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
int p_146976_2_, int p_146976_3_)
{
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
this.fontRendererObj.drawString("Quantum Chest", 8, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString("Amount", 10, 20, 16448255);
if (tile.storedItem != null)
this.fontRendererObj.drawString(tile.storedItem.stackSize + "", 10, 30, 16448255);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_)
{
this.fontRendererObj.drawString("Quantum Chest", 8, 6, 4210752);
this.fontRendererObj.drawString(
I18n.format("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString("Amount", 10, 20, 16448255);
if (tile.storedItem != null)
this.fontRendererObj.drawString(tile.storedItem.stackSize + "", 10,
30, 16448255);
}
}

View file

@ -9,30 +9,38 @@ import techreborn.tiles.TileQuantumTank;
public class GuiQuantumTank extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/ThermalGenerator.png");
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/ThermalGenerator.png");
TileQuantumTank tile;
TileQuantumTank tile;
public GuiQuantumTank(EntityPlayer player, TileQuantumTank tile) {
super(new ContainerQuantumTank(tile, player));
this.xSize = 176;
this.ySize = 167;
this.tile = tile;
}
public GuiQuantumTank(EntityPlayer player, TileQuantumTank tile)
{
super(new ContainerQuantumTank(tile, player));
this.xSize = 176;
this.ySize = 167;
this.tile = tile;
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
int p_146976_2_, int p_146976_3_)
{
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
this.fontRendererObj.drawString("Quantum Tank", 8, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255);
this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, 30, 16448255);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_)
{
this.fontRendererObj.drawString("Quantum Tank", 8, 6, 4210752);
this.fontRendererObj.drawString(
I18n.format("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255);
this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10,
30, 16448255);
}
}

View file

@ -8,22 +8,27 @@ import techreborn.tiles.TileRollingMachine;
public class GuiRollingMachine extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/rollingmachine.png");
TileRollingMachine rollingMachine;
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/rollingmachine.png");
TileRollingMachine rollingMachine;
public GuiRollingMachine(EntityPlayer player, TileRollingMachine tileRollingmachine) {
super(new ContainerRollingMachine(tileRollingmachine, player));
this.xSize = 176;
this.ySize = 167;
rollingMachine = tileRollingmachine;
}
public GuiRollingMachine(EntityPlayer player,
TileRollingMachine tileRollingmachine)
{
super(new ContainerRollingMachine(tileRollingmachine, player));
this.xSize = 176;
this.ySize = 167;
rollingMachine = tileRollingmachine;
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
int p_146976_2_, int p_146976_3_)
{
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
}

View file

@ -9,29 +9,38 @@ import techreborn.tiles.TileThermalGenerator;
public class GuiThermalGenerator extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/ThermalGenerator.png");
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/ThermalGenerator.png");
TileThermalGenerator tile;
TileThermalGenerator tile;
public GuiThermalGenerator(EntityPlayer player, TileThermalGenerator tile) {
super(new ContainerThermalGenerator(tile, player));
this.xSize = 176;
this.ySize = 167;
this.tile = tile;
}
public GuiThermalGenerator(EntityPlayer player, TileThermalGenerator tile)
{
super(new ContainerThermalGenerator(tile, player));
this.xSize = 176;
this.ySize = 167;
this.tile = tile;
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
int p_146976_2_, int p_146976_3_)
{
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
this.fontRendererObj.drawString("Thermal Generator", 8, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255);
this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, 30, 16448255);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_)
{
this.fontRendererObj.drawString("Thermal Generator", 8, 6, 4210752);
this.fontRendererObj.drawString(
I18n.format("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255);
this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10,
30, 16448255);
}
}