Filters are now editable by GUI!
This commit is contained in:
parent
a500d0f592
commit
cb555e90a6
7 changed files with 90 additions and 35 deletions
|
@ -28,6 +28,8 @@ public class GuiItemStackFilter extends GuiMekanism
|
||||||
|
|
||||||
public boolean isNew = false;
|
public boolean isNew = false;
|
||||||
|
|
||||||
|
public ItemStackFilter origFilter;
|
||||||
|
|
||||||
public ItemStackFilter filter = new ItemStackFilter();
|
public ItemStackFilter filter = new ItemStackFilter();
|
||||||
|
|
||||||
public String status = EnumColor.DARK_GREEN + "All OK";
|
public String status = EnumColor.DARK_GREEN + "All OK";
|
||||||
|
@ -39,7 +41,8 @@ public class GuiItemStackFilter extends GuiMekanism
|
||||||
super(new ContainerFilter(player.inventory));
|
super(new ContainerFilter(player.inventory));
|
||||||
tileEntity = tentity;
|
tileEntity = tentity;
|
||||||
|
|
||||||
filter = (ItemStackFilter)tileEntity.filters.get(index);
|
origFilter = (ItemStackFilter)tileEntity.filters.get(index);
|
||||||
|
filter = ((ItemStackFilter)tileEntity.filters.get(index)).clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiItemStackFilter(EntityPlayer player, TileEntityLogisticalSorter tentity)
|
public GuiItemStackFilter(EntityPlayer player, TileEntityLogisticalSorter tentity)
|
||||||
|
@ -84,7 +87,7 @@ public class GuiItemStackFilter extends GuiMekanism
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketNewFilter().setParams(Object3D.get(tileEntity), filter));
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketNewFilter().setParams(Object3D.get(tileEntity), filter));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Object3D.get(tileEntity), false, filter));
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Object3D.get(tileEntity), false, origFilter, filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0));
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0));
|
||||||
|
@ -96,7 +99,7 @@ public class GuiItemStackFilter extends GuiMekanism
|
||||||
}
|
}
|
||||||
else if(guibutton.id == 1)
|
else if(guibutton.id == 1)
|
||||||
{
|
{
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Object3D.get(tileEntity), true, filter));
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Object3D.get(tileEntity), true, origFilter));
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0));
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import mekanism.common.network.PacketLogisticalSorterGui;
|
||||||
import mekanism.common.network.PacketLogisticalSorterGui.SorterGuiPacket;
|
import mekanism.common.network.PacketLogisticalSorterGui.SorterGuiPacket;
|
||||||
import mekanism.common.network.PacketNewFilter;
|
import mekanism.common.network.PacketNewFilter;
|
||||||
import mekanism.common.tileentity.TileEntityLogisticalSorter;
|
import mekanism.common.tileentity.TileEntityLogisticalSorter;
|
||||||
|
import mekanism.common.transporter.ItemStackFilter;
|
||||||
import mekanism.common.transporter.OreDictFilter;
|
import mekanism.common.transporter.OreDictFilter;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||||
|
@ -35,6 +36,8 @@ public class GuiOreDictFilter extends GuiMekanism
|
||||||
|
|
||||||
public boolean isNew = false;
|
public boolean isNew = false;
|
||||||
|
|
||||||
|
public OreDictFilter origFilter;
|
||||||
|
|
||||||
public OreDictFilter filter = new OreDictFilter();
|
public OreDictFilter filter = new OreDictFilter();
|
||||||
|
|
||||||
private GuiTextField oreDictText;
|
private GuiTextField oreDictText;
|
||||||
|
@ -56,7 +59,10 @@ public class GuiOreDictFilter extends GuiMekanism
|
||||||
super(new ContainerFilter(player.inventory));
|
super(new ContainerFilter(player.inventory));
|
||||||
tileEntity = tentity;
|
tileEntity = tentity;
|
||||||
|
|
||||||
filter = (OreDictFilter)tentity.filters.get(index);
|
origFilter = (OreDictFilter)tileEntity.filters.get(index);
|
||||||
|
filter = ((OreDictFilter)tentity.filters.get(index)).clone();
|
||||||
|
|
||||||
|
updateStackList(filter.oreDictName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiOreDictFilter(EntityPlayer player, TileEntityLogisticalSorter tentity)
|
public GuiOreDictFilter(EntityPlayer player, TileEntityLogisticalSorter tentity)
|
||||||
|
@ -94,13 +100,10 @@ public class GuiOreDictFilter extends GuiMekanism
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(char c, int i)
|
public void keyTyped(char c, int i)
|
||||||
{
|
{
|
||||||
if(i == Keyboard.KEY_E)
|
if(!oreDictText.isFocused() || i == Keyboard.KEY_ESCAPE)
|
||||||
{
|
{
|
||||||
oreDictText.textboxKeyTyped(c, i);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
super.keyTyped(c, i);
|
super.keyTyped(c, i);
|
||||||
|
}
|
||||||
|
|
||||||
if(oreDictText.isFocused() && i == Keyboard.KEY_RETURN)
|
if(oreDictText.isFocused() && i == Keyboard.KEY_RETURN)
|
||||||
{
|
{
|
||||||
|
@ -121,6 +124,11 @@ public class GuiOreDictFilter extends GuiMekanism
|
||||||
|
|
||||||
if(guibutton.id == 0)
|
if(guibutton.id == 0)
|
||||||
{
|
{
|
||||||
|
if(!oreDictText.getText().isEmpty())
|
||||||
|
{
|
||||||
|
setOreDictKey();
|
||||||
|
}
|
||||||
|
|
||||||
if(filter.oreDictName != null && !filter.oreDictName.isEmpty())
|
if(filter.oreDictName != null && !filter.oreDictName.isEmpty())
|
||||||
{
|
{
|
||||||
if(isNew)
|
if(isNew)
|
||||||
|
@ -128,7 +136,7 @@ public class GuiOreDictFilter extends GuiMekanism
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketNewFilter().setParams(Object3D.get(tileEntity), filter));
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketNewFilter().setParams(Object3D.get(tileEntity), filter));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Object3D.get(tileEntity), false, filter));
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Object3D.get(tileEntity), false, origFilter, filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0));
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0));
|
||||||
|
@ -140,7 +148,7 @@ public class GuiOreDictFilter extends GuiMekanism
|
||||||
}
|
}
|
||||||
else if(guibutton.id == 1)
|
else if(guibutton.id == 1)
|
||||||
{
|
{
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Object3D.get(tileEntity), true, filter));
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Object3D.get(tileEntity), true, origFilter));
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0));
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,21 +296,8 @@ public class GuiOreDictFilter extends GuiMekanism
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOreDictKey()
|
private void updateStackList(String oreName)
|
||||||
{
|
{
|
||||||
String oreName = oreDictText.getText();
|
|
||||||
|
|
||||||
if(oreName == null || oreName.isEmpty())
|
|
||||||
{
|
|
||||||
status = EnumColor.DARK_RED + "No key entered";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if(oreName.equals(filter.oreDictName))
|
|
||||||
{
|
|
||||||
status = EnumColor.DARK_RED + "Same key";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(iterStacks == null)
|
if(iterStacks == null)
|
||||||
{
|
{
|
||||||
iterStacks = new ArrayList<ItemStack>();
|
iterStacks = new ArrayList<ItemStack>();
|
||||||
|
@ -355,10 +350,28 @@ public class GuiOreDictFilter extends GuiMekanism
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filter.oreDictName = oreName;
|
|
||||||
oreDictText.setText("");
|
|
||||||
|
|
||||||
stackSwitch = 0;
|
stackSwitch = 0;
|
||||||
stackIndex = -1;
|
stackIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setOreDictKey()
|
||||||
|
{
|
||||||
|
String oreName = oreDictText.getText();
|
||||||
|
|
||||||
|
if(oreName == null || oreName.isEmpty())
|
||||||
|
{
|
||||||
|
status = EnumColor.DARK_RED + "No key entered";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(oreName.equals(filter.oreDictName))
|
||||||
|
{
|
||||||
|
status = EnumColor.DARK_RED + "Same key";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateStackList(oreName);
|
||||||
|
|
||||||
|
filter.oreDictName = oreName;
|
||||||
|
oreDictText.setText("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ public class PacketEditFilter implements IMekanismPacket
|
||||||
{
|
{
|
||||||
public Object3D object3D;
|
public Object3D object3D;
|
||||||
|
|
||||||
|
public TransporterFilter filter;
|
||||||
|
|
||||||
public TransporterFilter edited;
|
public TransporterFilter edited;
|
||||||
|
|
||||||
public boolean delete;
|
public boolean delete;
|
||||||
|
@ -34,7 +36,12 @@ public class PacketEditFilter implements IMekanismPacket
|
||||||
{
|
{
|
||||||
object3D = (Object3D)data[0];
|
object3D = (Object3D)data[0];
|
||||||
delete = (Boolean)data[1];
|
delete = (Boolean)data[1];
|
||||||
edited = (TransporterFilter)data[2];
|
filter = (TransporterFilter)data[2];
|
||||||
|
|
||||||
|
if(!delete)
|
||||||
|
{
|
||||||
|
edited = (TransporterFilter)data[3];
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -45,14 +52,18 @@ public class PacketEditFilter implements IMekanismPacket
|
||||||
object3D = new Object3D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
|
object3D = new Object3D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
|
||||||
|
|
||||||
delete = dataStream.readBoolean();
|
delete = dataStream.readBoolean();
|
||||||
|
filter = TransporterFilter.readFromPacket(dataStream);
|
||||||
|
|
||||||
|
if(!delete)
|
||||||
|
{
|
||||||
edited = TransporterFilter.readFromPacket(dataStream);
|
edited = TransporterFilter.readFromPacket(dataStream);
|
||||||
|
}
|
||||||
|
|
||||||
World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(object3D.dimensionId);
|
World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(object3D.dimensionId);
|
||||||
|
|
||||||
if(worldServer != null && object3D.getTileEntity(worldServer) instanceof TileEntityLogisticalSorter)
|
if(worldServer != null && object3D.getTileEntity(worldServer) instanceof TileEntityLogisticalSorter)
|
||||||
{
|
{
|
||||||
TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)object3D.getTileEntity(worldServer);
|
TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)object3D.getTileEntity(worldServer);
|
||||||
TransporterFilter filter = TransporterFilter.readFromPacket(dataStream);
|
|
||||||
|
|
||||||
if(!sorter.filters.contains(filter))
|
if(!sorter.filters.contains(filter))
|
||||||
{
|
{
|
||||||
|
@ -87,7 +98,13 @@ public class PacketEditFilter implements IMekanismPacket
|
||||||
dataStream.writeBoolean(delete);
|
dataStream.writeBoolean(delete);
|
||||||
|
|
||||||
ArrayList data = new ArrayList();
|
ArrayList data = new ArrayList();
|
||||||
|
filter.write(data);
|
||||||
|
|
||||||
|
if(!delete)
|
||||||
|
{
|
||||||
edited.write(data);
|
edited.write(data);
|
||||||
|
}
|
||||||
|
|
||||||
PacketHandler.encode(data.toArray(), dataStream);
|
PacketHandler.encode(data.toArray(), dataStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,9 @@ public class PacketLogisticalSorterGui implements IMekanismPacket
|
||||||
}
|
}
|
||||||
|
|
||||||
player.openContainer.windowId = windowId;
|
player.openContainer.windowId = windowId;
|
||||||
} catch(Exception e) {}
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class PacketNewFilter implements IMekanismPacket
|
||||||
TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)object3D.getTileEntity(worldServer);
|
TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)object3D.getTileEntity(worldServer);
|
||||||
TransporterFilter filter = TransporterFilter.readFromPacket(dataStream);
|
TransporterFilter filter = TransporterFilter.readFromPacket(dataStream);
|
||||||
|
|
||||||
//sorter.filters.add(filter);
|
sorter.filters.add(filter);
|
||||||
|
|
||||||
for(EntityPlayer iterPlayer : sorter.playersUsing)
|
for(EntityPlayer iterPlayer : sorter.playersUsing)
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,4 +71,14 @@ public class ItemStackFilter extends TransporterFilter
|
||||||
{
|
{
|
||||||
return super.equals(filter) && filter instanceof ItemStackFilter && ((ItemStackFilter)filter).itemType.isItemEqual(itemType);
|
return super.equals(filter) && filter instanceof ItemStackFilter && ((ItemStackFilter)filter).itemType.isItemEqual(itemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStackFilter clone()
|
||||||
|
{
|
||||||
|
ItemStackFilter filter = new ItemStackFilter();
|
||||||
|
filter.color = color;
|
||||||
|
filter.itemType = itemType.copy();
|
||||||
|
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,4 +101,14 @@ public class OreDictFilter extends TransporterFilter
|
||||||
{
|
{
|
||||||
return super.equals(filter) && filter instanceof OreDictFilter && ((OreDictFilter)filter).oreDictName.equals(oreDictName);
|
return super.equals(filter) && filter instanceof OreDictFilter && ((OreDictFilter)filter).oreDictName.equals(oreDictName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OreDictFilter clone()
|
||||||
|
{
|
||||||
|
OreDictFilter filter = new OreDictFilter();
|
||||||
|
filter.color = color;
|
||||||
|
filter.oreDictName = oreDictName;
|
||||||
|
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue