diff --git a/common/mekanism/client/gui/GuiItemStackFilter.java b/common/mekanism/client/gui/GuiItemStackFilter.java index 2ba6f8856..6041e7804 100644 --- a/common/mekanism/client/gui/GuiItemStackFilter.java +++ b/common/mekanism/client/gui/GuiItemStackFilter.java @@ -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); diff --git a/common/mekanism/client/gui/GuiLogisticalSorter.java b/common/mekanism/client/gui/GuiLogisticalSorter.java index 3c5142df5..5e5bfd20c 100644 --- a/common/mekanism/client/gui/GuiLogisticalSorter.java +++ b/common/mekanism/client/gui/GuiLogisticalSorter.java @@ -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); } diff --git a/common/mekanism/client/gui/GuiOreDictFilter.java b/common/mekanism/client/gui/GuiOreDictFilter.java index 2d967ffcd..f52a49cb9 100644 --- a/common/mekanism/client/gui/GuiOreDictFilter.java +++ b/common/mekanism/client/gui/GuiOreDictFilter.java @@ -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); } diff --git a/common/mekanism/client/render/block/TransmitterRenderingHandler.java b/common/mekanism/client/render/block/TransmitterRenderingHandler.java index 2e539c3f0..5328e2142 100644 --- a/common/mekanism/client/render/block/TransmitterRenderingHandler.java +++ b/common/mekanism/client/render/block/TransmitterRenderingHandler.java @@ -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); diff --git a/common/mekanism/client/render/tileentity/RenderLogisticalTransporter.java b/common/mekanism/client/render/tileentity/RenderLogisticalTransporter.java index f2a9fb9e1..6b386eec3 100644 --- a/common/mekanism/client/render/tileentity/RenderLogisticalTransporter.java +++ b/common/mekanism/client/render/tileentity/RenderLogisticalTransporter.java @@ -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); diff --git a/common/mekanism/common/block/BlockTransmitter.java b/common/mekanism/common/block/BlockTransmitter.java index a965161bf..78067c719 100644 --- a/common/mekanism/common/block/BlockTransmitter.java +++ b/common/mekanism/common/block/BlockTransmitter.java @@ -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; } diff --git a/common/mekanism/common/item/ItemBlockTransmitter.java b/common/mekanism/common/item/ItemBlockTransmitter.java index 9b6acc2b0..0a86070e1 100644 --- a/common/mekanism/common/item/ItemBlockTransmitter.java +++ b/common/mekanism/common/item/ItemBlockTransmitter.java @@ -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; } } \ No newline at end of file diff --git a/common/mekanism/common/tileentity/TileEntityLogisticalSorter.java b/common/mekanism/common/tileentity/TileEntityLogisticalSorter.java index 87a377ce7..51b68ac27 100644 --- a/common/mekanism/common/tileentity/TileEntityLogisticalSorter.java +++ b/common/mekanism/common/tileentity/TileEntityLogisticalSorter.java @@ -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 diff --git a/common/mekanism/common/transporter/OreDictFilter.java b/common/mekanism/common/transporter/OreDictFilter.java index 4084bb880..e97115aee 100644 --- a/common/mekanism/common/transporter/OreDictFilter.java +++ b/common/mekanism/common/transporter/OreDictFilter.java @@ -23,7 +23,7 @@ public class OreDictFilter extends TransporterFilter return false; } - if(oreDictName.equals(oreKey)) + if(oreDictName.equals(oreKey) || oreDictName.equals("*")) { return true; } diff --git a/common/mekanism/common/transporter/TransporterFilter.java b/common/mekanism/common/transporter/TransporterFilter.java index 5cfe19451..079da7f19 100644 --- a/common/mekanism/common/transporter/TransporterFilter.java +++ b/common/mekanism/common/transporter/TransporterFilter.java @@ -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) diff --git a/common/mekanism/common/transporter/TransporterPathfinder.java b/common/mekanism/common/transporter/TransporterPathfinder.java index 635aec34d..b4eb3db17 100644 --- a/common/mekanism/common/transporter/TransporterPathfinder.java +++ b/common/mekanism/common/transporter/TransporterPathfinder.java @@ -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 iterated = new HashSet(); + public Object3D start; - public TileEntityLogisticalTransporter start; - - public Map destinations = new HashMap(); + public Set destinations = new HashSet(); 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 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)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 find() { - loop(start, 0); + loop(start, new ArrayList(), 0); - Object3D farthest = null; + Destination farthest = null; - for(Map.Entry 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 path = new ArrayList(); + public int distance; + + public Destination(ArrayList list, Object3D dest, int i) + { + path = (List)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 iterated = new HashSet(); + public Set destinations = new HashSet(); - public Map destinations = new HashMap(); - public Map prevNodes = new HashMap(); - - 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 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)currentPath.clone(), dist); } } } - public Object3D find() + public List find() { - loop(start, 0); + loop(start, new ArrayList(), 0); - Object3D closest = null; + Destination closest = null; - for(Map.Entry 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 openSet, closedSet; - - public final HashMap navMap; - - public final HashMap gScore, fScore; - - public final Object3D target; - - public final Object3D start; - - public final Object3D finalNode; - - public final TransporterStack transportStack; - - public List 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(); - closedSet = new HashSet(); - - navMap = new HashMap(); - - gScore = new HashMap(); - fScore = new HashMap(); - - results = new ArrayList(); - } - - 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 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 reconstructPath(HashMap naviMap, Object3D currentNode) - { - List path = new ArrayList(); - 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 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 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 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 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; } } diff --git a/common/mekanism/common/transporter/TransporterStack.java b/common/mekanism/common/transporter/TransporterStack.java index 9182a6dfb..0070945b5 100644 --- a/common/mekanism/common/transporter/TransporterStack.java +++ b/common/mekanism/common/transporter/TransporterStack.java @@ -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; diff --git a/common/mekanism/common/util/MekanismUtils.java b/common/mekanism/common/util/MekanismUtils.java index 24c579be5..0715ddc85 100644 --- a/common/mekanism/common/util/MekanismUtils.java +++ b/common/mekanism/common/util/MekanismUtils.java @@ -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 list = new ArrayList(); - - for(IModule module : Mekanism.modulesLoaded) + if(!Mekanism.latestVersionNumber.equals("null")) { - if(Version.get(Mekanism.latestVersionNumber).comparedState(module.getVersion()) == 1) + ArrayList list = new ArrayList(); + + 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; } diff --git a/common/mekanism/common/util/TransporterUtils.java b/common/mekanism/common/util/TransporterUtils.java index 6b089314d..1c45786c8 100644 --- a/common/mekanism/common/util/TransporterUtils.java +++ b/common/mekanism/common/util/TransporterUtils.java @@ -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); } diff --git a/resources/assets/mekanism/gui/GuiHydrogenGenerator.png b/resources/assets/mekanism/gui/GuiHydrogenGenerator.png index 772f62574..8d870a167 100644 Binary files a/resources/assets/mekanism/gui/GuiHydrogenGenerator.png and b/resources/assets/mekanism/gui/GuiHydrogenGenerator.png differ diff --git a/resources/assets/mekanism/gui/GuiLogisticalSorter.png b/resources/assets/mekanism/gui/GuiLogisticalSorter.png index 73e9ac258..f01c733c0 100644 Binary files a/resources/assets/mekanism/gui/GuiLogisticalSorter.png and b/resources/assets/mekanism/gui/GuiLogisticalSorter.png differ diff --git a/resources/assets/mekanism/lang/en_US.lang b/resources/assets/mekanism/lang/en_US.lang index 52dc30598..ceb0e1b95 100644 --- a/resources/assets/mekanism/lang/en_US.lang +++ b/resources/assets/mekanism/lang/en_US.lang @@ -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 diff --git a/resources/assets/mekanism/render/RestrictiveTransporter.png b/resources/assets/mekanism/render/RestrictiveTransporter.png new file mode 100644 index 000000000..d69fe127d Binary files /dev/null and b/resources/assets/mekanism/render/RestrictiveTransporter.png differ