diff --git a/src/java/mmm/recipes/RShapedOreRecipeWrapper.java b/src/java/mmm/recipes/RShapedOreRecipeWrapper.java index ca1de7e..3f6efdb 100644 --- a/src/java/mmm/recipes/RShapedOreRecipeWrapper.java +++ b/src/java/mmm/recipes/RShapedOreRecipeWrapper.java @@ -56,7 +56,7 @@ public class RShapedOreRecipeWrapper @Override public String getName( ) { - return this.recipe.getRecipeOutput( ).getUnlocalizedName( ); + return this.recipe.getRecipeOutput( ).getUnlocalizedName( ) + ".name"; } diff --git a/src/java/mmm/recipes/RShapedRecipeWrapper.java b/src/java/mmm/recipes/RShapedRecipeWrapper.java index 1cf6b3d..0852660 100644 --- a/src/java/mmm/recipes/RShapedRecipeWrapper.java +++ b/src/java/mmm/recipes/RShapedRecipeWrapper.java @@ -40,7 +40,7 @@ public class RShapedRecipeWrapper @Override public String getName( ) { - return this.recipe.getRecipeOutput( ).getUnlocalizedName( ); + return this.recipe.getRecipeOutput( ).getUnlocalizedName( ) + ".name"; } diff --git a/src/java/mmm/recipes/RShapelessOreRecipeWrapper.java b/src/java/mmm/recipes/RShapelessOreRecipeWrapper.java index 790f54d..59d0560 100644 --- a/src/java/mmm/recipes/RShapelessOreRecipeWrapper.java +++ b/src/java/mmm/recipes/RShapelessOreRecipeWrapper.java @@ -78,7 +78,7 @@ public class RShapelessOreRecipeWrapper @Override public String getName( ) { - return this.recipe.getRecipeOutput( ).getUnlocalizedName( ); + return this.recipe.getRecipeOutput( ).getUnlocalizedName( ) + ".name"; } diff --git a/src/java/mmm/recipes/RShapelessRecipeWrapper.java b/src/java/mmm/recipes/RShapelessRecipeWrapper.java index f2d7f1a..e7b5bf1 100644 --- a/src/java/mmm/recipes/RShapelessRecipeWrapper.java +++ b/src/java/mmm/recipes/RShapelessRecipeWrapper.java @@ -56,7 +56,7 @@ public class RShapelessRecipeWrapper @Override public String getName( ) { - return this.recipe.getRecipeOutput( ).getUnlocalizedName( ); + return this.recipe.getRecipeOutput( ).getUnlocalizedName( ) + ".name"; } diff --git a/src/java/mmm/tech/base/workbench/TBWBGui.java b/src/java/mmm/tech/base/workbench/TBWBGui.java index 9d0f568..fe8e25d 100644 --- a/src/java/mmm/tech/base/workbench/TBWBGui.java +++ b/src/java/mmm/tech/base/workbench/TBWBGui.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; import mmm.Mmm; +import mmm.core.CNetwork; import mmm.core.api.recipes.I_CraftingRecipeWrapper; import mmm.recipes.RCraftingWrappers; import mmm.utils.gui.A_UGContainerScreen; @@ -72,7 +73,7 @@ public class TBWBGui this.buttonList.add( this.bPrevious ); this.buttonList.add( this.bNext ); this.buttonList.add( this.bSetDefault ); - + this.enableButtons( ); } @@ -130,8 +131,9 @@ public class TBWBGui index = 0; } this.currentRecipe = index; - this.container.setCurrentRecipe( index == -1 ? null : this.recipes.get( index ) , false ); - // CNetwork.sendToServer( new TBAFMessage( rName , false ) ); + I_CraftingRecipeWrapper wrapper = index == -1 ? null : this.recipes.get( index ); + this.container.setCurrentRecipe( wrapper , false ); + CNetwork.sendToServer( new TBWBMessage( wrapper == null ? null : wrapper.getIdentifier( ) , false ) ); this.enableButtons( ); } diff --git a/src/java/mmm/tech/base/workbench/TBWBMessage.java b/src/java/mmm/tech/base/workbench/TBWBMessage.java new file mode 100644 index 0000000..3cce70c --- /dev/null +++ b/src/java/mmm/tech/base/workbench/TBWBMessage.java @@ -0,0 +1,69 @@ +package mmm.tech.base.workbench; + + +import io.netty.buffer.ByteBuf; +import mmm.core.api.I_Message; +import mmm.core.api.recipes.I_CraftingRecipeWrapper; +import mmm.recipes.RCraftingWrappers; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Container; +import net.minecraftforge.fml.common.network.ByteBufUtils; + + + +public class TBWBMessage + implements I_Message +{ + private String name; + private boolean setDefault; + + + public TBWBMessage( ) + { + // EMPTY + } + + + public TBWBMessage( final String name , final boolean setDefault ) + { + this.name = name; + this.setDefault = setDefault; + } + + + @Override + public void fromBytes( final ByteBuf buf ) + { + if ( buf.readBoolean( ) ) { + this.name = ByteBufUtils.readUTF8String( buf ); + } else { + this.name = null; + } + this.setDefault = buf.readBoolean( ); + } + + + @Override + public void toBytes( final ByteBuf buf ) + { + buf.writeBoolean( this.name != null ); + if ( this.name != null ) { + ByteBufUtils.writeUTF8String( buf , this.name ); + } + buf.writeBoolean( this.setDefault ); + } + + + @Override + public void handleOnServer( final EntityPlayerMP player ) + { + final Container curCont = player.openContainer; + if ( ! ( curCont instanceof TBWBContainer ) ) { + return; + } + final TBWBContainer container = (TBWBContainer) curCont; + final I_CraftingRecipeWrapper wrapper = RCraftingWrappers.IDENTIFIERS.get( this.name ); + container.setCurrentRecipe( wrapper , this.setDefault ); + } + +} diff --git a/src/java/mmm/tech/base/workbench/TBWorkbench.java b/src/java/mmm/tech/base/workbench/TBWorkbench.java index 2116713..ed8beba 100644 --- a/src/java/mmm/tech/base/workbench/TBWorkbench.java +++ b/src/java/mmm/tech/base/workbench/TBWorkbench.java @@ -2,6 +2,7 @@ package mmm.tech.base.workbench; import mmm.core.CGui; +import mmm.core.CNetwork; import mmm.core.CRegistry; import mmm.core.api.I_RecipeRegistrar; import net.minecraft.block.BlockContainer; @@ -55,6 +56,7 @@ public class TBWorkbench CGui.registerTileEntityGUI( TBWBTileEntity.class , // "mmm.tech.base.workbench.TBWBContainer" , // "mmm.tech.base.workbench.TBWBGui" ); + CNetwork.addServerMessage( TBWBMessage.class ); }