marker code cleanup

This commit is contained in:
asiekierka 2015-06-30 19:06:12 +02:00
parent c7881b25dc
commit 7f197356b4
3 changed files with 20 additions and 16 deletions

View file

@ -37,6 +37,7 @@ import buildcraft.BuildCraftCore;
import buildcraft.api.core.BCLog;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.core.IInvSlot;
import buildcraft.api.core.IPathProvider;
import buildcraft.api.core.Position;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.robots.IRequestProvider;
@ -86,7 +87,7 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
private SimpleInventory inv = new SimpleInventory(28, "Builder", 64);
private BptBuilderBase currentBuilder;
private RecursiveBlueprintBuilder recursiveBuilder;
private LinkedList<BlockIndex> path;
private List<BlockIndex> path;
private ArrayList<RequirementItemStack> requiredToBuild;
private NBTTagCompound initNBT = null;
private boolean done = true;
@ -253,15 +254,19 @@ public class TileBuilder extends TileAbstractBuilder implements IHasWork, IFluid
for (int z = zCoord - 1; z <= zCoord + 1; ++z) {
TileEntity tile = worldObj.getTileEntity(x, y, z);
if (tile instanceof TilePathMarker) {
path = ((TilePathMarker) tile).getPath();
if (tile instanceof IPathProvider) {
path = ((IPathProvider) tile).getPath();
for (BlockIndex b : path) {
worldObj.setBlockToAir(b.x, b.y, b.z);
// TODO (7.1): Add API method for IPathProviders to remove
// themselves from world like IAreaProviders.
if (tile instanceof TilePathMarker) {
for (BlockIndex b : path) {
BuildCraftBuilders.pathMarkerBlock.dropBlockAsItem(
worldObj, b.x, b.y, b.z,
0, 0);
BuildCraftBuilders.pathMarkerBlock.dropBlockAsItem(
worldObj, b.x, b.y, b.z,
0, 0);
worldObj.setBlockToAir(b.x, b.y, b.z);
}
}
break;

View file

@ -78,11 +78,7 @@ public class TileFiller extends TileAbstractBuilder implements IHasWork, IContro
if (a != null) {
box.initialize(a);
if (a instanceof TileMarker) {
a.removeFromWorld();
}
a.removeFromWorld();
sendNetworkUpdate();
}

View file

@ -8,6 +8,7 @@
*/
package buildcraft.builders;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
@ -27,7 +28,7 @@ import buildcraft.core.LaserData;
public class TilePathMarker extends TileMarker implements IPathProvider {
// A list with the pathMarkers that aren't fully connected
// It only contains markers within the loaded chunks
private static LinkedList<TilePathMarker> availableMarkers = new LinkedList<TilePathMarker>();
private static ArrayList<TilePathMarker> availableMarkers = new ArrayList<TilePathMarker>();
public int x0, y0, z0, x1, y1, z1;
public boolean loadLink0 = false;
@ -143,9 +144,10 @@ public class TilePathMarker extends TileMarker implements IPathProvider {
}
}
public LinkedList<BlockIndex> getPath() {
@Override
public ArrayList<BlockIndex> getPath() {
HashSet<BlockIndex> visitedPaths = new HashSet<BlockIndex>();
LinkedList<BlockIndex> res = new LinkedList<BlockIndex>();
ArrayList<BlockIndex> res = new ArrayList<BlockIndex>();
TilePathMarker nextTile = this;
@ -275,6 +277,7 @@ public class TilePathMarker extends TileMarker implements IPathProvider {
@Override
public void onChunkUnload() {
super.onChunkUnload();
availableMarkers.remove(this);
}