Added the basic gui, block and tile for the centrifuge
This commit is contained in:
parent
2b0fd80def
commit
bd357e0a2c
8 changed files with 159 additions and 5 deletions
30
src/main/java/techreborn/blocks/BlockCentrifuge.java
Normal file
30
src/main/java/techreborn/blocks/BlockCentrifuge.java
Normal file
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
33
src/main/java/techreborn/client/gui/GuiCentrifuge.java
Normal file
33
src/main/java/techreborn/client/gui/GuiCentrifuge.java
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
@ -42,6 +40,10 @@ public class ModBlocks {
|
|||
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");
|
||||
LogHelper.info("TechReborns Blocks Loaded");
|
||||
|
|
35
src/main/java/techreborn/tiles/TileCentrifuge.java
Normal file
35
src/main/java/techreborn/tiles/TileCentrifuge.java
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
BIN
src/main/resources/assets/techreborn/textures/gui/centrifuge.png
Normal file
BIN
src/main/resources/assets/techreborn/textures/gui/centrifuge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Loading…
Add table
Reference in a new issue