Finished core code for item tags, onto rendering!
This commit is contained in:
parent
61c7b3e4cd
commit
84f7bd1f85
6 changed files with 66 additions and 20 deletions
|
@ -26,10 +26,13 @@ public final class TransporterPathfinder
|
|||
|
||||
public Object3D lastFound;
|
||||
|
||||
public IdleDest(World world, TileEntityLogisticalTransporter tileEntity)
|
||||
public TransporterStack transportStack;
|
||||
|
||||
public IdleDest(World world, TileEntityLogisticalTransporter tileEntity, TransporterStack stack)
|
||||
{
|
||||
worldObj = world;
|
||||
start = tileEntity;
|
||||
transportStack = stack;
|
||||
}
|
||||
|
||||
public void loop(TileEntityLogisticalTransporter pointer)
|
||||
|
@ -79,13 +82,13 @@ public final class TransporterPathfinder
|
|||
public Object3D destination;
|
||||
public Object3D finalNode;
|
||||
|
||||
public ItemStack itemStack;
|
||||
public TransporterStack transportStack;
|
||||
|
||||
public Destination(World world, TileEntityLogisticalTransporter tileEntity, ItemStack stack)
|
||||
public Destination(World world, TileEntityLogisticalTransporter tileEntity, TransporterStack stack)
|
||||
{
|
||||
worldObj = world;
|
||||
start = tileEntity;
|
||||
itemStack = stack;
|
||||
transportStack = stack;
|
||||
}
|
||||
|
||||
public void loop(TileEntityLogisticalTransporter pointer)
|
||||
|
@ -101,14 +104,14 @@ public final class TransporterPathfinder
|
|||
{
|
||||
TileEntity tile = Object3D.get(pointer).getFromSide(side).getTileEntity(worldObj);
|
||||
|
||||
if(TransporterUtils.canInsert(tile, itemStack, side.ordinal()) && !(tile instanceof TileEntityLogisticalTransporter))
|
||||
if(TransporterUtils.canInsert(tile, transportStack.itemStack, side.ordinal()) && !(tile instanceof TileEntityLogisticalTransporter))
|
||||
{
|
||||
destination = Object3D.get(tile);
|
||||
finalNode = Object3D.get(pointer);
|
||||
return;
|
||||
}
|
||||
|
||||
if(tile instanceof TileEntityLogisticalTransporter && !iterated.contains(tile))
|
||||
if(transportStack.canInsert(tile) && !iterated.contains(tile))
|
||||
{
|
||||
loop((TileEntityLogisticalTransporter)tile);
|
||||
}
|
||||
|
@ -136,17 +139,20 @@ public final class TransporterPathfinder
|
|||
public final Object3D start;
|
||||
|
||||
public final Object3D finalNode;
|
||||
|
||||
public final TransporterStack transportStack;
|
||||
|
||||
public List<Object3D> results;
|
||||
|
||||
private World worldObj;
|
||||
|
||||
public Path(World world, Object3D node, Object3D startObj, Object3D finishObj)
|
||||
public Path(World world, Object3D node, Object3D startObj, Object3D finishObj, TransporterStack stack)
|
||||
{
|
||||
worldObj = world;
|
||||
finalNode = node;
|
||||
start = startObj;
|
||||
target = finishObj;
|
||||
transportStack = stack;
|
||||
|
||||
openSet = new HashSet<Object3D>();
|
||||
closedSet = new HashSet<Object3D>();
|
||||
|
@ -172,7 +178,7 @@ public final class TransporterPathfinder
|
|||
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
||||
Object3D neighbor = finalNode.translate(direction.offsetX, direction.offsetY, direction.offsetZ);
|
||||
|
||||
if(!(neighbor.getTileEntity(worldObj) instanceof TileEntityLogisticalTransporter))
|
||||
if(!transportStack.canInsert(neighbor.getTileEntity(worldObj)))
|
||||
{
|
||||
blockCount++;
|
||||
}
|
||||
|
@ -218,7 +224,7 @@ public final class TransporterPathfinder
|
|||
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
||||
Object3D neighbor = currentNode.getFromSide(direction);
|
||||
|
||||
if(neighbor.getTileEntity(worldObj) instanceof TileEntityLogisticalTransporter)
|
||||
if(transportStack.canInsert(neighbor.getTileEntity(worldObj)))
|
||||
{
|
||||
double tentativeG = gScore.get(currentNode) + currentNode.distanceTo(neighbor);
|
||||
|
||||
|
@ -280,23 +286,25 @@ public final class TransporterPathfinder
|
|||
}
|
||||
}
|
||||
|
||||
public static List<Object3D> getNewPath(TileEntityLogisticalTransporter start, ItemStack stack)
|
||||
public static List<Object3D> getNewPath(TileEntityLogisticalTransporter start, TransporterStack stack)
|
||||
{
|
||||
Destination d = new Destination(start.worldObj, start, stack);
|
||||
Object3D closest = d.find();
|
||||
|
||||
System.out.println(closest);
|
||||
|
||||
if(closest == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Path p = new Path(d.worldObj, d.finalNode, Object3D.get(start), closest);
|
||||
Path p = new Path(d.worldObj, d.finalNode, Object3D.get(start), closest, stack);
|
||||
return p.getPath();
|
||||
}
|
||||
|
||||
public static List<Object3D> getIdlePath(TileEntityLogisticalTransporter start)
|
||||
public static List<Object3D> getIdlePath(TileEntityLogisticalTransporter start, TransporterStack stack)
|
||||
{
|
||||
IdleDest d = new IdleDest(start.worldObj, start);
|
||||
IdleDest d = new IdleDest(start.worldObj, start, stack);
|
||||
Object3D farthest = d.find();
|
||||
|
||||
if(farthest == null || farthest.equals(Object3D.get(start)))
|
||||
|
@ -304,7 +312,7 @@ public final class TransporterPathfinder
|
|||
return null;
|
||||
}
|
||||
|
||||
Path p = new Path(start.worldObj, farthest, Object3D.get(start), null);
|
||||
Path p = new Path(start.worldObj, farthest, Object3D.get(start), null, stack);
|
||||
return p.getPath();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import mekanism.api.Object3D;
|
|||
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
|
@ -127,7 +128,7 @@ public class TransporterStack
|
|||
|
||||
public boolean recalculatePath(TileEntityLogisticalTransporter tileEntity)
|
||||
{
|
||||
List<Object3D> newPath = TransporterPathfinder.getNewPath(tileEntity, itemStack);
|
||||
List<Object3D> newPath = TransporterPathfinder.getNewPath(tileEntity, this);
|
||||
|
||||
if(newPath == null)
|
||||
{
|
||||
|
@ -144,7 +145,7 @@ public class TransporterStack
|
|||
|
||||
public void calculateIdle(TileEntityLogisticalTransporter tileEntity)
|
||||
{
|
||||
pathToTarget = TransporterPathfinder.getIdlePath(tileEntity);
|
||||
pathToTarget = TransporterPathfinder.getIdlePath(tileEntity, this);
|
||||
noTarget = true;
|
||||
originalLocation = Object3D.get(tileEntity);
|
||||
initiatedPath = true;
|
||||
|
@ -200,6 +201,17 @@ public class TransporterStack
|
|||
return 0;
|
||||
}
|
||||
|
||||
public boolean canInsert(TileEntity tileEntity)
|
||||
{
|
||||
if(!(tileEntity instanceof TileEntityLogisticalTransporter))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntityLogisticalTransporter transporter = (TileEntityLogisticalTransporter)tileEntity;
|
||||
return transporter.color == color || transporter.color == null;
|
||||
}
|
||||
|
||||
public Object3D getDest()
|
||||
{
|
||||
return pathToTarget.get(0);
|
||||
|
|
|
@ -68,6 +68,13 @@ public class ItemConfigurator extends ItemEnergized
|
|||
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Reset Electric Pump calculation."));
|
||||
return true;
|
||||
}
|
||||
else if(world.getBlockTileEntity(x, y, z) instanceof TileEntityLogisticalTransporter)
|
||||
{
|
||||
TileEntityLogisticalTransporter transporter = (TileEntityLogisticalTransporter)world.getBlockTileEntity(x, y, z);
|
||||
MekanismUtils.incrementColor(transporter);
|
||||
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Color bumped to: " + (transporter.color != null ? transporter.color.getName() : EnumColor.BLACK + "None")));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(world.getBlockTileEntity(x, y, z) instanceof TileEntityLogisticalTransporter)
|
||||
{
|
||||
|
@ -103,6 +110,7 @@ public class ItemConfigurator extends ItemEnergized
|
|||
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)config;
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), Object3D.get(tileEntity), 50D);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
|||
|
||||
if(!stack.isFinal(this))
|
||||
{
|
||||
if(next != null && next.getTileEntity(worldObj) instanceof TileEntityLogisticalTransporter)
|
||||
if(next != null && stack.canInsert(stack.getNext(this).getTileEntity(worldObj)))
|
||||
{
|
||||
needsSync = true;
|
||||
TileEntityLogisticalTransporter nextTile = (TileEntityLogisticalTransporter)next.getTileEntity(worldObj);
|
||||
|
@ -151,7 +151,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
|||
}
|
||||
}
|
||||
else {
|
||||
if(!(stack.getNext(this).getTileEntity(worldObj) instanceof TileEntityLogisticalTransporter))
|
||||
if(!stack.canInsert(stack.getNext(this).getTileEntity(worldObj)))
|
||||
{
|
||||
System.out.println("reached half, not final, next not transport");
|
||||
if(!recalculate(stack))
|
||||
|
@ -206,9 +206,8 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
|||
TransporterStack stack = new TransporterStack();
|
||||
stack.itemStack = itemStack;
|
||||
stack.originalLocation = original;
|
||||
stack.recalculatePath(this);
|
||||
|
||||
if(stack.hasPath())
|
||||
if(stack.recalculatePath(this))
|
||||
{
|
||||
transit.add(stack);
|
||||
return true;
|
||||
|
|
|
@ -36,6 +36,7 @@ import mekanism.common.network.PacketElectricChest.ElectricChestPacketType;
|
|||
import mekanism.common.tileentity.TileEntityBoundingBlock;
|
||||
import mekanism.common.tileentity.TileEntityDynamicTank;
|
||||
import mekanism.common.tileentity.TileEntityElectricChest;
|
||||
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
@ -1006,6 +1007,23 @@ public final class MekanismUtils
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void incrementColor(TileEntityLogisticalTransporter tileEntity)
|
||||
{
|
||||
if(tileEntity.color == null)
|
||||
{
|
||||
tileEntity.color = EnumColor.values()[1];
|
||||
return;
|
||||
}
|
||||
else if(tileEntity.color.ordinal() == EnumColor.values().length-1)
|
||||
{
|
||||
tileEntity.color = null;
|
||||
return;
|
||||
}
|
||||
|
||||
int ordinal = tileEntity.color.ordinal();
|
||||
tileEntity.color = EnumColor.values()[ordinal+1];
|
||||
}
|
||||
|
||||
public static enum ResourceType
|
||||
{
|
||||
GUI("gui"),
|
||||
|
|
|
@ -2,6 +2,7 @@ package mekanism.common.util;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
|
|
Loading…
Reference in a new issue