Alloy furnace GUI works
This commit is contained in:
parent
8a68416361
commit
ef65afe909
5 changed files with 41 additions and 14 deletions
|
@ -8,6 +8,7 @@ import mmm.materials.MAlloyRecipesRegistry;
|
||||||
import mmm.utils.UContainers;
|
import mmm.utils.UContainers;
|
||||||
import mmm.utils.UInventoryDisplay;
|
import mmm.utils.UInventoryDisplay;
|
||||||
import mmm.utils.UInventoryGrid;
|
import mmm.utils.UInventoryGrid;
|
||||||
|
import mmm.utils.URegistry;
|
||||||
import mmm.utils.slots.USDisplay;
|
import mmm.utils.slots.USDisplay;
|
||||||
import mmm.utils.slots.USFuel;
|
import mmm.utils.slots.USFuel;
|
||||||
import mmm.utils.slots.USOutput;
|
import mmm.utils.slots.USOutput;
|
||||||
|
@ -98,8 +99,11 @@ public class TBAlloyFurnaceContainer
|
||||||
this.recipe.setInventorySlotContents( i , recipe.inputs[ i ] );
|
this.recipe.setInventorySlotContents( i , recipe.inputs[ i ] );
|
||||||
}
|
}
|
||||||
this.recipe.setInventorySlotContents( 6 , recipe.output );
|
this.recipe.setInventorySlotContents( 6 , recipe.output );
|
||||||
|
|
||||||
// XXX confirm
|
if ( confirm ) {
|
||||||
|
this.tileEntity.currentRecipe = index;
|
||||||
|
URegistry.network.sendToAll( new TBAlloyFurnaceMessage( position , index , true ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,7 @@ public class TBAlloyFurnaceGui
|
||||||
private final TBAlloyFurnaceContainer container;
|
private final TBAlloyFurnaceContainer container;
|
||||||
private ArrowButton bPrevious;
|
private ArrowButton bPrevious;
|
||||||
private ArrowButton bNext;
|
private ArrowButton bNext;
|
||||||
|
private GuiButton bConfirm;
|
||||||
private TBAlloyFurnaceGui.Tab selectedTab = Tab.MAIN;
|
private TBAlloyFurnaceGui.Tab selectedTab = Tab.MAIN;
|
||||||
private int currentRecipe = 0;
|
private int currentRecipe = 0;
|
||||||
|
|
||||||
|
@ -115,7 +116,7 @@ public class TBAlloyFurnaceGui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setRecipe( 0 );
|
this.setRecipe( tileEntity.currentRecipe );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,10 +130,14 @@ public class TBAlloyFurnaceGui
|
||||||
|
|
||||||
this.bPrevious = new ArrowButton( 1 , 8 + x , 47 + y , false );
|
this.bPrevious = new ArrowButton( 1 , 8 + x , 47 + y , false );
|
||||||
this.bNext = new ArrowButton( 2 , 156 + x , 47 + y , true );
|
this.bNext = new ArrowButton( 2 , 156 + x , 47 + y , true );
|
||||||
this.bPrevious.visible = this.bNext.visible = false;
|
this.bConfirm = new GuiButton( 3 , 24 + x , 84 + y , 128 , 20 , "Select recipe" ); // XXX
|
||||||
|
// I18n
|
||||||
|
this.bPrevious.visible = this.bNext.visible = this.bConfirm.visible = false;
|
||||||
|
|
||||||
this.buttonList.add( this.bNext );
|
this.buttonList.add( this.bNext );
|
||||||
this.buttonList.add( this.bPrevious );
|
this.buttonList.add( this.bPrevious );
|
||||||
|
this.buttonList.add( this.bConfirm );
|
||||||
|
|
||||||
this.enableConfigButtons( );
|
this.enableConfigButtons( );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,8 +145,12 @@ public class TBAlloyFurnaceGui
|
||||||
private void enableConfigButtons( )
|
private void enableConfigButtons( )
|
||||||
{
|
{
|
||||||
if ( this.bNext != null ) {
|
if ( this.bNext != null ) {
|
||||||
|
boolean visible = ( this.selectedTab == Tab.CONFIG );
|
||||||
|
this.bNext.visible = this.bPrevious.visible = this.bConfirm.visible = visible;
|
||||||
|
|
||||||
this.bNext.enabled = this.currentRecipe < MAlloyRecipesRegistry.INSTANCE.getSortedRecipes( ).size( ) - 1;
|
this.bNext.enabled = this.currentRecipe < MAlloyRecipesRegistry.INSTANCE.getSortedRecipes( ).size( ) - 1;
|
||||||
this.bPrevious.enabled = this.currentRecipe > 0;
|
this.bPrevious.enabled = this.currentRecipe > 0;
|
||||||
|
this.bConfirm.enabled = ( this.currentRecipe != this.container.tileEntity.currentRecipe );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +223,13 @@ public class TBAlloyFurnaceGui
|
||||||
this.setRecipe( this.currentRecipe + 1 );
|
this.setRecipe( this.currentRecipe + 1 );
|
||||||
} else if ( button == this.bPrevious ) {
|
} else if ( button == this.bPrevious ) {
|
||||||
this.setRecipe( this.currentRecipe - 1 );
|
this.setRecipe( this.currentRecipe - 1 );
|
||||||
|
} else if ( button == this.bConfirm ) {
|
||||||
|
URegistry.network.sendToServer(
|
||||||
|
new TBAlloyFurnaceMessage( this.container.tileEntity.getPos( ) , this.currentRecipe , true ) );
|
||||||
|
this.container.tileEntity.currentRecipe = this.currentRecipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.enableConfigButtons( );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -245,12 +260,6 @@ public class TBAlloyFurnaceGui
|
||||||
.hideGroup( this.selectedTab.slotGroup ) //
|
.hideGroup( this.selectedTab.slotGroup ) //
|
||||||
.showGroup( tab.slotGroup );
|
.showGroup( tab.slotGroup );
|
||||||
this.selectedTab = tab;
|
this.selectedTab = tab;
|
||||||
|
this.enableConfigButtons( );
|
||||||
this.bNext.visible = tab == Tab.CONFIG;
|
|
||||||
this.bPrevious.visible = tab == Tab.CONFIG;
|
|
||||||
if ( tab == Tab.CONFIG ) {
|
|
||||||
this.bNext.enabled = this.currentRecipe < MAlloyRecipesRegistry.INSTANCE.getSortedRecipes( ).size( ) - 1;
|
|
||||||
this.bPrevious.enabled = this.currentRecipe > 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,9 @@ import mmm.utils.I_UMessage;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@ -58,7 +60,14 @@ public class TBAlloyFurnaceMessage
|
||||||
@SideOnly( Side.CLIENT )
|
@SideOnly( Side.CLIENT )
|
||||||
public void handleOnClient( final EntityPlayerSP player )
|
public void handleOnClient( final EntityPlayerSP player )
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
World world = player.getEntityWorld( );
|
||||||
|
TileEntity te = world.getTileEntity( this.blockPos );
|
||||||
|
if ( ! ( te instanceof TBAlloyFurnaceTileEntity ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TBAlloyFurnaceTileEntity afte = (TBAlloyFurnaceTileEntity) te;
|
||||||
|
afte.currentRecipe = this.selectedIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ public class TBAlloyFurnaceTileEntity
|
||||||
public final UInventoryGrid input;
|
public final UInventoryGrid input;
|
||||||
public final UInventoryGrid fuel;
|
public final UInventoryGrid fuel;
|
||||||
public final UInventoryGrid output;
|
public final UInventoryGrid output;
|
||||||
|
public int currentRecipe; // XXX That's a terrible idea
|
||||||
|
|
||||||
|
|
||||||
public TBAlloyFurnaceTileEntity( )
|
public TBAlloyFurnaceTileEntity( )
|
||||||
|
@ -22,26 +23,29 @@ public class TBAlloyFurnaceTileEntity
|
||||||
this.input = new UInventoryGrid( "Input" , 3 , 5 );
|
this.input = new UInventoryGrid( "Input" , 3 , 5 );
|
||||||
this.fuel = new UInventoryGrid( "Fuel" , 2 , 2 );
|
this.fuel = new UInventoryGrid( "Fuel" , 2 , 2 );
|
||||||
this.output = new UInventoryGrid( "Output" , 2 , 5 );
|
this.output = new UInventoryGrid( "Output" , 2 , 5 );
|
||||||
|
this.currentRecipe = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT( NBTTagCompound compound )
|
public void readFromNBT( final NBTTagCompound compound )
|
||||||
{
|
{
|
||||||
super.readFromNBT( compound );
|
super.readFromNBT( compound );
|
||||||
this.input.deserializeNBT( compound.getTagList( "Input" , NBT.TAG_COMPOUND ) );
|
this.input.deserializeNBT( compound.getTagList( "Input" , NBT.TAG_COMPOUND ) );
|
||||||
this.fuel.deserializeNBT( compound.getTagList( "Fuel" , NBT.TAG_COMPOUND ) );
|
this.fuel.deserializeNBT( compound.getTagList( "Fuel" , NBT.TAG_COMPOUND ) );
|
||||||
this.output.deserializeNBT( compound.getTagList( "Output" , NBT.TAG_COMPOUND ) );
|
this.output.deserializeNBT( compound.getTagList( "Output" , NBT.TAG_COMPOUND ) );
|
||||||
|
this.currentRecipe = compound.getInteger( "Recipe" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound writeToNBT( NBTTagCompound compound )
|
public NBTTagCompound writeToNBT( final NBTTagCompound compound )
|
||||||
{
|
{
|
||||||
super.writeToNBT( compound );
|
super.writeToNBT( compound );
|
||||||
compound.setTag( "Input" , this.input.serializeNBT( ) );
|
compound.setTag( "Input" , this.input.serializeNBT( ) );
|
||||||
compound.setTag( "Fuel" , this.fuel.serializeNBT( ) );
|
compound.setTag( "Fuel" , this.fuel.serializeNBT( ) );
|
||||||
compound.setTag( "Output" , this.output.serializeNBT( ) );
|
compound.setTag( "Output" , this.output.serializeNBT( ) );
|
||||||
|
compound.setInteger( "Recipe" , this.currentRecipe );
|
||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ public class TechBase
|
||||||
GameRegistry.registerTileEntity( TBAlloyFurnaceTileEntity.class , "mmm:tech/base/alloy_furnace" );
|
GameRegistry.registerTileEntity( TBAlloyFurnaceTileEntity.class , "mmm:tech/base/alloy_furnace" );
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler( Mmm.get( ) , new TBAlloyFurnaceGuiHandler( ) );
|
NetworkRegistry.INSTANCE.registerGuiHandler( Mmm.get( ) , new TBAlloyFurnaceGuiHandler( ) );
|
||||||
URegistry.addServerMessage( TBAlloyFurnaceMessage.class );
|
URegistry.addServerMessage( TBAlloyFurnaceMessage.class );
|
||||||
|
URegistry.addClientMessage( TBAlloyFurnaceMessage.class );
|
||||||
|
|
||||||
// FIXME test, remove this later
|
// FIXME test, remove this later
|
||||||
MAlloyRecipesRegistry.INSTANCE.addRecipe( 200 , 0.05f , Items.COOKED_CHICKEN , Items.COOKED_BEEF ,
|
MAlloyRecipesRegistry.INSTANCE.addRecipe( 200 , 0.05f , Items.COOKED_CHICKEN , Items.COOKED_BEEF ,
|
||||||
|
|
Reference in a new issue