More AI additions
This commit is contained in:
parent
38a391c496
commit
990c58fef7
5 changed files with 83 additions and 42 deletions
|
@ -21,11 +21,6 @@ public class ALCommonProxy implements IGuiHandler
|
|||
|
||||
}
|
||||
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
|
|
|
@ -68,33 +68,30 @@ public class AssemblyLine
|
|||
@Init
|
||||
public void load(FMLInitializationEvent evt)
|
||||
{
|
||||
proxy.init();
|
||||
|
||||
GameRegistry.registerTileEntity(TileEntityConveyorBelt.class, "ConveyorBelt");
|
||||
GameRegistry.registerTileEntity(TileEntitySorter.class, "Sorter");
|
||||
GameRegistry.registerTileEntity(TileEntityManipulator.class, "Manipulator");
|
||||
proxy.init();
|
||||
// Names
|
||||
|
||||
// Add Names
|
||||
LanguageRegistry.addName(new ItemStack(blockConveyorBelt, 1), "Conveyor Belt");
|
||||
LanguageRegistry.addName(new ItemStack(blockInteraction, 1, MachineType.SORTER.metadata), MachineType.SORTER.name);
|
||||
LanguageRegistry.addName(new ItemStack(blockInteraction, 1, MachineType.MANIPULATOR.metadata), MachineType.MANIPULATOR.name);
|
||||
LanguageRegistry.addName(new ItemStack(blockInteraction, 1, 8), "FutureBlock");
|
||||
LanguageRegistry.addName(new ItemStack(blockInteraction, 1, 12), "FutureBlock");
|
||||
|
||||
for(MachineType type : MachineType.values())
|
||||
{
|
||||
LanguageRegistry.addName(new ItemStack(blockInteraction, 1, type.metadata), type.name);
|
||||
}
|
||||
|
||||
@PostInit
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
// Conveyor Belt
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt), new Object[]
|
||||
{ "III", "MCM", 'I', Item.ingotIron, 'M', "motor", 'C', "basicCircuit" }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 2), new Object[]
|
||||
{ "III", "WMW", 'I', "ingotSteel", 'W', Block.wood, 'M', "motor" }));
|
||||
|
||||
// Rejector
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockInteraction, 1, 0), new Object[]
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockInteraction, 1, MachineType.SORTER.metadata), new Object[]
|
||||
{ "WPW", "@R@", '@', "plateSteel", 'R', Item.redstone, 'P', Block.pistonBase, 'C', "basicCircuit", 'W', "copperWire" }));
|
||||
|
||||
// Retriever
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(blockInteraction, 1, 4), new Object[]
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(blockInteraction, 1, MachineType.MANIPULATOR.metadata), new Object[]
|
||||
{ Block.dispenser, "basicCircuit" }));
|
||||
proxy.postInit();
|
||||
}
|
||||
|
||||
}
|
|
@ -13,40 +13,38 @@ public abstract class Task
|
|||
{
|
||||
protected int ticks;
|
||||
|
||||
/**
|
||||
* The TileEntity that is doing this task.
|
||||
*/
|
||||
public TileEntity handler;
|
||||
|
||||
private boolean shouldExecute = true;
|
||||
|
||||
public Task(TileEntity handler)
|
||||
{
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a task is being done.
|
||||
*
|
||||
* @param ticks
|
||||
* - The amount of ticks this task
|
||||
* The amount of ticks this task
|
||||
* has been elapsed for.
|
||||
* @return Return true if the task is not
|
||||
* finished and false if it is.
|
||||
*/
|
||||
protected void doTask()
|
||||
protected boolean doTask()
|
||||
{
|
||||
this.ticks++;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void resetTask()
|
||||
public void onTaskStart()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void onTaskEnd()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void setTileEntity(TileEntity tileEntity);
|
||||
|
||||
/**
|
||||
* @return Whether the task should keep
|
||||
* executing.
|
||||
* @return The tick interval of this task.
|
||||
* Return 0 for no ticks.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
public int getTickInterval()
|
||||
{
|
||||
return this.shouldExecute;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
51
src/common/assemblyline/ai/TileEntityAI.java
Normal file
51
src/common/assemblyline/ai/TileEntityAI.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
package assemblyline.ai;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
import universalelectricity.prefab.TileEntityAdvanced;
|
||||
|
||||
public class TileEntityAI extends TileEntityAdvanced
|
||||
{
|
||||
private final List<Task> tasks = new ArrayList<Task>();
|
||||
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
/**
|
||||
* Loop through each task and do them.
|
||||
*/
|
||||
try
|
||||
{
|
||||
for (Task task : this.tasks)
|
||||
{
|
||||
if (task.getTickInterval() > 0)
|
||||
{
|
||||
if (this.ticks % task.getTickInterval() == 0)
|
||||
{
|
||||
if (!task.doTask())
|
||||
{
|
||||
task.onTaskEnd();
|
||||
tasks.remove(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.severe("Failed to execute task in Assembly Line.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addTask(Task task)
|
||||
{
|
||||
task.setTileEntity(this);
|
||||
task.onTaskStart();
|
||||
tasks.add(task);
|
||||
}
|
||||
}
|
|
@ -46,7 +46,7 @@ public class ContainerCrafter extends Container
|
|||
@Override
|
||||
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue