Failing ;)

This commit is contained in:
Gig 2015-04-14 00:12:24 +01:00
parent 84ee22b859
commit 700276fb09
12 changed files with 387 additions and 1 deletions

View file

@ -0,0 +1,115 @@
package techreborn.api;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class RollingMachineRecipie {
ItemStack inputItem1, inputItem2, inputItem3, inputItem4 ,inputItem5, inputItem6,
inputItem7, inputItem8, inputItem9;
ItemStack output1;
int tickTime;
public RollingMachineRecipie(ItemStack inputItem1, ItemStack inputItem2, ItemStack inputItem3, ItemStack inputItem4,
ItemStack inputItem5, ItemStack inputItem6, ItemStack inputItem7, ItemStack inputItem8,ItemStack inputItem9,
ItemStack output1, int tickTime)
{
this.inputItem1 = inputItem1;
this.inputItem2 = inputItem2;
this.inputItem3 = inputItem3;
this.inputItem4 = inputItem4;
this.inputItem5 = inputItem5;
this.inputItem6 = inputItem6;
this.inputItem7 = inputItem7;
this.inputItem8 = inputItem8;
this.inputItem9 = inputItem9;
this.output1 = output1;
this.tickTime = tickTime;
}
public RollingMachineRecipie(Item inputItem1,Item inputItem2, Item inputItem3, Item inputItem4, Item inputItem5,
Item inputItem6, Item inputItem7, Item inputItem8, Item inputItem9, int inputAmount,
Item output1, int tickTime) {
this.inputItem1 = new ItemStack(inputItem1, inputAmount);
this.inputItem2 = new ItemStack(inputItem2, inputAmount);
this.inputItem3 = new ItemStack(inputItem3, inputAmount);
this.inputItem4 = new ItemStack(inputItem4, inputAmount);
this.inputItem5 = new ItemStack(inputItem5, inputAmount);
this.inputItem6 = new ItemStack(inputItem6, inputAmount);
this.inputItem7 = new ItemStack(inputItem7, inputAmount);
this.inputItem8 = new ItemStack(inputItem8, inputAmount);
this.inputItem9 = new ItemStack(inputItem9, inputAmount);
this.output1 = new ItemStack(output1);
this.tickTime = tickTime;
;
}
public RollingMachineRecipie(RollingMachineRecipie rollingmachineRecipie)
{
this.inputItem1 = rollingmachineRecipie.getInputItem1();
this.inputItem2 = rollingmachineRecipie.getInputItem2();
this.inputItem3 = rollingmachineRecipie.getInputItem3();
this.inputItem4 = rollingmachineRecipie.getInputItem4();
this.inputItem5 = rollingmachineRecipie.getInputItem5();
this.inputItem6 = rollingmachineRecipie.getInputItem6();
this.inputItem7 = rollingmachineRecipie.getInputItem7();
this.inputItem8 = rollingmachineRecipie.getInputItem8();
this.inputItem9 = rollingmachineRecipie.getInputItem9();
this.output1 = rollingmachineRecipie.getOutput1();
this.tickTime = rollingmachineRecipie.getTickTime();
}
public ItemStack getInputItem1()
{
return inputItem1;
}
public ItemStack getInputItem2()
{
return inputItem2;
}
public ItemStack getInputItem3()
{
return inputItem3;
}
public ItemStack getInputItem4()
{
return inputItem4;
}
public ItemStack getInputItem5()
{
return inputItem5;
}
public ItemStack getInputItem6()
{
return inputItem6;
}
public ItemStack getInputItem7()
{
return inputItem7;
}
public ItemStack getInputItem8()
{
return inputItem8;
}
public ItemStack getInputItem9()
{
return inputItem9;
}
public ItemStack getOutput1()
{
return output1;
}
public int getTickTime()
{
return tickTime;
}
}

View file

@ -7,6 +7,7 @@ import techreborn.util.ItemUtils;
public final class TechRebornAPI {
public static ArrayList<CentrifugeRecipie> centrifugeRecipies = new ArrayList<CentrifugeRecipie>();
public static ArrayList<RollingMachineRecipie> rollingmachineRecipes = new ArrayList<RollingMachineRecipie>();
public static void registerCentrifugeRecipe(CentrifugeRecipie recipie){
@ -24,8 +25,25 @@ public final class TechRebornAPI {
if(shouldAdd)
centrifugeRecipies.add(recipie);
}
public static void registerRollingMachineRecipe(RollingMachineRecipie recipie){
boolean shouldAdd = true;
for(CentrifugeRecipie centrifugeRecipie : centrifugeRecipies){
if(ItemUtils.isItemEqual(centrifugeRecipie.getInputItem(), recipie.getInputItem1(), false, true)){
try {
throw new RegisteredItemRecipe("Item " + recipie.getInputItem1().getUnlocalizedName() + " is already being used in a recipe for the RollingMachine");
} catch (RegisteredItemRecipe registeredItemRecipe) {
registeredItemRecipe.printStackTrace();
shouldAdd = false;
}
}
}
if(shouldAdd)
rollingmachineRecipes.add(recipie);
}
}
class RegisteredItemRecipe extends Exception
{
public RegisteredItemRecipe(String message)

View file

@ -0,0 +1,65 @@
package techreborn.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileRollingMachine;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockRollingMachine extends BlockContainer{
@SideOnly(Side.CLIENT)
private IIcon top;
@SideOnly(Side.CLIENT)
private IIcon other;
public BlockRollingMachine(Material material)
{
super(material.piston);
setCreativeTab(TechRebornCreativeTab.instance);
setBlockName("techreborn.rollingmachine");
setHardness(2f);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
{
return new TileRollingMachine();
}
@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.rollingMachineID, world, x, y, z);
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon)
{
top = icon.registerIcon("techreborn:rollingmachine_top");
other = icon.registerIcon("techreborn:rollingmachine_side");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int currentSide, int meta)
{
if (currentSide == 1) {
return top;
} else {
return other;
}
}
}

View file

@ -6,14 +6,17 @@ import net.minecraft.world.World;
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.GuiCentrifuge;
import techreborn.client.gui.GuiQuantumChest;
import techreborn.client.gui.GuiQuantumTank;
import techreborn.client.gui.GuiRollingMachine;
import techreborn.client.gui.GuiThermalGenerator;
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;
@ -23,6 +26,7 @@ public class GuiHandler implements IGuiHandler {
public static final int quantumTankID = 1;
public static final int quantumChestID = 2;
public static final int centrifugeID = 3;
public static final int rollingMachineID =4;
@Override
@ -35,6 +39,8 @@ public class GuiHandler implements IGuiHandler {
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);
}
return null;
@ -50,6 +56,8 @@ public class GuiHandler implements IGuiHandler {
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));
}
return null;
}

View file

@ -0,0 +1,50 @@
package techreborn.client.container;
import techreborn.client.SlotOutput;
import techreborn.tiles.TileCentrifuge;
import techreborn.tiles.TileRollingMachine;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
public class ContainerRollingMachine extends TechRebornContainer{
EntityPlayer player;
TileRollingMachine tile;
public ContainerRollingMachine(TileRollingMachine tileRollingmachine, EntityPlayer player){
tile = tileRollingmachine;
this.player = player;
//input
this.addSlotToContainer(new Slot(tileRollingmachine.inventory, 0, 30, 17));
this.addSlotToContainer(new Slot(tileRollingmachine.inventory, 1, 30, 35));
this.addSlotToContainer(new Slot(tileRollingmachine.inventory, 2, 30, 53));
this.addSlotToContainer(new Slot(tileRollingmachine.inventory, 3, 48, 17));
this.addSlotToContainer(new Slot(tileRollingmachine.inventory, 4, 48, 35));
this.addSlotToContainer(new Slot(tileRollingmachine.inventory, 5, 48, 53));
this.addSlotToContainer(new Slot(tileRollingmachine.inventory, 6, 66, 17));
this.addSlotToContainer(new Slot(tileRollingmachine.inventory, 7, 66, 35));
this.addSlotToContainer(new Slot(tileRollingmachine.inventory, 8, 66, 53));
//outputs
this.addSlotToContainer(new SlotOutput(tileRollingmachine.inventory, 9, 124, 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;
}
}

View file

@ -0,0 +1,33 @@
package techreborn.client.gui;
import techreborn.client.container.ContainerCentrifuge;
import techreborn.client.container.ContainerRollingMachine;
import techreborn.tiles.TileCentrifuge;
import techreborn.tiles.TileRollingMachine;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
public class GuiRollingMachine extends GuiContainer{
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;
}
@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

@ -0,0 +1,19 @@
package techreborn.compat.nei;
import codechicken.nei.recipe.TemplateRecipeHandler;
public class CentrifugeRecipieHandler extends TemplateRecipeHandler{
@Override
public String getRecipeName()
{
return "techreborn.centrifuge.recipe";
}
@Override
public String getGuiTexture()
{
return "techreborn:textures/gui/centrifuge.png";
}
}

View file

@ -0,0 +1,30 @@
package techreborn.compat.nei;
import techreborn.lib.ModInfo;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
public class NEIConfig implements IConfigureNEI{
@Override
public String getName()
{
return ModInfo.MOD_ID;
}
@Override
public String getVersion()
{
return ModInfo.MOD_VERSION;
}
@Override
public void loadConfig()
{
CentrifugeRecipieHandler centrifugeRecipieHandler = new CentrifugeRecipieHandler();
API.registerRecipeHandler(centrifugeRecipieHandler);
API.registerUsageHandler(centrifugeRecipieHandler);
}
}

View file

@ -13,6 +13,7 @@ import techreborn.itemblocks.ItemBlockStorage;
import techreborn.tiles.TileCentrifuge;
import techreborn.tiles.TileQuantumChest;
import techreborn.tiles.TileQuantumTank;
import techreborn.tiles.TileRollingMachine;
import techreborn.tiles.TileThermalGenerator;
import techreborn.util.LogHelper;
import cpw.mods.fml.common.registry.GameRegistry;
@ -23,6 +24,8 @@ public class ModBlocks {
public static Block quantumTank;
public static Block quantumChest;
public static Block centrifuge;
public static Block RollingMachine;
public static Block ore;
public static Block storage;
@ -43,7 +46,12 @@ public class ModBlocks {
centrifuge = new BlockCentrifuge().setBlockName("techreborn.centrifuge").setBlockTextureName("techreborn:centrifuge").setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(centrifuge, "techreborn.centrifuge");
GameRegistry.registerTileEntity(TileCentrifuge.class, "TileCentrifuge");
RollingMachine = new BlockRollingMachine(Material.piston);
GameRegistry.registerBlock(RollingMachine, "rollingmachine");
GameRegistry.registerTileEntity(TileRollingMachine.class, "TileRollingMachine");
ore = new BlockOre(Material.rock);
GameRegistry.registerBlock(ore, ItemBlockOre.class, "techreborn.ore");
LogHelper.info("TechReborns Blocks Loaded");

View file

@ -1,9 +1,12 @@
package techreborn.init;
import ic2.api.item.IC2Items;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import techreborn.api.CentrifugeRecipie;
import techreborn.api.RollingMachineRecipie;
import techreborn.api.TechRebornAPI;
import techreborn.config.ConfigTechReborn;
import techreborn.util.CraftingHelper;
@ -240,6 +243,7 @@ public class ModRecipes {
public static void addMachineRecipes()
{
TechRebornAPI.registerCentrifugeRecipe(new CentrifugeRecipie(Items.apple, 4, Items.beef, Items.baked_potato, null, null, 120, 4));
TechRebornAPI.registerRollingMachineRecipe(new RollingMachineRecipie(new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.furnace), 4));
LogHelper.info("Machine Recipes Added");
}

View file

@ -0,0 +1,36 @@
package techreborn.tiles;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import ic2.api.energy.prefab.BasicSink;
import techreborn.api.CentrifugeRecipie;
import techreborn.api.RollingMachineRecipie;
import techreborn.api.TechRebornAPI;
import techreborn.util.Inventory;
public class TileRollingMachine extends TileMachineBase {
public BasicSink energy;
public Inventory inventory = new Inventory(10, "TileRollingMachine", 64);
public boolean isRunning;
public int tickTime;
public RollingMachineRecipie currentRecipe;
public int euTick = 5;
public TileRollingMachine()
{
energy = new BasicSink(this, 100000, 1);
}
@Override
public void updateEntity()
{
super.updateEntity();
energy.updateEntity();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB