Rewrote pathfinder, added in Restrictive Transporters, added option to have null color in filters, added default outputting filter for sorter

whoo!
This commit is contained in:
Aidan C. Brady 2013-10-29 18:13:30 -04:00
parent 013a2a7aa4
commit 9496f7dfa3
18 changed files with 379 additions and 313 deletions

View file

@ -51,8 +51,6 @@ public class GuiItemStackFilter extends GuiMekanism
tileEntity = tentity;
isNew = true;
filter.color = TransporterUtils.colors.get(0);
}
@Override
@ -128,20 +126,29 @@ public class GuiItemStackFilter extends GuiMekanism
GL11.glPopMatrix();
}
GL11.glPushMatrix();
GL11.glColor4f(1, 1, 1, 1);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
mc.getTextureManager().bindTexture(MekanismRenderer.getColorResource(filter.color));
itemRenderer.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
if(filter.color != null)
{
GL11.glPushMatrix();
GL11.glColor4f(1, 1, 1, 1);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
mc.getTextureManager().bindTexture(MekanismRenderer.getColorResource(filter.color));
itemRenderer.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60)
{
drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis);
if(filter.color != null)
{
drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis);
}
else {
drawCreativeTabHoveringText("None", xAxis, yAxis);
}
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);

View file

@ -3,21 +3,25 @@ package mekanism.client.gui;
import java.util.ArrayList;
import mekanism.api.Object3D;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.inventory.container.ContainerNull;
import mekanism.common.network.PacketLogisticalSorterGui;
import mekanism.common.network.PacketLogisticalSorterGui.SorterGuiPacket;
import mekanism.common.network.PacketTileEntity;
import mekanism.common.tileentity.TileEntityLogisticalSorter;
import mekanism.common.transporter.ItemStackFilter;
import mekanism.common.transporter.OreDictFilter;
import mekanism.common.transporter.TransporterFilter;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.common.util.TransporterUtils;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -60,35 +64,48 @@ public class GuiLogisticalSorter extends GuiMekanism
{
super.mouseClicked(mouseX, mouseY, button);
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll()+18 && yAxis <= getScroll()+18+15)
if(button == 0)
{
dragOffset = yAxis - (getScroll()+18);
isDragging = true;
}
for(int i = 0; i < 4; i++)
{
if(tileEntity.filters.get(getFilterIndex()+i) != null)
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll()+18 && yAxis <= getScroll()+18+15)
{
int yStart = i*29 + 18;
if(xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart+29)
dragOffset = yAxis - (getScroll()+18);
isDragging = true;
}
for(int i = 0; i < 4; i++)
{
if(tileEntity.filters.get(getFilterIndex()+i) != null)
{
TransporterFilter filter = tileEntity.filters.get(getFilterIndex()+i);
int yStart = i*29 + 18;
if(filter instanceof ItemStackFilter)
if(xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart+29)
{
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER_INDEX, Object3D.get(tileEntity), 1, getFilterIndex()+i));
}
else if(filter instanceof OreDictFilter)
{
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER_INDEX, Object3D.get(tileEntity), 2, getFilterIndex()+i));
TransporterFilter filter = tileEntity.filters.get(getFilterIndex()+i);
if(filter instanceof ItemStackFilter)
{
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER_INDEX, Object3D.get(tileEntity), 1, getFilterIndex()+i));
}
else if(filter instanceof OreDictFilter)
{
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER_INDEX, Object3D.get(tileEntity), 2, getFilterIndex()+i));
}
}
}
}
if(xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153)
{
ArrayList data = new ArrayList();
data.add(0);
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
}
}
}
@ -153,11 +170,14 @@ public class GuiLogisticalSorter extends GuiMekanism
int yAxis = (mouseY - (height - ySize) / 2);
fontRenderer.drawString("Logistical Sorter", 43, 6, 0x404040);
fontRenderer.drawString("Filters:", 11, 19, 0x00CD00);
fontRenderer.drawString("T: " + tileEntity.filters.size(), 11, 28, 0x00CD00);
fontRenderer.drawString("IS: " + getItemStackFilters().size(), 11, 37, 0x00CD00);
fontRenderer.drawString("OD: " + getOreDictFilters().size(), 11, 46, 0x00CD00);
fontRenderer.drawString("Default:", 12, 126, 0x00CD00);
for(int i = 0; i < 4; i++)
{
if(tileEntity.filters.get(getFilterIndex()+i) != null)
@ -168,7 +188,7 @@ public class GuiLogisticalSorter extends GuiMekanism
if(filter instanceof ItemStackFilter)
{
fontRenderer.drawString("ItemStack Filter", 58, yStart + 2, 0x404040);
fontRenderer.drawString("Color: " + filter.color.getName(), 58, yStart + 11, 0x404040);
fontRenderer.drawString("Color: " + filter.color != null ? filter.color.getName() : "None", 58, yStart + 11, 0x404040);
}
else if(filter instanceof OreDictFilter)
{
@ -178,6 +198,31 @@ public class GuiLogisticalSorter extends GuiMekanism
}
}
if(tileEntity.color != null)
{
GL11.glPushMatrix();
GL11.glColor4f(1, 1, 1, 1);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
mc.getTextureManager().bindTexture(MekanismRenderer.getColorResource(tileEntity.color));
itemRenderer.renderIcon(13, 137, MekanismRenderer.getColorIcon(tileEntity.color), 16, 16);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
if(xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153)
{
if(tileEntity.color != null)
{
drawCreativeTabHoveringText(tileEntity.color.getName(), xAxis, yAxis);
}
else {
drawCreativeTabHoveringText("None", xAxis, yAxis);
}
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}

View file

@ -71,8 +71,6 @@ public class GuiOreDictFilter extends GuiMekanism
tileEntity = tentity;
isNew = true;
filter.color = TransporterUtils.colors.get(0);
}
@Override
@ -172,20 +170,29 @@ public class GuiOreDictFilter extends GuiMekanism
GL11.glPopMatrix();
}
GL11.glPushMatrix();
GL11.glColor4f(1, 1, 1, 1);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
mc.getTextureManager().bindTexture(MekanismRenderer.getColorResource(filter.color));
itemRenderer.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
if(filter.color != null)
{
GL11.glPushMatrix();
GL11.glColor4f(1, 1, 1, 1);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
mc.getTextureManager().bindTexture(MekanismRenderer.getColorResource(filter.color));
itemRenderer.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60)
{
drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis);
if(filter.color != null)
{
drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis);
}
else {
drawCreativeTabHoveringText("None", xAxis, yAxis);
}
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
@ -310,7 +317,7 @@ public class GuiOreDictFilter extends GuiMekanism
for(String s : OreDictionary.getOreNames())
{
if(oreName.equals(s))
if(oreName.equals(s) || oreName.equals("*"))
{
keys.add(s);
}

View file

@ -45,9 +45,12 @@ public class TransmitterRenderingHandler implements ISimpleBlockRenderingHandler
case 3:
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter.png"));
break;
case 4:
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "RestrictiveTransporter.png"));
break;
}
if(metadata != 3)
if(metadata != 3 && metadata != 4)
{
smallTransmitter.renderSide(ForgeDirection.UP, true);
smallTransmitter.renderSide(ForgeDirection.DOWN, true);

View file

@ -1,5 +1,6 @@
package mekanism.client.render.tileentity;
import mekanism.api.Object3D;
import mekanism.client.model.ModelTransmitter;
import mekanism.client.model.ModelTransmitter.Size;
import mekanism.client.model.ModelTransporterBox;
@ -38,7 +39,17 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
public void renderAModelAt(TileEntityLogisticalTransporter tileEntity, double x, double y, double z, float partialTick)
{
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter.png"));
int meta = Object3D.get(tileEntity).getMetadata(tileEntity.worldObj);
if(meta == 3)
{
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter.png"));
}
else if(meta == 4)
{
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "RestrictiveTransporter.png"));
}
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);

View file

@ -44,6 +44,7 @@ import cpw.mods.fml.relauncher.SideOnly;
* 1: Universal Cable
* 2: Mechanical Pipe
* 3: Logistical Transporter
* 4: Restrictive Transporter
* @author AidanBrady
*
*/
@ -101,6 +102,7 @@ public class BlockTransmitter extends Block
list.add(new ItemStack(i, 1, 1));
list.add(new ItemStack(i, 1, 2));
list.add(new ItemStack(i, 1, 3));
list.add(new ItemStack(i, 1, 4));
}
@Override
@ -241,7 +243,7 @@ public class BlockTransmitter extends Block
{
connectable = PipeUtils.getConnections(tileEntity);
}
else if(world.getBlockMetadata(x, y, z) == 3)
else if(world.getBlockMetadata(x, y, z) == 3 || world.getBlockMetadata(x, y, z) == 4)
{
connectable = TransporterUtils.getConnections((TileEntityLogisticalTransporter)tileEntity);
}
@ -371,6 +373,8 @@ public class BlockTransmitter extends Block
return new TileEntityMechanicalPipe();
case 3:
return new TileEntityLogisticalTransporter();
case 4:
return new TileEntityLogisticalTransporter();
default:
return null;
}

View file

@ -67,6 +67,13 @@ public class ItemBlockTransmitter extends ItemBlock
list.add("- " + EnumColor.PURPLE + "Items (universal)");
list.add("- " + EnumColor.PURPLE + "Blocks (universal)");
}
else if(itemstack.getItemDamage() == 4)
{
list.add(EnumColor.DARK_GREY + "Capable of transferring:");
list.add("- " + EnumColor.PURPLE + "Items (universal)");
list.add("- " + EnumColor.PURPLE + "Blocks (universal)");
list.add("- " + EnumColor.DARK_RED + "Only used if no other paths available");
}
}
}
@ -86,6 +93,7 @@ public class ItemBlockTransmitter extends ItemBlock
public String getUnlocalizedName(ItemStack itemstack)
{
String name = "";
switch(itemstack.getItemDamage())
{
case 0:
@ -100,10 +108,14 @@ public class ItemBlockTransmitter extends ItemBlock
case 3:
name = "LogisticalTransporter";
break;
case 4:
name = "RestrictiveTransporter";
break;
default:
name = "Unknown";
break;
}
return getUnlocalizedName() + "." + name;
}
}

View file

@ -31,6 +31,8 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
public RedstoneControl controlType = RedstoneControl.DISABLED;
public EnumColor color;
public final int MAX_DELAY = 10;
public int delayTicks;
@ -74,18 +76,18 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
if(inInventory != null && inInventory.itemStack != null)
{
EnumColor color = null;
EnumColor filterColor = color;
for(TransporterFilter filter : filters)
{
if(filter.canFilter(inInventory.itemStack))
{
color = filter.color;
filterColor = filter.color;
break;
}
}
if(TransporterUtils.insert(this, transporter, inInventory.itemStack, color))
if(TransporterUtils.insert(this, transporter, inInventory.itemStack, filterColor))
{
inventory.setInventorySlotContents(inInventory.slotID, null);
setActive(true);
@ -116,6 +118,11 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
nbtTags.setInteger("controlType", controlType.ordinal());
if(color != null)
{
nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color));
}
NBTTagList filterTags = new NBTTagList();
for(TransporterFilter filter : filters)
@ -138,6 +145,11 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
if(nbtTags.hasKey("color"))
{
color = TransporterUtils.colors.get(nbtTags.getInteger("color"));
}
if(nbtTags.hasKey("filters"))
{
NBTTagList tagList = nbtTags.getTagList("filters");
@ -152,6 +164,16 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
@Override
public void handlePacketData(ByteArrayDataInput dataStream)
{
if(!worldObj.isRemote)
{
if(dataStream.readInt() == 0)
{
color = TransporterUtils.increment(color);
}
return;
}
super.handlePacketData(dataStream);
int type = dataStream.readInt();
@ -161,6 +183,16 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
isActive = dataStream.readBoolean();
controlType = RedstoneControl.values()[dataStream.readInt()];
int c = dataStream.readInt();
if(c != -1)
{
color = TransporterUtils.colors.get(c);
}
else {
color = null;
}
filters.clear();
int amount = dataStream.readInt();
@ -175,7 +207,17 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
else if(type == 1)
{
isActive = dataStream.readBoolean();
controlType = RedstoneControl.values()[dataStream.readInt()];
controlType = RedstoneControl.values()[dataStream.readInt()];
int c = dataStream.readInt();
if(c != -1)
{
color = TransporterUtils.colors.get(c);
}
else {
color = null;
}
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
@ -202,6 +244,14 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
data.add(isActive);
data.add(controlType.ordinal());
if(color != null)
{
data.add(TransporterUtils.colors.indexOf(color));
}
else {
data.add(-1);
}
data.add(filters.size());
for(TransporterFilter filter : filters)
@ -221,6 +271,14 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
data.add(isActive);
data.add(controlType.ordinal());
if(color != null)
{
data.add(TransporterUtils.colors.indexOf(color));
}
else {
data.add(-1);
}
return data;
}
@ -262,7 +320,12 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
@Override
public int[] getAccessibleSlotsFromSide(int side)
{
return new int[] {0};
if(side == ForgeDirection.getOrientation(facing).ordinal() || side == ForgeDirection.getOrientation(facing).getOpposite().ordinal())
{
return new int[] {0};
}
return null;
}
@Override

View file

@ -23,7 +23,7 @@ public class OreDictFilter extends TransporterFilter
return false;
}
if(oreDictName.equals(oreKey))
if(oreDictName.equals(oreKey) || oreDictName.equals("*"))
{
return true;
}

View file

@ -17,22 +17,43 @@ public abstract class TransporterFilter
public void write(NBTTagCompound nbtTags)
{
nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color));
if(color != null)
{
nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color));
}
}
protected void read(NBTTagCompound nbtTags)
{
color = TransporterUtils.colors.get(nbtTags.getInteger("color"));
if(nbtTags.hasKey("color"))
{
color = TransporterUtils.colors.get(nbtTags.getInteger("color"));
}
}
public void write(ArrayList data)
{
data.add(TransporterUtils.colors.indexOf(color));
if(color != null)
{
data.add(TransporterUtils.colors.indexOf(color));
}
else {
data.add(-1);
}
}
protected void read(ByteArrayDataInput dataStream)
{
color = TransporterUtils.colors.get(dataStream.readInt());
int c = dataStream.readInt();
if(c != -1)
{
color = TransporterUtils.colors.get(c);
}
else {
color = null;
}
}
public static TransporterFilter readFromNBT(NBTTagCompound nbtTags)

View file

@ -1,13 +1,13 @@
package mekanism.common.transporter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import mekanism.api.EnumColor;
import mekanism.api.Object3D;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.util.TransporterUtils;
@ -17,35 +17,33 @@ import net.minecraftforge.common.ForgeDirection;
public final class TransporterPathfinder
{
public static class IdleDest
public static class IdlePath
{
public World worldObj;
public Set<TileEntityLogisticalTransporter> iterated = new HashSet<TileEntityLogisticalTransporter>();
public Object3D start;
public TileEntityLogisticalTransporter start;
public Map<Object3D, Integer> destinations = new HashMap<Object3D, Integer>();
public Set<Destination> destinations = new HashSet<Destination>();
public TransporterStack transportStack;
public IdleDest(World world, TileEntityLogisticalTransporter tileEntity, TransporterStack stack)
public IdlePath(World world, Object3D obj, TransporterStack stack)
{
worldObj = world;
start = tileEntity;
start = obj;
transportStack = stack;
}
public void loop(TileEntityLogisticalTransporter pointer, int dist)
public void loop(Object3D pointer, ArrayList<Object3D> currentPath, int dist)
{
if(pointer == null)
{
return;
}
iterated.add(pointer);
currentPath.add(pointer);
if(pointer.color == EnumColor.BLACK)
if(pointer.getMetadata(worldObj) == 4)
{
dist += 1000;
}
@ -57,69 +55,108 @@ public final class TransporterPathfinder
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tile = Object3D.get(pointer).getFromSide(side).getTileEntity(worldObj);
TileEntity tile = pointer.getFromSide(side).getTileEntity(worldObj);
if(transportStack.canInsertToTransporter(tile) && !iterated.contains(tile))
if(transportStack.canInsertToTransporter(tile) && !currentPath.contains(Object3D.get(tile)))
{
loop((TileEntityLogisticalTransporter)tile, dist);
loop(Object3D.get(tile), (ArrayList<Object3D>)currentPath.clone(), dist);
found = true;
}
}
if(!found)
{
destinations.put(Object3D.get(pointer), dist);
destinations.add(new Destination(currentPath, null, dist));
}
}
public Object3D find()
public List<Object3D> find()
{
loop(start, 0);
loop(start, new ArrayList<Object3D>(), 0);
Object3D farthest = null;
Destination farthest = null;
for(Map.Entry<Object3D, Integer> entry : destinations.entrySet())
for(Destination obj : destinations)
{
if(farthest == null || destinations.get(farthest) < entry.getValue())
if(farthest == null || obj.distance > farthest.distance)
{
farthest = entry.getKey();
if(!obj.path.isEmpty() && !obj.path.get(0).equals(start))
{
farthest = obj;
}
}
}
return farthest;
if(farthest == null)
{
return null;
}
return farthest.path;
}
}
public static class Destination
{
public List<Object3D> path = new ArrayList<Object3D>();
public int distance;
public Destination(ArrayList<Object3D> list, Object3D dest, int i)
{
path = (List<Object3D>)list.clone();
if(dest != null)
{
path.add(dest);
}
Collections.reverse(path);
distance = i;
}
@Override
public int hashCode()
{
int code = 1;
code = 31 * code + path.hashCode();
code = 31 * code + distance;
return code;
}
@Override
public boolean equals(Object dest)
{
return dest instanceof Destination && ((Destination)dest).path.equals(path) && ((Destination)dest).distance == distance;
}
}
public static class DestPath
{
public World worldObj;
public Set<TileEntityLogisticalTransporter> iterated = new HashSet<TileEntityLogisticalTransporter>();
public Set<Destination> destinations = new HashSet<Destination>();
public Map<Object3D, Integer> destinations = new HashMap<Object3D, Integer>();
public Map<Object3D, Object3D> prevNodes = new HashMap<Object3D, Object3D>();
public TileEntityLogisticalTransporter start;
public Object3D start;
public TransporterStack transportStack;
public Destination(World world, TileEntityLogisticalTransporter tileEntity, TransporterStack stack)
public DestPath(World world, Object3D obj, TransporterStack stack)
{
worldObj = world;
start = tileEntity;
start = obj;
transportStack = stack;
}
public void loop(TileEntityLogisticalTransporter pointer, int dist)
public void loop(Object3D pointer, ArrayList<Object3D> currentPath, int dist)
{
if(pointer == null)
{
return;
}
iterated.add(pointer);
currentPath.add(pointer);
if(pointer.color == EnumColor.BLACK)
if(pointer.getMetadata(worldObj) == 4)
{
dist += 1000;
}
@ -129,225 +166,69 @@ public final class TransporterPathfinder
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tile = Object3D.get(pointer).getFromSide(side).getTileEntity(worldObj);
TileEntity tile = pointer.getFromSide(side).getTileEntity(worldObj);
if(TransporterUtils.canInsert(tile, transportStack.itemStack, side.ordinal()) && !(tile instanceof TileEntityLogisticalTransporter))
{
destinations.put(Object3D.get(tile), dist);
prevNodes.put(Object3D.get(tile), Object3D.get(pointer));
return;
destinations.add(new Destination(currentPath, Object3D.get(tile), dist));
}
if(transportStack.canInsertToTransporter(tile) && !iterated.contains(tile))
if(transportStack.canInsertToTransporter(tile) && !currentPath.contains(Object3D.get(tile)))
{
loop((TileEntityLogisticalTransporter)tile, dist);
loop(Object3D.get(tile), (ArrayList<Object3D>)currentPath.clone(), dist);
}
}
}
public Object3D find()
public List<Object3D> find()
{
loop(start, 0);
loop(start, new ArrayList<Object3D>(), 0);
Object3D closest = null;
Destination closest = null;
for(Map.Entry<Object3D, Integer> entry : destinations.entrySet())
for(Destination obj : destinations)
{
if(closest == null || destinations.get(closest) > entry.getValue())
if(closest == null || obj.distance < closest.distance)
{
closest = entry.getKey();
}
}
return closest;
}
}
public static class Path
{
public final Set<Object3D> openSet, closedSet;
public final HashMap<Object3D, Object3D> navMap;
public final HashMap<Object3D, Double> gScore, fScore;
public final Object3D target;
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, TransporterStack stack)
{
worldObj = world;
finalNode = node;
start = startObj;
target = finishObj;
transportStack = stack;
openSet = new HashSet<Object3D>();
closedSet = new HashSet<Object3D>();
navMap = new HashMap<Object3D, Object3D>();
gScore = new HashMap<Object3D, Double>();
fScore = new HashMap<Object3D, Double>();
results = new ArrayList<Object3D>();
}
public boolean find(final Object3D start)
{
openSet.add(start);
gScore.put(start, 0d);
fScore.put(start, gScore.get(start) + getEstimate(start, finalNode));
int blockCount = 0;
for(int i = 0; i < 6; i++)
{
ForgeDirection direction = ForgeDirection.getOrientation(i);
Object3D neighbor = finalNode.translate(direction.offsetX, direction.offsetY, direction.offsetZ);
if(!transportStack.canInsertToTransporter(neighbor.getTileEntity(worldObj)))
{
blockCount++;
}
}
if(blockCount >= 6)
{
return false;
}
double maxSearchDistance = start.distanceTo(finalNode) * 2;
while(!openSet.isEmpty())
{
Object3D currentNode = null;
double lowestFScore = 0;
for(Object3D node : openSet)
{
if(currentNode == null || fScore.get(node) < lowestFScore)
if(!obj.path.isEmpty() && !obj.path.get(0).equals(start))
{
currentNode = node;
lowestFScore = fScore.get(node);
}
}
if(currentNode == null && start.distanceTo(currentNode) > maxSearchDistance)
{
break;
}
if(currentNode.equals(finalNode))
{
results = reconstructPath(navMap, finalNode);
return true;
}
openSet.remove(currentNode);
closedSet.add(currentNode);
for(int i = 0; i < 6; i++)
{
ForgeDirection direction = ForgeDirection.getOrientation(i);
Object3D neighbor = currentNode.getFromSide(direction);
if(transportStack.canInsertToTransporter(neighbor.getTileEntity(worldObj)))
{
double tentativeG = gScore.get(currentNode) + currentNode.distanceTo(neighbor);
if(closedSet.contains(neighbor))
{
if(tentativeG >= gScore.get(neighbor))
{
continue;
}
}
if(!openSet.contains(neighbor) || tentativeG < gScore.get(neighbor))
{
navMap.put(neighbor, currentNode);
gScore.put(neighbor, tentativeG);
fScore.put(neighbor, gScore.get(neighbor) + getEstimate(neighbor, finalNode));
openSet.add(neighbor);
}
closest = obj;
}
}
}
return false;
}
public List<Object3D> getPath()
{
boolean foundPath = find(start);
if(foundPath)
if(closest == null)
{
if(target != null)
{
results.add(0, target);
}
return results;
return null;
}
return null;
}
private List<Object3D> reconstructPath(HashMap<Object3D, Object3D> naviMap, Object3D currentNode)
{
List<Object3D> path = new ArrayList<Object3D>();
path.add(currentNode);
if(naviMap.containsKey(currentNode))
{
path.addAll(reconstructPath(naviMap, naviMap.get(currentNode)));
}
return path;
}
private double getEstimate(Object3D start, Object3D target2)
{
return start.distanceTo(target2);
return closest.path;
}
}
public static List<Object3D> getNewPath(TileEntityLogisticalTransporter start, TransporterStack stack)
{
Destination d = new Destination(start.worldObj, start, stack);
Object3D closest = d.find();
DestPath d = new DestPath(start.worldObj, Object3D.get(start), stack);
List<Object3D> path = d.find();
if(closest == null)
if(path == null)
{
return null;
}
Path p = new Path(d.worldObj, d.prevNodes.get(closest), Object3D.get(start), closest, stack);
return p.getPath();
return path;
}
public static List<Object3D> getIdlePath(TileEntityLogisticalTransporter start, TransporterStack stack)
{
IdleDest d = new IdleDest(start.worldObj, start, stack);
Object3D farthest = d.find();
IdlePath d = new IdlePath(start.worldObj, Object3D.get(start), stack);
List<Object3D> path = d.find();
if(farthest == null || farthest.equals(Object3D.get(start)))
if(path == null)
{
return null;
}
Path p = new Path(start.worldObj, farthest, Object3D.get(start), null, stack);
return p.getPath();
return path;
}
}

View file

@ -204,7 +204,10 @@ public class TransporterStack
{
if(progress < 50)
{
return Object3D.get(tileEntity).sideDifference(getPrev(tileEntity)).ordinal();
if(getPrev(tileEntity) != null)
{
return Object3D.get(tileEntity).sideDifference(getPrev(tileEntity)).ordinal();
}
}
else if(progress == 50)
{
@ -215,7 +218,10 @@ public class TransporterStack
}
else if(progress > 50)
{
return getNext(tileEntity).sideDifference(Object3D.get(tileEntity)).ordinal();
if(getNext(tileEntity) != null)
{
return getNext(tileEntity).sideDifference(Object3D.get(tileEntity)).ordinal();
}
}
return 0;

View file

@ -71,50 +71,52 @@ public final class MekanismUtils
*/
public static boolean checkForUpdates(EntityPlayer entityplayer)
{
if(Mekanism.updateNotifications && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null)
{
if(!Mekanism.latestVersionNumber.equals("null"))
try {
if(Mekanism.updateNotifications && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null)
{
ArrayList<IModule> list = new ArrayList<IModule>();
for(IModule module : Mekanism.modulesLoaded)
if(!Mekanism.latestVersionNumber.equals("null"))
{
if(Version.get(Mekanism.latestVersionNumber).comparedState(module.getVersion()) == 1)
ArrayList<IModule> list = new ArrayList<IModule>();
for(IModule module : Mekanism.modulesLoaded)
{
list.add(module);
if(Version.get(Mekanism.latestVersionNumber).comparedState(module.getVersion()) == 1)
{
list.add(module);
}
}
if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1 || !list.isEmpty())
{
entityplayer.addChatMessage(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------");
entityplayer.addChatMessage(EnumColor.GREY + " Using outdated version on one or more modules.");
if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1)
{
entityplayer.addChatMessage(EnumColor.INDIGO + " Mekanism: " + EnumColor.DARK_RED + Mekanism.versionNumber);
}
for(IModule module : list)
{
entityplayer.addChatMessage(EnumColor.INDIGO + " Mekanism" + module.getName() + ": " + EnumColor.DARK_RED + module.getVersion());
}
entityplayer.addChatMessage(EnumColor.GREY + " Consider updating to version " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber);
entityplayer.addChatMessage(EnumColor.GREY + " New features: " + EnumColor.INDIGO + Mekanism.recentNews);
entityplayer.addChatMessage(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------");
return true;
}
else if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == -1)
{
entityplayer.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Using developer build " + EnumColor.DARK_GREY + Mekanism.versionNumber);
return true;
}
}
if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1 || !list.isEmpty())
{
entityplayer.addChatMessage(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------");
entityplayer.addChatMessage(EnumColor.GREY + " Using outdated version on one or more modules.");
if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1)
{
entityplayer.addChatMessage(EnumColor.INDIGO + " Mekanism: " + EnumColor.DARK_RED + Mekanism.versionNumber);
}
for(IModule module : list)
{
entityplayer.addChatMessage(EnumColor.INDIGO + " Mekanism" + module.getName() + ": " + EnumColor.DARK_RED + module.getVersion());
}
entityplayer.addChatMessage(EnumColor.GREY + " Consider updating to version " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber);
entityplayer.addChatMessage(EnumColor.GREY + " New features: " + EnumColor.INDIGO + Mekanism.recentNews);
entityplayer.addChatMessage(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------");
return true;
}
else if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == -1)
{
entityplayer.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Using developer build " + EnumColor.DARK_GREY + Mekanism.versionNumber);
return true;
else {
System.out.println("[Mekanism] Minecraft is in offline mode, could not check for updates.");
}
}
else {
System.out.println("[Mekanism] Minecraft is in offline mode, could not check for updates.");
}
}
} catch(Exception e) {}
return false;
}

View file

@ -35,7 +35,6 @@ public final class TransporterUtils
ret.add(EnumColor.RED);
ret.add(EnumColor.PINK);
ret.add(EnumColor.YELLOW);
ret.add(EnumColor.BLACK);
return ret;
}
@ -357,10 +356,14 @@ public final class TransporterUtils
public static EnumColor increment(EnumColor color)
{
if(colors.indexOf(color) == colors.size()-1)
if(color == null)
{
return colors.get(0);
}
else if(colors.indexOf(color) == colors.size()-1)
{
return null;
}
return colors.get(colors.indexOf(color)+1);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View file

@ -67,6 +67,7 @@ tile.Transmitter.PressurizedTube.name=Pressurized Tube
tile.Transmitter.UniversalCable.name=Universal Cable
tile.Transmitter.MechanicalPipe.name=Mechanical Pipe
tile.Transmitter.LogisticalTransporter.name=Logistical Transporter
tile.Transmitter.RestrictiveTransporter.name=Restrictive Transporter
//Energy Cubes
tile.EnergyCube.Basic.name=Basic Energy Cube

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB