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 Object3D lastFound;
|
||||||
|
|
||||||
public IdleDest(World world, TileEntityLogisticalTransporter tileEntity)
|
public TransporterStack transportStack;
|
||||||
|
|
||||||
|
public IdleDest(World world, TileEntityLogisticalTransporter tileEntity, TransporterStack stack)
|
||||||
{
|
{
|
||||||
worldObj = world;
|
worldObj = world;
|
||||||
start = tileEntity;
|
start = tileEntity;
|
||||||
|
transportStack = stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loop(TileEntityLogisticalTransporter pointer)
|
public void loop(TileEntityLogisticalTransporter pointer)
|
||||||
|
@ -79,13 +82,13 @@ public final class TransporterPathfinder
|
||||||
public Object3D destination;
|
public Object3D destination;
|
||||||
public Object3D finalNode;
|
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;
|
worldObj = world;
|
||||||
start = tileEntity;
|
start = tileEntity;
|
||||||
itemStack = stack;
|
transportStack = stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loop(TileEntityLogisticalTransporter pointer)
|
public void loop(TileEntityLogisticalTransporter pointer)
|
||||||
|
@ -101,14 +104,14 @@ public final class TransporterPathfinder
|
||||||
{
|
{
|
||||||
TileEntity tile = Object3D.get(pointer).getFromSide(side).getTileEntity(worldObj);
|
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);
|
destination = Object3D.get(tile);
|
||||||
finalNode = Object3D.get(pointer);
|
finalNode = Object3D.get(pointer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tile instanceof TileEntityLogisticalTransporter && !iterated.contains(tile))
|
if(transportStack.canInsert(tile) && !iterated.contains(tile))
|
||||||
{
|
{
|
||||||
loop((TileEntityLogisticalTransporter)tile);
|
loop((TileEntityLogisticalTransporter)tile);
|
||||||
}
|
}
|
||||||
|
@ -137,16 +140,19 @@ public final class TransporterPathfinder
|
||||||
|
|
||||||
public final Object3D finalNode;
|
public final Object3D finalNode;
|
||||||
|
|
||||||
|
public final TransporterStack transportStack;
|
||||||
|
|
||||||
public List<Object3D> results;
|
public List<Object3D> results;
|
||||||
|
|
||||||
private World worldObj;
|
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;
|
worldObj = world;
|
||||||
finalNode = node;
|
finalNode = node;
|
||||||
start = startObj;
|
start = startObj;
|
||||||
target = finishObj;
|
target = finishObj;
|
||||||
|
transportStack = stack;
|
||||||
|
|
||||||
openSet = new HashSet<Object3D>();
|
openSet = new HashSet<Object3D>();
|
||||||
closedSet = new HashSet<Object3D>();
|
closedSet = new HashSet<Object3D>();
|
||||||
|
@ -172,7 +178,7 @@ public final class TransporterPathfinder
|
||||||
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
||||||
Object3D neighbor = finalNode.translate(direction.offsetX, direction.offsetY, direction.offsetZ);
|
Object3D neighbor = finalNode.translate(direction.offsetX, direction.offsetY, direction.offsetZ);
|
||||||
|
|
||||||
if(!(neighbor.getTileEntity(worldObj) instanceof TileEntityLogisticalTransporter))
|
if(!transportStack.canInsert(neighbor.getTileEntity(worldObj)))
|
||||||
{
|
{
|
||||||
blockCount++;
|
blockCount++;
|
||||||
}
|
}
|
||||||
|
@ -218,7 +224,7 @@ public final class TransporterPathfinder
|
||||||
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
ForgeDirection direction = ForgeDirection.getOrientation(i);
|
||||||
Object3D neighbor = currentNode.getFromSide(direction);
|
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);
|
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);
|
Destination d = new Destination(start.worldObj, start, stack);
|
||||||
Object3D closest = d.find();
|
Object3D closest = d.find();
|
||||||
|
|
||||||
|
System.out.println(closest);
|
||||||
|
|
||||||
if(closest == null)
|
if(closest == null)
|
||||||
{
|
{
|
||||||
return 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();
|
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();
|
Object3D farthest = d.find();
|
||||||
|
|
||||||
if(farthest == null || farthest.equals(Object3D.get(start)))
|
if(farthest == null || farthest.equals(Object3D.get(start)))
|
||||||
|
@ -304,7 +312,7 @@ public final class TransporterPathfinder
|
||||||
return null;
|
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();
|
return p.getPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import mekanism.api.Object3D;
|
||||||
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
|
@ -127,7 +128,7 @@ public class TransporterStack
|
||||||
|
|
||||||
public boolean recalculatePath(TileEntityLogisticalTransporter tileEntity)
|
public boolean recalculatePath(TileEntityLogisticalTransporter tileEntity)
|
||||||
{
|
{
|
||||||
List<Object3D> newPath = TransporterPathfinder.getNewPath(tileEntity, itemStack);
|
List<Object3D> newPath = TransporterPathfinder.getNewPath(tileEntity, this);
|
||||||
|
|
||||||
if(newPath == null)
|
if(newPath == null)
|
||||||
{
|
{
|
||||||
|
@ -144,7 +145,7 @@ public class TransporterStack
|
||||||
|
|
||||||
public void calculateIdle(TileEntityLogisticalTransporter tileEntity)
|
public void calculateIdle(TileEntityLogisticalTransporter tileEntity)
|
||||||
{
|
{
|
||||||
pathToTarget = TransporterPathfinder.getIdlePath(tileEntity);
|
pathToTarget = TransporterPathfinder.getIdlePath(tileEntity, this);
|
||||||
noTarget = true;
|
noTarget = true;
|
||||||
originalLocation = Object3D.get(tileEntity);
|
originalLocation = Object3D.get(tileEntity);
|
||||||
initiatedPath = true;
|
initiatedPath = true;
|
||||||
|
@ -200,6 +201,17 @@ public class TransporterStack
|
||||||
return 0;
|
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()
|
public Object3D getDest()
|
||||||
{
|
{
|
||||||
return pathToTarget.get(0);
|
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."));
|
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Reset Electric Pump calculation."));
|
||||||
return true;
|
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)
|
else if(world.getBlockTileEntity(x, y, z) instanceof TileEntityLogisticalTransporter)
|
||||||
{
|
{
|
||||||
|
@ -103,6 +110,7 @@ public class ItemConfigurator extends ItemEnergized
|
||||||
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)config;
|
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)config;
|
||||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), Object3D.get(tileEntity), 50D);
|
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), Object3D.get(tileEntity), 50D);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
||||||
|
|
||||||
if(!stack.isFinal(this))
|
if(!stack.isFinal(this))
|
||||||
{
|
{
|
||||||
if(next != null && next.getTileEntity(worldObj) instanceof TileEntityLogisticalTransporter)
|
if(next != null && stack.canInsert(stack.getNext(this).getTileEntity(worldObj)))
|
||||||
{
|
{
|
||||||
needsSync = true;
|
needsSync = true;
|
||||||
TileEntityLogisticalTransporter nextTile = (TileEntityLogisticalTransporter)next.getTileEntity(worldObj);
|
TileEntityLogisticalTransporter nextTile = (TileEntityLogisticalTransporter)next.getTileEntity(worldObj);
|
||||||
|
@ -151,7 +151,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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");
|
System.out.println("reached half, not final, next not transport");
|
||||||
if(!recalculate(stack))
|
if(!recalculate(stack))
|
||||||
|
@ -206,9 +206,8 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
||||||
TransporterStack stack = new TransporterStack();
|
TransporterStack stack = new TransporterStack();
|
||||||
stack.itemStack = itemStack;
|
stack.itemStack = itemStack;
|
||||||
stack.originalLocation = original;
|
stack.originalLocation = original;
|
||||||
stack.recalculatePath(this);
|
|
||||||
|
|
||||||
if(stack.hasPath())
|
if(stack.recalculatePath(this))
|
||||||
{
|
{
|
||||||
transit.add(stack);
|
transit.add(stack);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -36,6 +36,7 @@ import mekanism.common.network.PacketElectricChest.ElectricChestPacketType;
|
||||||
import mekanism.common.tileentity.TileEntityBoundingBlock;
|
import mekanism.common.tileentity.TileEntityBoundingBlock;
|
||||||
import mekanism.common.tileentity.TileEntityDynamicTank;
|
import mekanism.common.tileentity.TileEntityDynamicTank;
|
||||||
import mekanism.common.tileentity.TileEntityElectricChest;
|
import mekanism.common.tileentity.TileEntityElectricChest;
|
||||||
|
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
@ -1006,6 +1007,23 @@ public final class MekanismUtils
|
||||||
return false;
|
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
|
public static enum ResourceType
|
||||||
{
|
{
|
||||||
GUI("gui"),
|
GUI("gui"),
|
||||||
|
|
|
@ -2,6 +2,7 @@ package mekanism.common.util;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import mekanism.api.EnumColor;
|
||||||
import mekanism.api.Object3D;
|
import mekanism.api.Object3D;
|
||||||
import mekanism.api.transmitters.ITransmitter;
|
import mekanism.api.transmitters.ITransmitter;
|
||||||
import mekanism.api.transmitters.TransmissionType;
|
import mekanism.api.transmitters.TransmissionType;
|
||||||
|
|
Loading…
Reference in a new issue