Added tile/recipehandler/gui for Assembling Machine

This commit is contained in:
Gig 2015-05-07 23:39:26 +01:00
parent 111cd541b5
commit c6e3dfaf82
8 changed files with 235 additions and 0 deletions

View file

@ -16,6 +16,7 @@ import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileAlloySmelter;
import techreborn.tiles.TileAssemblingMachine;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileMachineCasing;
import cpw.mods.fml.relauncher.Side;
@ -48,6 +49,22 @@ public class BlockAssemblingMachine extends BlockMachineBase {
this.iconBottom = icon.registerIcon("techreborn:machine/machine_bottom");
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_)
{
return new TileAssemblingMachine();
}
@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.assemblingmachineID, world, x, y,
z);
return true;
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{

View file

@ -3,6 +3,7 @@ package techreborn.client;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import techreborn.client.container.ContainerAlloySmelter;
import techreborn.client.container.ContainerAssemblingMachine;
import techreborn.client.container.ContainerBlastFurnace;
import techreborn.client.container.ContainerCentrifuge;
import techreborn.client.container.ContainerChunkloader;
@ -14,6 +15,7 @@ import techreborn.client.container.ContainerQuantumTank;
import techreborn.client.container.ContainerRollingMachine;
import techreborn.client.container.ContainerThermalGenerator;
import techreborn.client.gui.GuiAlloySmelter;
import techreborn.client.gui.GuiAssemblingMachine;
import techreborn.client.gui.GuiBlastFurnace;
import techreborn.client.gui.GuiCentrifuge;
import techreborn.client.gui.GuiChunkLoader;
@ -26,6 +28,7 @@ import techreborn.client.gui.GuiRollingMachine;
import techreborn.client.gui.GuiThermalGenerator;
import techreborn.pda.GuiPda;
import techreborn.tiles.TileAlloySmelter;
import techreborn.tiles.TileAssemblingMachine;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileCentrifuge;
import techreborn.tiles.TileChunkLoader;
@ -52,6 +55,7 @@ public class GuiHandler implements IGuiHandler {
public static final int matterfabID = 9;
public static final int pdaID = 10;
public static final int chunkloaderID = 11;
public static final int assemblingmachineID = 12;
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
@ -101,6 +105,10 @@ public class GuiHandler implements IGuiHandler {
{
return new ContainerChunkloader(
(TileChunkLoader) world.getTileEntity(x, y, z), player);
} else if (ID == assemblingmachineID)
{
return new ContainerAssemblingMachine(
(TileAssemblingMachine) world.getTileEntity(x, y, z), player);
} else if (ID == pdaID)
{
return null;
@ -157,6 +165,10 @@ public class GuiHandler implements IGuiHandler {
{
return new GuiChunkLoader(player,
(TileChunkLoader) world.getTileEntity(x, y, z));
} else if (ID == assemblingmachineID)
{
return new GuiAssemblingMachine(player,
(TileAssemblingMachine) world.getTileEntity(x, y, z));
} else if (ID == pdaID)
{
return new GuiPda(player);

View file

@ -0,0 +1,56 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import techreborn.client.SlotOutput;
import techreborn.tiles.TileAlloySmelter;
import techreborn.tiles.TileAssemblingMachine;
import techreborn.tiles.TileBlastFurnace;
public class ContainerAssemblingMachine extends TechRebornContainer {
EntityPlayer player;
TileAssemblingMachine tile;
@Override
public boolean canInteractWith(EntityPlayer player)
{
return true;
}
public int tickTime;
public ContainerAssemblingMachine(TileAssemblingMachine tileAssemblingMachine,
EntityPlayer player)
{
tile = tileAssemblingMachine;
this.player = player;
// input
this.addSlotToContainer(new Slot(tileAssemblingMachine.inventory, 0, 47, 17));
this.addSlotToContainer(new Slot(tileAssemblingMachine.inventory, 1, 65, 17));
// outputs
this.addSlotToContainer(new SlotOutput(tileAssemblingMachine.inventory, 2,116, 35));
// power
this.addSlotToContainer(new Slot(tileAssemblingMachine.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));
}
}
}

View file

@ -0,0 +1,49 @@
package techreborn.client.gui;
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 techreborn.client.container.ContainerAlloySmelter;
import techreborn.client.container.ContainerAssemblingMachine;
import techreborn.client.container.ContainerBlastFurnace;
import techreborn.tiles.TileAlloySmelter;
import techreborn.tiles.TileAssemblingMachine;
import techreborn.tiles.TileBlastFurnace;
public class GuiAssemblingMachine extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/assembling_machine.png");
TileAssemblingMachine assemblinmachine;
public GuiAssemblingMachine(EntityPlayer player,
TileAssemblingMachine tileassemblinmachine)
{
super(new ContainerAssemblingMachine(tileassemblinmachine, player));
this.xSize = 176;
this.ySize = 167;
assemblinmachine = tileassemblinmachine;
}
@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.assemblinmachine.name"), 60, 6, 4210752);
this.fontRendererObj.drawString(
I18n.format("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
}
}

View file

@ -52,6 +52,7 @@ import techreborn.itemblocks.ItemBlockQuantumChest;
import techreborn.itemblocks.ItemBlockQuantumTank;
import techreborn.itemblocks.ItemBlockStorage;
import techreborn.tiles.TileAlloySmelter;
import techreborn.tiles.TileAssemblingMachine;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileCentrifuge;
import techreborn.tiles.TileChunkLoader;
@ -192,6 +193,7 @@ public class ModBlocks {
AssemblyMachine = new BlockAssemblingMachine(Material.rock);
GameRegistry.registerBlock(AssemblyMachine, "assemblymachine");
GameRegistry.registerTileEntity(TileAssemblingMachine.class, "TileAssemblyMachine");
DieselGenerator = new BlockDieselGenerator(Material.rock);
GameRegistry.registerBlock(DieselGenerator, "dieselgenerator");

View file

@ -0,0 +1,18 @@
package techreborn.recipes;
import net.minecraft.item.ItemStack;
import techreborn.api.recipe.BaseRecipe;
public class AssemblingMachineRecipe extends BaseRecipe {
public AssemblingMachineRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick)
{
super("assemblingMachineRecipe", tickTime, euPerTick);
if(input1 != null)
inputs.add(input1);
if(input2 != null)
inputs.add(input2);
if(output1 != null)
outputs.add(output1);
}
}

View file

@ -0,0 +1,80 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.util.Inventory;
public class TileAssemblingMachine extends TileMachineBase implements IWrenchable {
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(4, "TileAssemblingMachine", 64);
public RecipeCrafter crafter;
public TileAssemblingMachine()
{
//TODO configs
energy = new BasicSink(this, 1000, 2);
//Input slots
int[] inputs = new int[2];
inputs[0] = 0;
inputs[1] = 1;
int[] outputs = new int[1];
outputs[0] = 2;
crafter = new RecipeCrafter("assemblingMachineRecipe", this, energy, 2, 2, inventory, inputs, outputs);
}
@Override
public void updateEntity()
{
super.updateEntity();
energy.updateEntity();
crafter.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)
{
return true;
}
@Override
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(ModBlocks.AlloySmelter, 1);
}
public boolean isComplete()
{
return false;
}
}

View file

@ -15,6 +15,7 @@ tile.techreborn.matterfabricator.name=Matter Fabricator
tile.techreborn.implosioncompressor.name=Implosion Compressor
tile.techreborn.grinder.name=Industrial Grinder
tile.techreborn.chunkloader.name=Industrial Chunkloader
tile.techreborn.assemblinmachine.name=Assembling Machine
#Ores