This repository has been archived on 2024-07-18. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
mmm/src/java/mmm/utils/UContainers.java
Emmanuel BENOîT 8a68416361 Alloy furnace progress
+ Mostly working GUI
+ Many new utilities
=> A lot of this will need clean-up
2016-06-22 09:22:49 +02:00

44 lines
1.2 KiB
Java

package mmm.utils;
public class UContainers
{
public static interface SlotAdder
{
public void addSlot( int index , int x , int y );
}
public static void addPlayerInventory( final UContainers.SlotAdder slotAdder , final int x , final int y )
{
UContainers.addPlayerInventory( slotAdder , x , y , 4 );
}
public static void addPlayerInventory( final UContainers.SlotAdder slotAdder , final int x , final int y ,
final int spacing )
{
UContainers.addGrid( slotAdder , 9 , 3 , 9 , x , y ); // Main inventory
UContainers.addGrid( slotAdder , 9 , 1 , 0 , x , y + spacing + 54 ); // Quick bar
}
public static void addGrid( final UContainers.SlotAdder slotAdder , final int columns , final int rows ,
final int index , final int x , final int y )
{
addGrid( slotAdder , columns , rows , index , x , y , 2 , 2 );
}
public static void addGrid( final UContainers.SlotAdder slotAdder , final int columns , final int rows ,
final int index , final int x , final int y , int xSpacing , int ySpacing )
{
for ( int row = 0 , i = 0 ; row < rows ; ++row ) {
for ( int column = 0 ; column < columns ; ++column , ++i ) {
slotAdder.addSlot( index + i , x + column * ( 16 + xSpacing ) , y + row * ( 16 + ySpacing ) );
}
}
}
}