Create a sort order for interfaces based on their location.
This commit is contained in:
parent
f343ac36e8
commit
423e6be0c8
4 changed files with 38 additions and 10 deletions
|
@ -150,7 +150,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||||
{
|
{
|
||||||
long id = Long.parseLong( key.substring( 1 ), Character.MAX_RADIX );
|
long id = Long.parseLong( key.substring( 1 ), Character.MAX_RADIX );
|
||||||
NBTTagCompound invData = in.getCompoundTag( key );
|
NBTTagCompound invData = in.getCompoundTag( key );
|
||||||
ClientDCInternalInv current = getById( id, invData.getString( "un" ) );
|
ClientDCInternalInv current = getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) );
|
||||||
|
|
||||||
for (int x = 0; x < current.inv.getSizeInventory(); x++)
|
for (int x = 0; x < current.inv.getSizeInventory(); x++)
|
||||||
{
|
{
|
||||||
|
@ -182,21 +182,29 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||||
for (String n : names)
|
for (String n : names)
|
||||||
{
|
{
|
||||||
lines.add( n );
|
lines.add( n );
|
||||||
for (ClientDCInternalInv i : byName.get( n ))
|
|
||||||
|
ArrayList<ClientDCInternalInv> lset = new ArrayList();
|
||||||
|
lset.addAll( byName.get( n ) );
|
||||||
|
|
||||||
|
Collections.sort( lset );
|
||||||
|
|
||||||
|
for (ClientDCInternalInv i : lset)
|
||||||
|
{
|
||||||
lines.add( i );
|
lines.add( i );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
myScrollBar.setRange( 0, getTotalRows() - 6, 2 );
|
myScrollBar.setRange( 0, getTotalRows() - 6, 2 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClientDCInternalInv getById(long id, String string)
|
private ClientDCInternalInv getById(long id, long sortBy, String string)
|
||||||
{
|
{
|
||||||
ClientDCInternalInv o = byId.get( id );
|
ClientDCInternalInv o = byId.get( id );
|
||||||
|
|
||||||
if ( o == null )
|
if ( o == null )
|
||||||
{
|
{
|
||||||
byId.put( id, o = new ClientDCInternalInv( 9, id, string ) );
|
byId.put( id, o = new ClientDCInternalInv( 9, id, sortBy, string ) );
|
||||||
refreshList = true;
|
refreshList = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,18 +2,21 @@ package appeng.client.me;
|
||||||
|
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
import appeng.tile.inventory.AppEngInternalInventory;
|
import appeng.tile.inventory.AppEngInternalInventory;
|
||||||
|
import appeng.util.ItemSorters;
|
||||||
|
|
||||||
public class ClientDCInternalInv
|
public class ClientDCInternalInv implements Comparable<ClientDCInternalInv>
|
||||||
{
|
{
|
||||||
|
|
||||||
final public String unlocalizedName;
|
final public String unlocalizedName;
|
||||||
final public long id;
|
|
||||||
final public AppEngInternalInventory inv;
|
final public AppEngInternalInventory inv;
|
||||||
|
final public long id;
|
||||||
|
final public long sortBy;
|
||||||
|
|
||||||
public ClientDCInternalInv(int size, long id, String unlocalizedName) {
|
public ClientDCInternalInv(int size, long id, long sortBy, String unlocalizedName) {
|
||||||
inv = new AppEngInternalInventory( null, size );
|
inv = new AppEngInternalInventory( null, size );
|
||||||
this.unlocalizedName = unlocalizedName;
|
this.unlocalizedName = unlocalizedName;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
this.sortBy = sortBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
|
@ -24,4 +27,10 @@ public class ClientDCInternalInv
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(ClientDCInternalInv o)
|
||||||
|
{
|
||||||
|
return ItemSorters.compareLong( sortBy, o.sortBy );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -45,14 +45,16 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
|
||||||
long which = autoBase++;
|
long which = autoBase++;
|
||||||
String unlocalizedName;
|
String unlocalizedName;
|
||||||
|
|
||||||
public InvTracker(IInventory patterns, String unlocalizedName) {
|
public InvTracker(DualityInterface dual, IInventory patterns, String unlocalizedName) {
|
||||||
server = patterns;
|
server = patterns;
|
||||||
client = new AppEngInternalInventory( null, server.getSizeInventory() );
|
client = new AppEngInternalInventory( null, server.getSizeInventory() );
|
||||||
this.unlocalizedName = unlocalizedName;
|
this.unlocalizedName = unlocalizedName;
|
||||||
|
this.sortBy = dual.getSortValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
IInventory client;
|
IInventory client;
|
||||||
IInventory server;
|
IInventory server;
|
||||||
|
public long sortBy;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -263,14 +265,14 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
|
||||||
{
|
{
|
||||||
IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||||
DualityInterface dual = ih.getInterfaceDuality();
|
DualityInterface dual = ih.getInterfaceDuality();
|
||||||
diList.put( ih, new InvTracker( dual.getPatterns(), dual.getTermName() ) );
|
diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IGridNode gn : g.getMachines( PartInterface.class ))
|
for (IGridNode gn : g.getMachines( PartInterface.class ))
|
||||||
{
|
{
|
||||||
IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||||
DualityInterface dual = ih.getInterfaceDuality();
|
DualityInterface dual = ih.getInterfaceDuality();
|
||||||
diList.put( ih, new InvTracker( dual.getPatterns(), dual.getTermName() ) );
|
diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,7 +293,10 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
|
||||||
NBTTagCompound invv = data.getCompoundTag( name );
|
NBTTagCompound invv = data.getCompoundTag( name );
|
||||||
|
|
||||||
if ( invv.hasNoTags() )
|
if ( invv.hasNoTags() )
|
||||||
|
{
|
||||||
|
invv.setLong( "sortBy", inv.sortBy );
|
||||||
invv.setString( "un", inv.unlocalizedName );
|
invv.setString( "un", inv.unlocalizedName );
|
||||||
|
}
|
||||||
|
|
||||||
for (int x = 0; x < length; x++)
|
for (int x = 0; x < length; x++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1045,4 +1045,10 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
||||||
|
|
||||||
return "Nothing";
|
return "Nothing";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getSortValue()
|
||||||
|
{
|
||||||
|
TileEntity te = iHost.getTileEntity();
|
||||||
|
return (te.zCoord << 24) ^ (te.xCoord << 8) ^ te.yCoord;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue