diff --git a/src/main/java/techreborn/blocks/BlockCentrifuge.java b/src/main/java/techreborn/blocks/BlockCentrifuge.java new file mode 100644 index 000000000..9f12b30d1 --- /dev/null +++ b/src/main/java/techreborn/blocks/BlockCentrifuge.java @@ -0,0 +1,30 @@ +package techreborn.blocks; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import techreborn.Core; +import techreborn.client.GuiHandler; +import techreborn.tiles.TileCentrifuge; + +public class BlockCentrifuge extends BlockContainer { + + public BlockCentrifuge(){ + super(Material.piston); + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return new TileCentrifuge(); + } + + @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.centrifugeID, world, x, y, z); + return true; + } + +} diff --git a/src/main/java/techreborn/client/GuiHandler.java b/src/main/java/techreborn/client/GuiHandler.java index 2f83ad445..e8981bcea 100644 --- a/src/main/java/techreborn/client/GuiHandler.java +++ b/src/main/java/techreborn/client/GuiHandler.java @@ -3,12 +3,15 @@ package techreborn.client; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; +import techreborn.client.container.ContainerCentrifuge; import techreborn.client.container.ContainerQuantumChest; import techreborn.client.container.ContainerQuantumTank; import techreborn.client.container.ContainerThermalGenerator; +import techreborn.client.gui.GuiCentrifuge; import techreborn.client.gui.GuiQuantumChest; import techreborn.client.gui.GuiQuantumTank; import techreborn.client.gui.GuiThermalGenerator; +import techreborn.tiles.TileCentrifuge; import techreborn.tiles.TileQuantumChest; import techreborn.tiles.TileQuantumTank; import techreborn.tiles.TileThermalGenerator; @@ -19,6 +22,7 @@ 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; @Override @@ -29,6 +33,8 @@ public class GuiHandler implements IGuiHandler { 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); } return null; @@ -42,6 +48,8 @@ public class GuiHandler implements IGuiHandler { 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)); } return null; } diff --git a/src/main/java/techreborn/client/container/ContainerCentrifuge.java b/src/main/java/techreborn/client/container/ContainerCentrifuge.java new file mode 100644 index 000000000..1393cb805 --- /dev/null +++ b/src/main/java/techreborn/client/container/ContainerCentrifuge.java @@ -0,0 +1,45 @@ +package techreborn.client.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; +import techreborn.client.SlotOutput; +import techreborn.tiles.TileCentrifuge; + +public class ContainerCentrifuge extends TechRebornContainer { + + EntityPlayer player; + + TileCentrifuge tile; + + 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)); + + 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)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return true; + } +} diff --git a/src/main/java/techreborn/client/gui/GuiCentrifuge.java b/src/main/java/techreborn/client/gui/GuiCentrifuge.java new file mode 100644 index 000000000..1d702a857 --- /dev/null +++ b/src/main/java/techreborn/client/gui/GuiCentrifuge.java @@ -0,0 +1,33 @@ +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 techreborn.client.container.ContainerCentrifuge; +import techreborn.tiles.TileCentrifuge; + +public class GuiCentrifuge extends GuiContainer { + + private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/centrifuge.png"); + + public GuiCentrifuge(EntityPlayer player, TileCentrifuge tileCentrifuge) { + super(new ContainerCentrifuge(tileCentrifuge, player)); + this.xSize = 176; + this.ySize = 167; + } + + @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); + } +} diff --git a/src/main/java/techreborn/init/ModBlocks.java b/src/main/java/techreborn/init/ModBlocks.java index bd0a6a1ff..7d9e33b0d 100644 --- a/src/main/java/techreborn/init/ModBlocks.java +++ b/src/main/java/techreborn/init/ModBlocks.java @@ -4,16 +4,13 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -import techreborn.blocks.BlockOre; -import techreborn.blocks.BlockQuantumChest; -import techreborn.blocks.BlockQuantumTank; -import techreborn.blocks.BlockStorage; -import techreborn.blocks.BlockThermalGenerator; +import techreborn.blocks.*; import techreborn.client.TechRebornCreativeTab; import techreborn.itemblocks.ItemBlockOre; import techreborn.itemblocks.ItemBlockQuantumChest; import techreborn.itemblocks.ItemBlockQuantumTank; import techreborn.itemblocks.ItemBlockStorage; +import techreborn.tiles.TileCentrifuge; import techreborn.tiles.TileQuantumChest; import techreborn.tiles.TileQuantumTank; import techreborn.tiles.TileThermalGenerator; @@ -25,6 +22,7 @@ public class ModBlocks { public static Block thermalGenerator; public static Block quantumTank; public static Block quantumChest; + public static Block centrifuge; public static Block ore; public static Block storage; @@ -41,6 +39,10 @@ public class ModBlocks { quantumChest = new BlockQuantumChest().setBlockName("techreborn.quantumChest").setBlockTextureName("techreborn:quantumChest").setCreativeTab(TechRebornCreativeTab.instance); GameRegistry.registerBlock(quantumChest, ItemBlockQuantumChest.class, "techreborn.quantumChest"); GameRegistry.registerTileEntity(TileQuantumChest.class, "TileQuantumChest"); + + centrifuge = new BlockCentrifuge().setBlockName("techreborn.centrifuge").setBlockTextureName("techreborn:centrifuge").setCreativeTab(TechRebornCreativeTab.instance); + GameRegistry.registerBlock(centrifuge, "techreborn.centrifuge"); + GameRegistry.registerTileEntity(TileCentrifuge.class, "TileCentrifuge"); ore = new BlockOre(Material.rock); GameRegistry.registerBlock(ore, ItemBlockOre.class, "techreborn.ore"); diff --git a/src/main/java/techreborn/tiles/TileCentrifuge.java b/src/main/java/techreborn/tiles/TileCentrifuge.java new file mode 100644 index 000000000..89ef83ea6 --- /dev/null +++ b/src/main/java/techreborn/tiles/TileCentrifuge.java @@ -0,0 +1,35 @@ +package techreborn.tiles; + +import ic2.api.energy.prefab.BasicSink; +import net.minecraft.nbt.NBTTagCompound; +import techreborn.util.Inventory; + +public class TileCentrifuge extends TileMachineBase { + + public BasicSink energy; + public Inventory inventory = new Inventory(6, "TileCentrifuge", 64); + + public TileCentrifuge() { + //TODO check values, + config + energy = new BasicSink(this, 100000, 1); + } + + + @Override + public void updateEntity() { + super.updateEntity(); + energy.updateEntity(); + } + + @Override + public void readFromNBT(NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + inventory.readFromNBT(tagCompound); + } + + @Override + public void writeToNBT(NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + inventory.writeToNBT(tagCompound); + } +} diff --git a/src/main/resources/assets/techreborn/lang/en_US.lang b/src/main/resources/assets/techreborn/lang/en_US.lang index 892230ca4..5298c4f80 100644 --- a/src/main/resources/assets/techreborn/lang/en_US.lang +++ b/src/main/resources/assets/techreborn/lang/en_US.lang @@ -3,6 +3,7 @@ itemGroup.techreborn=Tech Reborn tile.techreborn.thermalGenerator.name=Thermal Generator tile.techreborn.quantumTank.name=Quantum Tank tile.techreborn.quantumChest.name=Quantum Chest +tile.techreborn.centrifuge.name=Centrifuge #Ores tile.techreborn.ore.Galena.name=Galena Ore diff --git a/src/main/resources/assets/techreborn/textures/gui/centrifuge.png b/src/main/resources/assets/techreborn/textures/gui/centrifuge.png new file mode 100644 index 000000000..b0e64192c Binary files /dev/null and b/src/main/resources/assets/techreborn/textures/gui/centrifuge.png differ