Added gui/container to alloy furnace
This commit is contained in:
parent
88bb4db40f
commit
e784681b56
6 changed files with 240 additions and 0 deletions
|
@ -16,8 +16,10 @@ import techreborn.Core;
|
|||
import techreborn.blocks.BlockMachineBase;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.tiles.TileAlloyFurnace;
|
||||
import techreborn.tiles.TileAlloySmelter;
|
||||
import techreborn.tiles.TileBlastFurnace;
|
||||
import techreborn.tiles.TileHeatGenerator;
|
||||
import techreborn.tiles.TileMachineCasing;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -41,6 +43,22 @@ public class BlockAlloyFurnace extends BlockMachineBase {
|
|||
super(material);
|
||||
setBlockName("techreborn.alloyfurnace");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int p_149915_2_)
|
||||
{
|
||||
return new TileAlloyFurnace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z,
|
||||
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (!player.isSneaking())
|
||||
player.openGui(Core.INSTANCE, GuiHandler.alloyFurnaceID, world, x, y,
|
||||
z);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
|
|
@ -3,6 +3,7 @@ package techreborn.client;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.client.container.ContainerAesu;
|
||||
import techreborn.client.container.ContainerAlloyFurnace;
|
||||
import techreborn.client.container.ContainerAlloySmelter;
|
||||
import techreborn.client.container.ContainerAssemblingMachine;
|
||||
import techreborn.client.container.ContainerBlastFurnace;
|
||||
|
@ -20,6 +21,7 @@ import techreborn.client.container.ContainerQuantumTank;
|
|||
import techreborn.client.container.ContainerRollingMachine;
|
||||
import techreborn.client.container.ContainerThermalGenerator;
|
||||
import techreborn.client.gui.GuiAesu;
|
||||
import techreborn.client.gui.GuiAlloyFurnace;
|
||||
import techreborn.client.gui.GuiAlloySmelter;
|
||||
import techreborn.client.gui.GuiAssemblingMachine;
|
||||
import techreborn.client.gui.GuiBlastFurnace;
|
||||
|
@ -38,6 +40,7 @@ import techreborn.client.gui.GuiRollingMachine;
|
|||
import techreborn.client.gui.GuiThermalGenerator;
|
||||
import techreborn.pda.GuiPda;
|
||||
import techreborn.tiles.TileAesu;
|
||||
import techreborn.tiles.TileAlloyFurnace;
|
||||
import techreborn.tiles.TileAlloySmelter;
|
||||
import techreborn.tiles.TileAssemblingMachine;
|
||||
import techreborn.tiles.TileBlastFurnace;
|
||||
|
@ -76,6 +79,7 @@ public class GuiHandler implements IGuiHandler {
|
|||
public static final int dieselGeneratorID = 15;
|
||||
public static final int industrialElectrolyzerID = 16;
|
||||
public static final int aesuID =17;
|
||||
public static final int alloyFurnaceID = 18;
|
||||
|
||||
|
||||
|
||||
|
@ -151,6 +155,10 @@ public class GuiHandler implements IGuiHandler {
|
|||
{
|
||||
return new ContainerAesu(
|
||||
(TileAesu) world.getTileEntity(x, y, z), player);
|
||||
} else if (ID == alloyFurnaceID)
|
||||
{
|
||||
return new ContainerAlloyFurnace(
|
||||
(TileAlloyFurnace) world.getTileEntity(x, y, z), player);
|
||||
} else if (ID == pdaID)
|
||||
{
|
||||
return null;
|
||||
|
@ -231,6 +239,10 @@ public class GuiHandler implements IGuiHandler {
|
|||
{
|
||||
return new GuiAesu(player,
|
||||
(TileAesu) world.getTileEntity(x, y, z));
|
||||
} else if (ID == alloyFurnaceID)
|
||||
{
|
||||
return new GuiAlloyFurnace(player,
|
||||
(TileAlloyFurnace) world.getTileEntity(x, y, z));
|
||||
} else if (ID == pdaID)
|
||||
{
|
||||
return new GuiPda(player);
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotFurnace;
|
||||
import techreborn.client.SlotOutput;
|
||||
import techreborn.tiles.TileAlloyFurnace;
|
||||
import techreborn.tiles.TileAlloySmelter;
|
||||
import techreborn.tiles.TileBlastFurnace;
|
||||
|
||||
public class ContainerAlloyFurnace extends TechRebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
|
||||
TileAlloyFurnace tile;
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int tickTime;
|
||||
|
||||
public ContainerAlloyFurnace(TileAlloyFurnace tileAlloyfurnace,
|
||||
EntityPlayer player)
|
||||
{
|
||||
tile = tileAlloyfurnace;
|
||||
this.player = player;
|
||||
|
||||
// input
|
||||
this.addSlotToContainer(new Slot(tileAlloyfurnace.inventory, 0, 47, 17));
|
||||
this.addSlotToContainer(new Slot(tileAlloyfurnace.inventory, 1, 65, 17));
|
||||
// outputs
|
||||
this.addSlotToContainer(new SlotOutput(tileAlloyfurnace.inventory, 2, 116, 35));
|
||||
// Fuel
|
||||
this.addSlotToContainer(new Slot(tileAlloyfurnace.inventory, 3, 56, 53));
|
||||
|
||||
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 < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
|
||||
142));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
61
src/main/java/techreborn/client/gui/GuiAlloyFurnace.java
Normal file
61
src/main/java/techreborn/client/gui/GuiAlloyFurnace.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import techreborn.client.container.ContainerAlloyFurnace;
|
||||
import techreborn.client.container.ContainerAlloySmelter;
|
||||
import techreborn.client.container.ContainerBlastFurnace;
|
||||
import techreborn.tiles.TileAlloyFurnace;
|
||||
import techreborn.tiles.TileAlloySmelter;
|
||||
import techreborn.tiles.TileBlastFurnace;
|
||||
|
||||
public class GuiAlloyFurnace extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation(
|
||||
"techreborn", "textures/gui/alloy_furnace.png");
|
||||
|
||||
TileAlloyFurnace alloyfurnace;
|
||||
|
||||
public GuiAlloyFurnace(EntityPlayer player,
|
||||
TileAlloyFurnace tileAlloyFurnace)
|
||||
{
|
||||
super(new ContainerAlloyFurnace(tileAlloyFurnace, player));
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
alloyfurnace = tileAlloyFurnace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
|
||||
this.buttonList.clear();
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.buttonList.add(new GuiButton(0, k + 4, l + 4, 20, 20, "R"));
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@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(StatCollector.translateToLocal("tile.techreborn.alloyfurnace.name"), 40, 6, 4210752);
|
||||
this.fontRendererObj.drawString(
|
||||
I18n.format("container.inventory", new Object[0]), 8,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
}
|
|
@ -53,6 +53,7 @@ import techreborn.itemblocks.ItemBlockQuantumChest;
|
|||
import techreborn.itemblocks.ItemBlockQuantumTank;
|
||||
import techreborn.itemblocks.ItemBlockStorage;
|
||||
import techreborn.tiles.TileAesu;
|
||||
import techreborn.tiles.TileAlloyFurnace;
|
||||
import techreborn.tiles.TileAlloySmelter;
|
||||
import techreborn.tiles.TileAssemblingMachine;
|
||||
import techreborn.tiles.TileBlastFurnace;
|
||||
|
@ -207,6 +208,7 @@ public class ModBlocks {
|
|||
|
||||
AlloyFurnace = new BlockAlloyFurnace(Material.rock);
|
||||
GameRegistry.registerBlock(AlloyFurnace, "alloyfurnace");
|
||||
GameRegistry.registerTileEntity(TileAlloyFurnace.class, "TileAlloyFurnace");
|
||||
|
||||
ChemicalReactor = new BlockChemicalReactor(Material.rock);
|
||||
GameRegistry.registerBlock(ChemicalReactor, "chemicalreactor");
|
||||
|
|
90
src/main/java/techreborn/tiles/TileAlloyFurnace.java
Normal file
90
src/main/java/techreborn/tiles/TileAlloyFurnace.java
Normal file
|
@ -0,0 +1,90 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import ic2.api.tile.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import techreborn.api.recipe.RecipeCrafter;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.util.Inventory;
|
||||
|
||||
public class TileAlloyFurnace extends TileMachineBase implements IWrenchable {
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(4, "TileAlloyFurnace", 64);
|
||||
|
||||
public TileAlloyFurnace()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getFacing()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(short facing)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
if (entityPlayer.isSneaking())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
return new ItemStack(ModBlocks.AlloyFurnace, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
inventory.readFromNBT(tagCompound);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeToNBT(tagCompound);
|
||||
inventory.writeToNBT(tagCompound);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue