Began work on automatic machine item ejection (much smaller project than transporters!)
This commit is contained in:
parent
6837b1fb66
commit
2c49ca40ed
44
common/mekanism/common/TileComponentEjector.java
Normal file
44
common/mekanism/common/TileComponentEjector.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package mekanism.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.SideData;
|
||||
import mekanism.common.tileentity.TileEntityContainerBlock;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileComponentEjector implements ITileComponent
|
||||
{
|
||||
public TileEntityContainerBlock tileEntity;
|
||||
|
||||
public SideData sideData;
|
||||
|
||||
public TileComponentEjector(TileEntityContainerBlock tile, SideData data)
|
||||
{
|
||||
tileEntity = tile;
|
||||
sideData = data;
|
||||
|
||||
tile.components.add(this);
|
||||
}
|
||||
|
||||
public void onOutput()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound nbtTags) {}
|
||||
|
||||
@Override
|
||||
public void read(ByteArrayDataInput dataStream) {}
|
||||
|
||||
@Override
|
||||
public void write(NBTTagCompound nbtTags) {}
|
||||
|
||||
@Override
|
||||
public void write(ArrayList data) {}
|
||||
}
|
|
@ -8,6 +8,7 @@ import mekanism.api.SideData;
|
|||
import mekanism.api.gas.EnumGas;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.RecipeHandler;
|
||||
import mekanism.common.TileComponentEjector;
|
||||
import mekanism.common.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
@ -64,6 +65,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
MAX_SECONDARY_ENERGY = maxSecondaryEnergy;
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 4);
|
||||
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(3));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,6 +187,8 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
else {
|
||||
inventory[2].stackSize += itemstack.stackSize;
|
||||
}
|
||||
|
||||
ejectorComponent.onOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -92,7 +92,11 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench
|
|||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
facing = nbtTags.getInteger("facing");
|
||||
|
||||
if(nbtTags.hasKey("facing"))
|
||||
{
|
||||
facing = nbtTags.getInteger("facing");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,8 +15,9 @@ import mekanism.common.IRedstoneControl;
|
|||
import mekanism.common.IUpgradeTile;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.TileComponentUpgrade;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.TileComponentEjector;
|
||||
import mekanism.common.TileComponentUpgrade;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -65,6 +66,7 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent;
|
||||
public TileComponentEjector ejectorComponent;
|
||||
|
||||
/**
|
||||
* The foundation of all machines - a simple tile entity with a facing, active state, initialized state, sound effect, and animated texture.
|
||||
|
|
|
@ -4,6 +4,7 @@ import mekanism.api.EnumColor;
|
|||
import mekanism.api.SideData;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.RecipeHandler;
|
||||
import mekanism.common.TileComponentEjector;
|
||||
import mekanism.common.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
@ -40,6 +41,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
|
|||
inventory = new ItemStack[4];
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(3));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -119,6 +121,8 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
|
|||
else {
|
||||
inventory[2].stackSize += itemstack.stackSize;
|
||||
}
|
||||
|
||||
ejectorComponent.onOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,14 +11,15 @@ import mekanism.api.SideData;
|
|||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.client.sound.IHasSound;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.IFactory.RecipeType;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
import mekanism.common.IUpgradeTile;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.TileComponentUpgrade;
|
||||
import mekanism.common.IFactory.RecipeType;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.Tier.FactoryTier;
|
||||
import mekanism.common.TileComponentEjector;
|
||||
import mekanism.common.TileComponentUpgrade;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
|
@ -76,6 +77,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
public TileComponentEjector ejectorComponent;
|
||||
|
||||
public TileEntityFactory()
|
||||
{
|
||||
|
@ -96,6 +98,8 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
inventory = new ItemStack[4+type.processes*2];
|
||||
progress = new int[type.processes];
|
||||
isActive = false;
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(4));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -385,6 +389,8 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
else {
|
||||
inventory[outputSlot].stackSize += itemstack.stackSize;
|
||||
}
|
||||
|
||||
ejectorComponent.onOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,10 +20,11 @@ import mekanism.common.IRedstoneControl;
|
|||
import mekanism.common.IUpgradeTile;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.RecipeHandler;
|
||||
import mekanism.common.TileComponentUpgrade;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.RecipeHandler;
|
||||
import mekanism.common.RecipeHandler.Recipe;
|
||||
import mekanism.common.TileComponentEjector;
|
||||
import mekanism.common.TileComponentUpgrade;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
|
@ -78,6 +79,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
public TileComponentEjector ejectorComponent;
|
||||
|
||||
public TileEntityMetallurgicInfuser()
|
||||
{
|
||||
|
@ -91,6 +93,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {4}));
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(4));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -255,6 +258,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
else {
|
||||
inventory[3].stackSize += output.resource.stackSize;
|
||||
}
|
||||
|
||||
ejectorComponent.onOutput();
|
||||
}
|
||||
|
||||
public boolean canOperate()
|
||||
|
|
Loading…
Reference in a new issue