Factory Installers are done!
This commit is contained in:
parent
274930fd8a
commit
abd581b2f1
6 changed files with 173 additions and 8 deletions
|
@ -463,6 +463,15 @@ public class Mekanism
|
|||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock2, 2, 2), new Object[] {
|
||||
" I ", "ICI", " I ", Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock2, 1, 1), Character.valueOf('C'), "circuitBasic"
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(MekanismItems.FactoryInstaller, 1, 0), new Object[] {
|
||||
"RCR", "iWi", "RCR", Character.valueOf('R'), "alloyBasic", Character.valueOf('C'), "circuitBasic", Character.valueOf('i'), "ingotIron", Character.valueOf('W'), "plankWood"
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(MekanismItems.FactoryInstaller, 1, 1), new Object[] {
|
||||
"ECE", "oWo", "ECE", Character.valueOf('E'), "alloyAdvanced", Character.valueOf('C'), "circuitAdvanced", Character.valueOf('o'), "ingotOsmium", Character.valueOf('W'), "plankWood"
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(MekanismItems.FactoryInstaller, 1, 2), new Object[] {
|
||||
"RCR", "gWg", "RCR", Character.valueOf('R'), "alloyElite", Character.valueOf('C'), "circuitElite", Character.valueOf('g'), "ingotGold", Character.valueOf('W'), "plankWood"
|
||||
}));
|
||||
|
||||
//Energy Cube recipes
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), new Object[] {
|
||||
|
|
|
@ -5,7 +5,9 @@ import java.util.List;
|
|||
import mekanism.common.Tier.BaseTier;
|
||||
import mekanism.common.Tier.FactoryTier;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.tile.TileEntityAdvancedElectricMachine;
|
||||
import mekanism.common.tile.TileEntityBasicBlock;
|
||||
import mekanism.common.tile.TileEntityElectricMachine;
|
||||
import mekanism.common.tile.TileEntityFactory;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
@ -80,7 +82,28 @@ public class ItemFactoryInstaller extends ItemMekanism
|
|||
|
||||
if(type != null)
|
||||
{
|
||||
|
||||
if(tile instanceof TileEntityElectricMachine)
|
||||
{
|
||||
((TileEntityElectricMachine)tile).upgrade(type);
|
||||
|
||||
if(!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(tile instanceof TileEntityAdvancedElectricMachine)
|
||||
{
|
||||
((TileEntityAdvancedElectricMachine)tile).upgrade(type);
|
||||
|
||||
if(!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,24 @@
|
|||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.AdvancedMachineInput;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
|
@ -23,14 +30,10 @@ import mekanism.common.util.InventoryUtils;
|
|||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import mekanism.common.util.StatUtils;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
|
@ -82,6 +85,66 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
|||
upgradeComponent = new TileComponentUpgrade(this, 4);
|
||||
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(3));
|
||||
}
|
||||
|
||||
public void upgrade(RecipeType type)
|
||||
{
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
worldObj.setBlock(xCoord, yCoord, zCoord, MekanismBlocks.MachineBlock, 5, 3);
|
||||
|
||||
TileEntityFactory factory = (TileEntityFactory)worldObj.getTileEntity(xCoord, yCoord, zCoord);
|
||||
|
||||
//Basic
|
||||
factory.facing = facing;
|
||||
factory.clientFacing = clientFacing;
|
||||
factory.ticker = ticker;
|
||||
factory.redstone = redstone;
|
||||
factory.redstoneLastTick = redstoneLastTick;
|
||||
factory.doAutoSync = doAutoSync;
|
||||
factory.components = components;
|
||||
|
||||
//Electric
|
||||
factory.electricityStored = electricityStored;
|
||||
factory.ic2Registered = ic2Registered;
|
||||
|
||||
//Noisy
|
||||
factory.soundURL = soundURL;
|
||||
factory.sound = sound;
|
||||
|
||||
//Machine
|
||||
factory.sideConfig = sideConfig;
|
||||
factory.progress[0] = operatingTicks;
|
||||
factory.updateDelay = updateDelay;
|
||||
factory.isActive = isActive;
|
||||
factory.clientActive = clientActive;
|
||||
factory.controlType = controlType;
|
||||
factory.prevEnergy = prevEnergy;
|
||||
factory.upgradeComponent = upgradeComponent;
|
||||
factory.upgradeComponent.setUpgradeSlot(0);
|
||||
factory.upgradeComponent.tileEntity = factory;
|
||||
factory.ejectorComponent = ejectorComponent;
|
||||
factory.ejectorComponent.sideData = factory.sideOutputs.get(5);
|
||||
factory.ejectorComponent.tileEntity = factory;
|
||||
factory.recipeType = type;
|
||||
|
||||
//Advanced Machine
|
||||
factory.gasTank.setGas(gasTank.getGas());
|
||||
|
||||
factory.inventory[5] = inventory[0];
|
||||
factory.inventory[4] = inventory[1];
|
||||
factory.inventory[5+3] = inventory[2];
|
||||
factory.inventory[1] = inventory[3];
|
||||
factory.inventory[0] = inventory[4];
|
||||
|
||||
for(Upgrade upgrade : upgradeComponent.getSupportedTypes())
|
||||
{
|
||||
factory.recalculateUpgradables(upgrade);
|
||||
}
|
||||
|
||||
factory.upgraded = true;
|
||||
|
||||
factory.markDirty();
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(factory), factory.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(factory)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of ticks the declared itemstack can fuel this machine.
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
package mekanism.common.tile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.machines.BasicMachineRecipe;
|
||||
|
@ -14,10 +22,8 @@ import mekanism.common.util.ChargeUtils;
|
|||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
|
@ -51,6 +57,62 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
|||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(3));
|
||||
}
|
||||
|
||||
public void upgrade(RecipeType type)
|
||||
{
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
worldObj.setBlock(xCoord, yCoord, zCoord, MekanismBlocks.MachineBlock, 5, 3);
|
||||
|
||||
TileEntityFactory factory = (TileEntityFactory)worldObj.getTileEntity(xCoord, yCoord, zCoord);
|
||||
|
||||
//Basic
|
||||
factory.facing = facing;
|
||||
factory.clientFacing = clientFacing;
|
||||
factory.ticker = ticker;
|
||||
factory.redstone = redstone;
|
||||
factory.redstoneLastTick = redstoneLastTick;
|
||||
factory.doAutoSync = doAutoSync;
|
||||
factory.components = components;
|
||||
|
||||
//Electric
|
||||
factory.electricityStored = electricityStored;
|
||||
factory.ic2Registered = ic2Registered;
|
||||
|
||||
//Noisy
|
||||
factory.soundURL = soundURL;
|
||||
factory.sound = sound;
|
||||
|
||||
//Machine
|
||||
factory.sideConfig = sideConfig;
|
||||
factory.progress[0] = operatingTicks;
|
||||
factory.updateDelay = updateDelay;
|
||||
factory.isActive = isActive;
|
||||
factory.clientActive = clientActive;
|
||||
factory.controlType = controlType;
|
||||
factory.prevEnergy = prevEnergy;
|
||||
factory.upgradeComponent = upgradeComponent;
|
||||
factory.upgradeComponent.setUpgradeSlot(0);
|
||||
factory.upgradeComponent.tileEntity = factory;
|
||||
factory.ejectorComponent = ejectorComponent;
|
||||
factory.ejectorComponent.sideData = factory.sideOutputs.get(5);
|
||||
factory.ejectorComponent.tileEntity = factory;
|
||||
factory.recipeType = type;
|
||||
|
||||
factory.inventory[5] = inventory[0];
|
||||
factory.inventory[1] = inventory[1];
|
||||
factory.inventory[5+3] = inventory[2];
|
||||
factory.inventory[0] = inventory[3];
|
||||
|
||||
for(Upgrade upgrade : upgradeComponent.getSupportedTypes())
|
||||
{
|
||||
factory.recalculateUpgradables(upgrade);
|
||||
}
|
||||
|
||||
factory.upgraded = true;
|
||||
|
||||
factory.markDirty();
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(factory), factory.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(factory)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
|
|
|
@ -186,7 +186,10 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
factory.sounds = sounds;
|
||||
factory.controlType = controlType;
|
||||
factory.upgradeComponent = upgradeComponent;
|
||||
factory.upgradeComponent.tileEntity = factory;
|
||||
factory.ejectorComponent = ejectorComponent;
|
||||
factory.ejectorComponent.tileEntity = factory;
|
||||
factory.ejectorComponent.sideData = factory.sideOutputs.get(5);
|
||||
|
||||
for(int i = 0; i < tier.processes+5; i++)
|
||||
{
|
||||
|
@ -212,7 +215,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
|
||||
factory.upgraded = true;
|
||||
|
||||
markDirty();
|
||||
factory.markDirty();
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(factory), factory.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(factory)));
|
||||
}
|
||||
|
||||
|
|
|
@ -88,6 +88,11 @@ public class TileComponentUpgrade implements ITileComponent
|
|||
{
|
||||
return upgradeSlot;
|
||||
}
|
||||
|
||||
public void setUpgradeSlot(int i)
|
||||
{
|
||||
upgradeSlot = i;
|
||||
}
|
||||
|
||||
public int getScaledUpgradeProgress(int i)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue