I have some ideas for upgrade items- so that I can get people off their Advanced Machine dependency. Unfortunately at present it looks like there's no way to hook TileEntityMachine when there are upgrade items.
What I would like to be able to do is create new "Upgrader" items, probably event driven, with visibility into the base TileEntityMachine.
Here's a simple proposal.
Code
public interface MachineUpgradeItem {
/** Called with the current itemstack when the upgrade stack is modified
* Returns true if this is now a locked slot (cannot have more inserted)
*/
public boolean installUpgradeItem(ItemStack upgradeItemStack, TileEntityMachine machine);
/** Called to compute the current effect of this stack on the machine. Generally would set the overclock rate and maybe have other effects.
* Returns maybe a new value for some parameter?
*/
public int evaluateOverclock(ItemStack upgradeItemStack, TileEntityMachine machine);
/** Called whenever an operation cycle is about to start (new item being smelted or something)
* This should come before the machine decides if it wants to smelt something - so I could insert something into the machine at the last second.
* Returns true if the operation can proceed.
*/
public boolean beforeOperation(ItemStack upgradeItemStack, TileEntityMachine machine);
/** Called after an operation cycle is complete. (Item has finished smelting for example).
* This allows for me to e.g. remove the item from the machine and put it somewhere else.
*/
public boolean afterOperation(ItemStack upgradeItemStack, TileEntityMachine machine);
}
Display More
This is just a sketch of an idea for a new API to support modders creating new upgrade items without having to hack base IC2 code. Thoughts?