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:
parent
013a2a7aa4
commit
9496f7dfa3
18 changed files with 379 additions and 313 deletions
|
@ -51,8 +51,6 @@ public class GuiItemStackFilter extends GuiMekanism
|
||||||
tileEntity = tentity;
|
tileEntity = tentity;
|
||||||
|
|
||||||
isNew = true;
|
isNew = true;
|
||||||
|
|
||||||
filter.color = TransporterUtils.colors.get(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -128,20 +126,29 @@ public class GuiItemStackFilter extends GuiMekanism
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
if(filter.color != null)
|
||||||
GL11.glColor4f(1, 1, 1, 1);
|
{
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
GL11.glPushMatrix();
|
||||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
GL11.glColor4f(1, 1, 1, 1);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
mc.getTextureManager().bindTexture(MekanismRenderer.getColorResource(filter.color));
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||||
itemRenderer.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16);
|
|
||||||
|
mc.getTextureManager().bindTexture(MekanismRenderer.getColorResource(filter.color));
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
itemRenderer.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16);
|
||||||
GL11.glPopMatrix();
|
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60)
|
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);
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
|
|
|
@ -3,21 +3,25 @@ package mekanism.client.gui;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import mekanism.api.Object3D;
|
import mekanism.api.Object3D;
|
||||||
|
import mekanism.client.render.MekanismRenderer;
|
||||||
import mekanism.common.PacketHandler;
|
import mekanism.common.PacketHandler;
|
||||||
import mekanism.common.PacketHandler.Transmission;
|
import mekanism.common.PacketHandler.Transmission;
|
||||||
import mekanism.common.inventory.container.ContainerNull;
|
import mekanism.common.inventory.container.ContainerNull;
|
||||||
import mekanism.common.network.PacketLogisticalSorterGui;
|
import mekanism.common.network.PacketLogisticalSorterGui;
|
||||||
import mekanism.common.network.PacketLogisticalSorterGui.SorterGuiPacket;
|
import mekanism.common.network.PacketLogisticalSorterGui.SorterGuiPacket;
|
||||||
|
import mekanism.common.network.PacketTileEntity;
|
||||||
import mekanism.common.tileentity.TileEntityLogisticalSorter;
|
import mekanism.common.tileentity.TileEntityLogisticalSorter;
|
||||||
import mekanism.common.transporter.ItemStackFilter;
|
import mekanism.common.transporter.ItemStackFilter;
|
||||||
import mekanism.common.transporter.OreDictFilter;
|
import mekanism.common.transporter.OreDictFilter;
|
||||||
import mekanism.common.transporter.TransporterFilter;
|
import mekanism.common.transporter.TransporterFilter;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||||
|
import mekanism.common.util.TransporterUtils;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import org.lwjgl.opengl.GL12;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
@ -60,35 +64,48 @@ public class GuiLogisticalSorter extends GuiMekanism
|
||||||
{
|
{
|
||||||
super.mouseClicked(mouseX, mouseY, button);
|
super.mouseClicked(mouseX, mouseY, button);
|
||||||
|
|
||||||
int xAxis = (mouseX - (width - xSize) / 2);
|
if(button == 0)
|
||||||
int yAxis = (mouseY - (height - ySize) / 2);
|
|
||||||
|
|
||||||
if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll()+18 && yAxis <= getScroll()+18+15)
|
|
||||||
{
|
{
|
||||||
dragOffset = yAxis - (getScroll()+18);
|
int xAxis = (mouseX - (width - xSize) / 2);
|
||||||
isDragging = true;
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
}
|
|
||||||
|
if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll()+18 && yAxis <= getScroll()+18+15)
|
||||||
for(int i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
if(tileEntity.filters.get(getFilterIndex()+i) != null)
|
|
||||||
{
|
{
|
||||||
int yStart = i*29 + 18;
|
dragOffset = yAxis - (getScroll()+18);
|
||||||
|
isDragging = true;
|
||||||
if(xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart+29)
|
}
|
||||||
|
|
||||||
|
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));
|
TransporterFilter filter = tileEntity.filters.get(getFilterIndex()+i);
|
||||||
}
|
|
||||||
else if(filter instanceof OreDictFilter)
|
if(filter instanceof ItemStackFilter)
|
||||||
{
|
{
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER_INDEX, Object3D.get(tileEntity), 2, getFilterIndex()+i));
|
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);
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
|
|
||||||
fontRenderer.drawString("Logistical Sorter", 43, 6, 0x404040);
|
fontRenderer.drawString("Logistical Sorter", 43, 6, 0x404040);
|
||||||
|
|
||||||
fontRenderer.drawString("Filters:", 11, 19, 0x00CD00);
|
fontRenderer.drawString("Filters:", 11, 19, 0x00CD00);
|
||||||
fontRenderer.drawString("T: " + tileEntity.filters.size(), 11, 28, 0x00CD00);
|
fontRenderer.drawString("T: " + tileEntity.filters.size(), 11, 28, 0x00CD00);
|
||||||
fontRenderer.drawString("IS: " + getItemStackFilters().size(), 11, 37, 0x00CD00);
|
fontRenderer.drawString("IS: " + getItemStackFilters().size(), 11, 37, 0x00CD00);
|
||||||
fontRenderer.drawString("OD: " + getOreDictFilters().size(), 11, 46, 0x00CD00);
|
fontRenderer.drawString("OD: " + getOreDictFilters().size(), 11, 46, 0x00CD00);
|
||||||
|
|
||||||
|
fontRenderer.drawString("Default:", 12, 126, 0x00CD00);
|
||||||
|
|
||||||
for(int i = 0; i < 4; i++)
|
for(int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
if(tileEntity.filters.get(getFilterIndex()+i) != null)
|
if(tileEntity.filters.get(getFilterIndex()+i) != null)
|
||||||
|
@ -168,7 +188,7 @@ public class GuiLogisticalSorter extends GuiMekanism
|
||||||
if(filter instanceof ItemStackFilter)
|
if(filter instanceof ItemStackFilter)
|
||||||
{
|
{
|
||||||
fontRenderer.drawString("ItemStack Filter", 58, yStart + 2, 0x404040);
|
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)
|
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);
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,6 @@ public class GuiOreDictFilter extends GuiMekanism
|
||||||
tileEntity = tentity;
|
tileEntity = tentity;
|
||||||
|
|
||||||
isNew = true;
|
isNew = true;
|
||||||
|
|
||||||
filter.color = TransporterUtils.colors.get(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -172,20 +170,29 @@ public class GuiOreDictFilter extends GuiMekanism
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
if(filter.color != null)
|
||||||
GL11.glColor4f(1, 1, 1, 1);
|
{
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
GL11.glPushMatrix();
|
||||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
GL11.glColor4f(1, 1, 1, 1);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
mc.getTextureManager().bindTexture(MekanismRenderer.getColorResource(filter.color));
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||||
itemRenderer.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16);
|
|
||||||
|
mc.getTextureManager().bindTexture(MekanismRenderer.getColorResource(filter.color));
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
itemRenderer.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16);
|
||||||
GL11.glPopMatrix();
|
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60)
|
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);
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
|
@ -310,7 +317,7 @@ public class GuiOreDictFilter extends GuiMekanism
|
||||||
|
|
||||||
for(String s : OreDictionary.getOreNames())
|
for(String s : OreDictionary.getOreNames())
|
||||||
{
|
{
|
||||||
if(oreName.equals(s))
|
if(oreName.equals(s) || oreName.equals("*"))
|
||||||
{
|
{
|
||||||
keys.add(s);
|
keys.add(s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,12 @@ public class TransmitterRenderingHandler implements ISimpleBlockRenderingHandler
|
||||||
case 3:
|
case 3:
|
||||||
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter.png"));
|
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter.png"));
|
||||||
break;
|
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.UP, true);
|
||||||
smallTransmitter.renderSide(ForgeDirection.DOWN, true);
|
smallTransmitter.renderSide(ForgeDirection.DOWN, true);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package mekanism.client.render.tileentity;
|
package mekanism.client.render.tileentity;
|
||||||
|
|
||||||
|
import mekanism.api.Object3D;
|
||||||
import mekanism.client.model.ModelTransmitter;
|
import mekanism.client.model.ModelTransmitter;
|
||||||
import mekanism.client.model.ModelTransmitter.Size;
|
import mekanism.client.model.ModelTransmitter.Size;
|
||||||
import mekanism.client.model.ModelTransporterBox;
|
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)
|
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.glPushMatrix();
|
||||||
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
|
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
|
||||||
GL11.glScalef(1.0F, -1F, -1F);
|
GL11.glScalef(1.0F, -1F, -1F);
|
||||||
|
|
|
@ -44,6 +44,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
* 1: Universal Cable
|
* 1: Universal Cable
|
||||||
* 2: Mechanical Pipe
|
* 2: Mechanical Pipe
|
||||||
* 3: Logistical Transporter
|
* 3: Logistical Transporter
|
||||||
|
* 4: Restrictive Transporter
|
||||||
* @author AidanBrady
|
* @author AidanBrady
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -101,6 +102,7 @@ public class BlockTransmitter extends Block
|
||||||
list.add(new ItemStack(i, 1, 1));
|
list.add(new ItemStack(i, 1, 1));
|
||||||
list.add(new ItemStack(i, 1, 2));
|
list.add(new ItemStack(i, 1, 2));
|
||||||
list.add(new ItemStack(i, 1, 3));
|
list.add(new ItemStack(i, 1, 3));
|
||||||
|
list.add(new ItemStack(i, 1, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -241,7 +243,7 @@ public class BlockTransmitter extends Block
|
||||||
{
|
{
|
||||||
connectable = PipeUtils.getConnections(tileEntity);
|
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);
|
connectable = TransporterUtils.getConnections((TileEntityLogisticalTransporter)tileEntity);
|
||||||
}
|
}
|
||||||
|
@ -371,6 +373,8 @@ public class BlockTransmitter extends Block
|
||||||
return new TileEntityMechanicalPipe();
|
return new TileEntityMechanicalPipe();
|
||||||
case 3:
|
case 3:
|
||||||
return new TileEntityLogisticalTransporter();
|
return new TileEntityLogisticalTransporter();
|
||||||
|
case 4:
|
||||||
|
return new TileEntityLogisticalTransporter();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,13 @@ public class ItemBlockTransmitter extends ItemBlock
|
||||||
list.add("- " + EnumColor.PURPLE + "Items (universal)");
|
list.add("- " + EnumColor.PURPLE + "Items (universal)");
|
||||||
list.add("- " + EnumColor.PURPLE + "Blocks (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)
|
public String getUnlocalizedName(ItemStack itemstack)
|
||||||
{
|
{
|
||||||
String name = "";
|
String name = "";
|
||||||
|
|
||||||
switch(itemstack.getItemDamage())
|
switch(itemstack.getItemDamage())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -100,10 +108,14 @@ public class ItemBlockTransmitter extends ItemBlock
|
||||||
case 3:
|
case 3:
|
||||||
name = "LogisticalTransporter";
|
name = "LogisticalTransporter";
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
name = "RestrictiveTransporter";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
name = "Unknown";
|
name = "Unknown";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getUnlocalizedName() + "." + name;
|
return getUnlocalizedName() + "." + name;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,6 +31,8 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
|
|
||||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||||
|
|
||||||
|
public EnumColor color;
|
||||||
|
|
||||||
public final int MAX_DELAY = 10;
|
public final int MAX_DELAY = 10;
|
||||||
|
|
||||||
public int delayTicks;
|
public int delayTicks;
|
||||||
|
@ -74,18 +76,18 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
|
|
||||||
if(inInventory != null && inInventory.itemStack != null)
|
if(inInventory != null && inInventory.itemStack != null)
|
||||||
{
|
{
|
||||||
EnumColor color = null;
|
EnumColor filterColor = color;
|
||||||
|
|
||||||
for(TransporterFilter filter : filters)
|
for(TransporterFilter filter : filters)
|
||||||
{
|
{
|
||||||
if(filter.canFilter(inInventory.itemStack))
|
if(filter.canFilter(inInventory.itemStack))
|
||||||
{
|
{
|
||||||
color = filter.color;
|
filterColor = filter.color;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(TransporterUtils.insert(this, transporter, inInventory.itemStack, color))
|
if(TransporterUtils.insert(this, transporter, inInventory.itemStack, filterColor))
|
||||||
{
|
{
|
||||||
inventory.setInventorySlotContents(inInventory.slotID, null);
|
inventory.setInventorySlotContents(inInventory.slotID, null);
|
||||||
setActive(true);
|
setActive(true);
|
||||||
|
@ -116,6 +118,11 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
|
|
||||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||||
|
|
||||||
|
if(color != null)
|
||||||
|
{
|
||||||
|
nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color));
|
||||||
|
}
|
||||||
|
|
||||||
NBTTagList filterTags = new NBTTagList();
|
NBTTagList filterTags = new NBTTagList();
|
||||||
|
|
||||||
for(TransporterFilter filter : filters)
|
for(TransporterFilter filter : filters)
|
||||||
|
@ -138,6 +145,11 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
|
|
||||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||||
|
|
||||||
|
if(nbtTags.hasKey("color"))
|
||||||
|
{
|
||||||
|
color = TransporterUtils.colors.get(nbtTags.getInteger("color"));
|
||||||
|
}
|
||||||
|
|
||||||
if(nbtTags.hasKey("filters"))
|
if(nbtTags.hasKey("filters"))
|
||||||
{
|
{
|
||||||
NBTTagList tagList = nbtTags.getTagList("filters");
|
NBTTagList tagList = nbtTags.getTagList("filters");
|
||||||
|
@ -152,6 +164,16 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
@Override
|
@Override
|
||||||
public void handlePacketData(ByteArrayDataInput dataStream)
|
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||||
{
|
{
|
||||||
|
if(!worldObj.isRemote)
|
||||||
|
{
|
||||||
|
if(dataStream.readInt() == 0)
|
||||||
|
{
|
||||||
|
color = TransporterUtils.increment(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
super.handlePacketData(dataStream);
|
super.handlePacketData(dataStream);
|
||||||
|
|
||||||
int type = dataStream.readInt();
|
int type = dataStream.readInt();
|
||||||
|
@ -161,6 +183,16 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
isActive = dataStream.readBoolean();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
filters.clear();
|
filters.clear();
|
||||||
|
|
||||||
int amount = dataStream.readInt();
|
int amount = dataStream.readInt();
|
||||||
|
@ -175,7 +207,17 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
else if(type == 1)
|
else if(type == 1)
|
||||||
{
|
{
|
||||||
isActive = dataStream.readBoolean();
|
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);
|
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
||||||
}
|
}
|
||||||
|
@ -202,6 +244,14 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
data.add(isActive);
|
data.add(isActive);
|
||||||
data.add(controlType.ordinal());
|
data.add(controlType.ordinal());
|
||||||
|
|
||||||
|
if(color != null)
|
||||||
|
{
|
||||||
|
data.add(TransporterUtils.colors.indexOf(color));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data.add(-1);
|
||||||
|
}
|
||||||
|
|
||||||
data.add(filters.size());
|
data.add(filters.size());
|
||||||
|
|
||||||
for(TransporterFilter filter : filters)
|
for(TransporterFilter filter : filters)
|
||||||
|
@ -221,6 +271,14 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
data.add(isActive);
|
data.add(isActive);
|
||||||
data.add(controlType.ordinal());
|
data.add(controlType.ordinal());
|
||||||
|
|
||||||
|
if(color != null)
|
||||||
|
{
|
||||||
|
data.add(TransporterUtils.colors.indexOf(color));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data.add(-1);
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -262,7 +320,12 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
@Override
|
@Override
|
||||||
public int[] getAccessibleSlotsFromSide(int side)
|
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
|
@Override
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class OreDictFilter extends TransporterFilter
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(oreDictName.equals(oreKey))
|
if(oreDictName.equals(oreKey) || oreDictName.equals("*"))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,22 +17,43 @@ public abstract class TransporterFilter
|
||||||
|
|
||||||
public void write(NBTTagCompound nbtTags)
|
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)
|
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)
|
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)
|
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)
|
public static TransporterFilter readFromNBT(NBTTagCompound nbtTags)
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package mekanism.common.transporter;
|
package mekanism.common.transporter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import mekanism.api.EnumColor;
|
|
||||||
import mekanism.api.Object3D;
|
import mekanism.api.Object3D;
|
||||||
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
||||||
import mekanism.common.util.TransporterUtils;
|
import mekanism.common.util.TransporterUtils;
|
||||||
|
@ -17,35 +17,33 @@ import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
public final class TransporterPathfinder
|
public final class TransporterPathfinder
|
||||||
{
|
{
|
||||||
public static class IdleDest
|
public static class IdlePath
|
||||||
{
|
{
|
||||||
public World worldObj;
|
public World worldObj;
|
||||||
|
|
||||||
public Set<TileEntityLogisticalTransporter> iterated = new HashSet<TileEntityLogisticalTransporter>();
|
public Object3D start;
|
||||||
|
|
||||||
public TileEntityLogisticalTransporter start;
|
public Set<Destination> destinations = new HashSet<Destination>();
|
||||||
|
|
||||||
public Map<Object3D, Integer> destinations = new HashMap<Object3D, Integer>();
|
|
||||||
|
|
||||||
public TransporterStack transportStack;
|
public TransporterStack transportStack;
|
||||||
|
|
||||||
public IdleDest(World world, TileEntityLogisticalTransporter tileEntity, TransporterStack stack)
|
public IdlePath(World world, Object3D obj, TransporterStack stack)
|
||||||
{
|
{
|
||||||
worldObj = world;
|
worldObj = world;
|
||||||
start = tileEntity;
|
start = obj;
|
||||||
transportStack = stack;
|
transportStack = stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loop(TileEntityLogisticalTransporter pointer, int dist)
|
public void loop(Object3D pointer, ArrayList<Object3D> currentPath, int dist)
|
||||||
{
|
{
|
||||||
if(pointer == null)
|
if(pointer == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterated.add(pointer);
|
currentPath.add(pointer);
|
||||||
|
|
||||||
if(pointer.color == EnumColor.BLACK)
|
if(pointer.getMetadata(worldObj) == 4)
|
||||||
{
|
{
|
||||||
dist += 1000;
|
dist += 1000;
|
||||||
}
|
}
|
||||||
|
@ -57,69 +55,108 @@ public final class TransporterPathfinder
|
||||||
|
|
||||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
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;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!found)
|
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 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 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 Object3D start;
|
||||||
public Map<Object3D, Object3D> prevNodes = new HashMap<Object3D, Object3D>();
|
|
||||||
|
|
||||||
public TileEntityLogisticalTransporter start;
|
|
||||||
|
|
||||||
public TransporterStack transportStack;
|
public TransporterStack transportStack;
|
||||||
|
|
||||||
public Destination(World world, TileEntityLogisticalTransporter tileEntity, TransporterStack stack)
|
public DestPath(World world, Object3D obj, TransporterStack stack)
|
||||||
{
|
{
|
||||||
worldObj = world;
|
worldObj = world;
|
||||||
start = tileEntity;
|
start = obj;
|
||||||
transportStack = stack;
|
transportStack = stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loop(TileEntityLogisticalTransporter pointer, int dist)
|
public void loop(Object3D pointer, ArrayList<Object3D> currentPath, int dist)
|
||||||
{
|
{
|
||||||
if(pointer == null)
|
if(pointer == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterated.add(pointer);
|
currentPath.add(pointer);
|
||||||
|
|
||||||
if(pointer.color == EnumColor.BLACK)
|
if(pointer.getMetadata(worldObj) == 4)
|
||||||
{
|
{
|
||||||
dist += 1000;
|
dist += 1000;
|
||||||
}
|
}
|
||||||
|
@ -129,225 +166,69 @@ public final class TransporterPathfinder
|
||||||
|
|
||||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
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))
|
if(TransporterUtils.canInsert(tile, transportStack.itemStack, side.ordinal()) && !(tile instanceof TileEntityLogisticalTransporter))
|
||||||
{
|
{
|
||||||
destinations.put(Object3D.get(tile), dist);
|
destinations.add(new Destination(currentPath, Object3D.get(tile), dist));
|
||||||
prevNodes.put(Object3D.get(tile), Object3D.get(pointer));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
if(!obj.path.isEmpty() && !obj.path.get(0).equals(start))
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
currentNode = node;
|
closest = obj;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Object3D> getPath()
|
|
||||||
{
|
|
||||||
boolean foundPath = find(start);
|
|
||||||
|
|
||||||
if(foundPath)
|
if(closest == null)
|
||||||
{
|
{
|
||||||
if(target != null)
|
return null;
|
||||||
{
|
|
||||||
results.add(0, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return closest.path;
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Object3D> getNewPath(TileEntityLogisticalTransporter start, TransporterStack stack)
|
public static List<Object3D> getNewPath(TileEntityLogisticalTransporter start, TransporterStack stack)
|
||||||
{
|
{
|
||||||
Destination d = new Destination(start.worldObj, start, stack);
|
DestPath d = new DestPath(start.worldObj, Object3D.get(start), stack);
|
||||||
Object3D closest = d.find();
|
List<Object3D> path = d.find();
|
||||||
|
|
||||||
if(closest == null)
|
if(path == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Path p = new Path(d.worldObj, d.prevNodes.get(closest), Object3D.get(start), closest, stack);
|
return path;
|
||||||
return p.getPath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Object3D> getIdlePath(TileEntityLogisticalTransporter start, TransporterStack stack)
|
public static List<Object3D> getIdlePath(TileEntityLogisticalTransporter start, TransporterStack stack)
|
||||||
{
|
{
|
||||||
IdleDest d = new IdleDest(start.worldObj, start, stack);
|
IdlePath d = new IdlePath(start.worldObj, Object3D.get(start), stack);
|
||||||
Object3D farthest = d.find();
|
List<Object3D> path = d.find();
|
||||||
|
|
||||||
if(farthest == null || farthest.equals(Object3D.get(start)))
|
if(path == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Path p = new Path(start.worldObj, farthest, Object3D.get(start), null, stack);
|
return path;
|
||||||
return p.getPath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,10 @@ public class TransporterStack
|
||||||
{
|
{
|
||||||
if(progress < 50)
|
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)
|
else if(progress == 50)
|
||||||
{
|
{
|
||||||
|
@ -215,7 +218,10 @@ public class TransporterStack
|
||||||
}
|
}
|
||||||
else if(progress > 50)
|
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;
|
return 0;
|
||||||
|
|
|
@ -71,50 +71,52 @@ public final class MekanismUtils
|
||||||
*/
|
*/
|
||||||
public static boolean checkForUpdates(EntityPlayer entityplayer)
|
public static boolean checkForUpdates(EntityPlayer entityplayer)
|
||||||
{
|
{
|
||||||
if(Mekanism.updateNotifications && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null)
|
try {
|
||||||
{
|
if(Mekanism.updateNotifications && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null)
|
||||||
if(!Mekanism.latestVersionNumber.equals("null"))
|
|
||||||
{
|
{
|
||||||
ArrayList<IModule> list = new ArrayList<IModule>();
|
if(!Mekanism.latestVersionNumber.equals("null"))
|
||||||
|
|
||||||
for(IModule module : Mekanism.modulesLoaded)
|
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1 || !list.isEmpty())
|
System.out.println("[Mekanism] Minecraft is in offline mode, could not check for updates.");
|
||||||
{
|
|
||||||
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 {
|
} catch(Exception e) {}
|
||||||
System.out.println("[Mekanism] Minecraft is in offline mode, could not check for updates.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ public final class TransporterUtils
|
||||||
ret.add(EnumColor.RED);
|
ret.add(EnumColor.RED);
|
||||||
ret.add(EnumColor.PINK);
|
ret.add(EnumColor.PINK);
|
||||||
ret.add(EnumColor.YELLOW);
|
ret.add(EnumColor.YELLOW);
|
||||||
ret.add(EnumColor.BLACK);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -357,10 +356,14 @@ public final class TransporterUtils
|
||||||
|
|
||||||
public static EnumColor increment(EnumColor color)
|
public static EnumColor increment(EnumColor color)
|
||||||
{
|
{
|
||||||
if(colors.indexOf(color) == colors.size()-1)
|
if(color == null)
|
||||||
{
|
{
|
||||||
return colors.get(0);
|
return colors.get(0);
|
||||||
}
|
}
|
||||||
|
else if(colors.indexOf(color) == colors.size()-1)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return colors.get(colors.indexOf(color)+1);
|
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 |
|
@ -67,6 +67,7 @@ tile.Transmitter.PressurizedTube.name=Pressurized Tube
|
||||||
tile.Transmitter.UniversalCable.name=Universal Cable
|
tile.Transmitter.UniversalCable.name=Universal Cable
|
||||||
tile.Transmitter.MechanicalPipe.name=Mechanical Pipe
|
tile.Transmitter.MechanicalPipe.name=Mechanical Pipe
|
||||||
tile.Transmitter.LogisticalTransporter.name=Logistical Transporter
|
tile.Transmitter.LogisticalTransporter.name=Logistical Transporter
|
||||||
|
tile.Transmitter.RestrictiveTransporter.name=Restrictive Transporter
|
||||||
|
|
||||||
//Energy Cubes
|
//Energy Cubes
|
||||||
tile.EnergyCube.Basic.name=Basic Energy Cube
|
tile.EnergyCube.Basic.name=Basic Energy Cube
|
||||||
|
|
BIN
resources/assets/mekanism/render/RestrictiveTransporter.png
Normal file
BIN
resources/assets/mekanism/render/RestrictiveTransporter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.6 KiB |
Loading…
Reference in a new issue