mirror of
https://github.com/GTNewHorizons/ThaumicEnergistics.git
synced 2026-10-25 20:32:27 +00:00
Quality & Safety
Added a lot of safety checks to arcane patterns. Updated name of storage components and cells to better match AE2's. Fixes #260 - Players preferred item is now used in arcane patterns. QOL: Essentia terminal aspects are now un-selectable.
This commit is contained in:
1 parent
1d4700f6b1
commit
6fcc282a80
11 files changed
+502
-203
No files matched your search
+7
-1
@@ -1,4 +1,10 @@
|
||||
12/27/2015 0.9.1.0 - Beta
|
||||
12/28/2015 0.9.1.1 - Beta
|
||||
Added a lot of safety checks to arcane patterns.
|
||||
Updated name of storage components and cells to better match AE2's.
|
||||
Fixes #260 - Players preferred item is now used in arcane patterns.
|
||||
QOL: Essentia terminal aspects are now un-selectable.
|
||||
|
||||
12/27/2015 0.9.1.0 - Beta
|
||||
Fixes #112 - A.C.T can now issue crafting jobs!
|
||||
Fixes #230 - Arcane patterns now respect substitutions.
|
||||
Note: This change is NOT retro-active. Knowledge cores must have their patterns re-saved in order for the changes to take effect.
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ buildscript {
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "0.9.1.0"
|
||||
version = "0.9.1.1"
|
||||
group= "thaumicenergistics" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "thaumicenergistics"
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ThaumicEnergistics
|
||||
/**
|
||||
* Current version of the mod.
|
||||
*/
|
||||
public static final String VERSION = "0.9.1.0"; // Note: don't forget to change the build.gradle file as well
|
||||
public static final String VERSION = "0.9.1.1"; // Note: don't forget to change the build.gradle file as well
|
||||
|
||||
/**
|
||||
* Singleton instance
|
||||
|
||||
@@ -275,6 +275,64 @@ public class ContainerKnowledgeInscriber
|
||||
this.patternSlot_last = this.patternSlots[this.patternSlots.length - 1].slotNumber;
|
||||
}
|
||||
|
||||
private void loadPattern( final ArcaneCraftingPattern pattern )
|
||||
{
|
||||
if( ( pattern == null ) || ( !pattern.isPatternValid() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Set the slots
|
||||
for( int index = 0; index < this.craftingSlots.length; index++ )
|
||||
{
|
||||
IAEItemStack ingStack = pattern.getInputs()[index];
|
||||
if( ingStack != null )
|
||||
{
|
||||
this.craftingSlots[index].putStack( ingStack.getItemStack() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.craftingSlots[index].putStack( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares input to a pattern from the current recipe
|
||||
*
|
||||
* @param input
|
||||
* @param slotNumber
|
||||
* @return
|
||||
*/
|
||||
private Object preparePatternInput( final Object input, final int slotNumber )
|
||||
{
|
||||
if( input instanceof ArrayList )
|
||||
{
|
||||
// Get the prefered item
|
||||
ItemStack preferedItem = this.craftingSlots[slotNumber].getStack();
|
||||
|
||||
// Create the list
|
||||
ArrayList<ItemStack> ingList = new ArrayList<ItemStack>();
|
||||
|
||||
// Add the prefered item first
|
||||
ingList.add( preferedItem );
|
||||
|
||||
// Add the rest
|
||||
ArrayList<ItemStack> inputList = (ArrayList<ItemStack>)input;
|
||||
for( ItemStack item : inputList )
|
||||
{
|
||||
if( ( item == null ) || ( ItemStack.areItemStacksEqual( preferedItem, item ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ingList.add( item );
|
||||
}
|
||||
|
||||
return ingList;
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the slots to reflect the stored patterns.
|
||||
*/
|
||||
@@ -401,9 +459,9 @@ public class ContainerKnowledgeInscriber
|
||||
if( this.activeRecipe instanceof ShapedArcaneRecipe )
|
||||
{
|
||||
ShapedArcaneRecipe recipe = (ShapedArcaneRecipe)this.activeRecipe;
|
||||
for( int index = 0; index < recipe.input.length; ++index )
|
||||
for( int slotNumber = 0; slotNumber < recipe.input.length; ++slotNumber )
|
||||
{
|
||||
inputs[index] = recipe.input[index];
|
||||
inputs[slotNumber] = this.preparePatternInput( recipe.input[slotNumber], slotNumber );
|
||||
}
|
||||
}
|
||||
// Is the recipe shapeless?
|
||||
@@ -411,9 +469,9 @@ public class ContainerKnowledgeInscriber
|
||||
{
|
||||
ShapelessArcaneRecipe recipe = (ShapelessArcaneRecipe)this.activeRecipe;
|
||||
ArrayList ings = recipe.getInput();
|
||||
for( int index = 0; index < ings.size(); ++index )
|
||||
for( int slotNumber = 0; slotNumber < ings.size(); ++slotNumber )
|
||||
{
|
||||
inputs[index] = ings.get( index );
|
||||
inputs[slotNumber] = this.preparePatternInput( ings.get( slotNumber ), slotNumber );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -434,6 +492,7 @@ public class ContainerKnowledgeInscriber
|
||||
|
||||
// Update the slots
|
||||
this.updatePatternSlots();
|
||||
this.loadPattern( pattern );
|
||||
|
||||
// Update the client
|
||||
this.onClientRequestFullUpdate( player );
|
||||
@@ -547,21 +606,7 @@ public class ContainerKnowledgeInscriber
|
||||
if( clickedSlot.getHasStack() )
|
||||
{
|
||||
// Load the pattern
|
||||
ArcaneCraftingPattern pattern = this.kCoreHandler.getPatternForItem( clickedSlot.getStack() );
|
||||
|
||||
// Set the slots
|
||||
for( int index = 0; index < this.craftingSlots.length; index++ )
|
||||
{
|
||||
IAEItemStack ingStack = pattern.getInputs()[index];
|
||||
if( ingStack != null )
|
||||
{
|
||||
this.craftingSlots[index].putStack( ingStack.getItemStack() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.craftingSlots[index].putStack( null );
|
||||
}
|
||||
}
|
||||
loadPattern( this.kCoreHandler.getPatternForItem( clickedSlot.getStack() ) );
|
||||
|
||||
// Update the matrix
|
||||
this.onCraftMatrixChanged( clickedSlot.inventory );
|
||||
|
||||
@@ -504,40 +504,52 @@ public class GuiEssentiaCellTerminal
|
||||
|
||||
int index = 0;
|
||||
|
||||
// Rows
|
||||
for( int y = 0; y < GuiEssentiaCellTerminal.ROWS_PER_PAGE; y++ )
|
||||
// Is the mouse in the widget area?
|
||||
if( GuiHelper.INSTANCE.isPointInGuiRegion(
|
||||
GuiEssentiaCellTerminal.WIDGET_OFFSET_Y,
|
||||
GuiEssentiaCellTerminal.WIDGET_OFFSET_X,
|
||||
GuiEssentiaCellTerminal.ROWS_PER_PAGE * AbstractWidget.WIDGET_SIZE,
|
||||
GuiEssentiaCellTerminal.WIDGETS_PER_ROW * AbstractWidget.WIDGET_SIZE,
|
||||
mouseX, mouseY, this.guiLeft, this.guiTop ) )
|
||||
{
|
||||
// Columns
|
||||
for( int x = 0; x < GuiEssentiaCellTerminal.WIDGETS_PER_ROW; x++ )
|
||||
// Rows
|
||||
for( int y = 0; y < GuiEssentiaCellTerminal.ROWS_PER_PAGE; y++ )
|
||||
{
|
||||
// Calculate the index
|
||||
index = ( ( y + this.currentScroll ) * GuiEssentiaCellTerminal.WIDGETS_PER_ROW ) + x;
|
||||
|
||||
// Is the index in bounds?
|
||||
if( index < listSize )
|
||||
// Columns
|
||||
for( int x = 0; x < GuiEssentiaCellTerminal.WIDGETS_PER_ROW; x++ )
|
||||
{
|
||||
// Get the widget at this index
|
||||
WidgetAspectSelector currentWidget = this.matchingSearchWidgets.get( index );
|
||||
// Calculate the index
|
||||
index = ( ( y + this.currentScroll ) * GuiEssentiaCellTerminal.WIDGETS_PER_ROW ) + x;
|
||||
|
||||
// Is the mouse over this widget?
|
||||
if( currentWidget.isMouseOverWidget( mouseX, mouseY ) )
|
||||
// Is the index in bounds?
|
||||
if( index < listSize )
|
||||
{
|
||||
// Play clicky sound
|
||||
Minecraft.getMinecraft().getSoundHandler()
|
||||
.playSound( PositionedSoundRecord.func_147674_a( new ResourceLocation( "gui.button.press" ), 1.0F ) );
|
||||
// Get the widget at this index
|
||||
WidgetAspectSelector currentWidget = this.matchingSearchWidgets.get( index );
|
||||
|
||||
// Send the click to the widget
|
||||
currentWidget.mouseClicked();
|
||||
// Is the mouse over this widget?
|
||||
if( currentWidget.isMouseOverWidget( mouseX, mouseY ) )
|
||||
{
|
||||
// Play clicky sound
|
||||
Minecraft.getMinecraft().getSoundHandler().playSound(
|
||||
PositionedSoundRecord.func_147674_a( new ResourceLocation( "gui.button.press" ), 1.0F ) );
|
||||
|
||||
// Stop searching and do not pass to super
|
||||
return;
|
||||
// Send the click to the widget
|
||||
currentWidget.mouseClicked();
|
||||
|
||||
// Stop searching and do not pass to super
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unselect
|
||||
this.baseContainer.setSelectedAspect( null );
|
||||
|
||||
// Stop searching
|
||||
y = GuiEssentiaCellTerminal.ROWS_PER_PAGE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Stop searching
|
||||
y = GuiEssentiaCellTerminal.ROWS_PER_PAGE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.aspect.AspectStack;
|
||||
import thaumicenergistics.util.GuiHelper;
|
||||
|
||||
@@ -220,10 +221,18 @@ public class WidgetAspectSelector
|
||||
@Override
|
||||
public void mouseClicked()
|
||||
{
|
||||
if( this.getAspect() != null )
|
||||
Aspect selected = null;
|
||||
|
||||
// Get the selected aspect
|
||||
AspectStack selectedStack = ( (IAspectSelectorGui)this.hostGUI ).getSelectedAspect();
|
||||
|
||||
// Does the selected aspect not match?
|
||||
if( ( selectedStack == null ) || ( selectedStack.aspect != this.getAspect() ) )
|
||||
{
|
||||
( (IAspectSelectorGui)this.hostGUI ).getContainer().setSelectedAspect( this.getAspect() );
|
||||
selected = this.getAspect();
|
||||
}
|
||||
|
||||
( (IAspectSelectorGui)this.hostGUI ).getContainer().setSelectedAspect( selected );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,32 +25,37 @@ public class ArcaneCraftingPattern
|
||||
/**
|
||||
* Aspects required.
|
||||
*/
|
||||
public AspectList aspects;
|
||||
protected AspectList aspects;
|
||||
|
||||
/**
|
||||
* Ingredients.
|
||||
*/
|
||||
public Object[] ingredients = new Object[ArcaneCraftingPattern.GRID_SIZE];
|
||||
protected Object[] ingredients = new Object[ArcaneCraftingPattern.GRID_SIZE];
|
||||
|
||||
/**
|
||||
* Crafting result.
|
||||
*/
|
||||
public IAEItemStack result;
|
||||
protected IAEItemStack result;
|
||||
|
||||
/**
|
||||
* The knowledge core this pattern belongs to.
|
||||
*/
|
||||
public ItemStack knowledgeCoreHost;
|
||||
protected ItemStack knowledgeCoreHost;
|
||||
|
||||
/**
|
||||
* Cached array of required aspects
|
||||
*/
|
||||
private Aspect[] cachedAspects;
|
||||
protected Aspect[] cachedAspects;
|
||||
|
||||
/**
|
||||
* Ingredients as AE itemstacks.
|
||||
*/
|
||||
private IAEItemStack[] ingredientsAE;
|
||||
protected IAEItemStack[] ingredientsAE;
|
||||
|
||||
/**
|
||||
* True if the recipe is valid.
|
||||
*/
|
||||
protected boolean isValid = false;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -72,6 +77,7 @@ public class ArcaneCraftingPattern
|
||||
this.result = AEApi.instance().storage().createItemStack( craftingResult );
|
||||
|
||||
// Set the ingredients
|
||||
boolean hasAtLeastOneValidInput = false;
|
||||
for( int index = 0; ( ( index < this.ingredients.length ) && ( index < craftingIngredients.length ) ); ++index )
|
||||
{
|
||||
// Get the next ingredient
|
||||
@@ -81,8 +87,12 @@ public class ArcaneCraftingPattern
|
||||
if( nextIng != null )
|
||||
{
|
||||
this.ingredients[index] = nextIng;
|
||||
hasAtLeastOneValidInput = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Set validity
|
||||
this.setPatternValidity( ( this.aspects.size() > 0 ) && ( this.result != null ) && hasAtLeastOneValidInput );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,6 +184,27 @@ public class ArcaneCraftingPattern
|
||||
}
|
||||
}
|
||||
|
||||
protected void setPatternValidity( final boolean valid )
|
||||
{
|
||||
// Set
|
||||
this.isValid = valid;
|
||||
|
||||
if( !valid )
|
||||
{
|
||||
// Clear all items.
|
||||
this.result = null;
|
||||
this.ingredientsAE = null;
|
||||
for( int index = 0; index < ArcaneCraftingPattern.GRID_SIZE; ++index )
|
||||
{
|
||||
this.ingredients[index] = null;
|
||||
}
|
||||
|
||||
// Clear aspects
|
||||
this.aspects = new AspectList();
|
||||
this.cachedAspects = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSubstitute()
|
||||
{
|
||||
@@ -181,6 +212,16 @@ public class ArcaneCraftingPattern
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the aspect cost for the specified aspect.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getAspectCost( final Aspect aspect )
|
||||
{
|
||||
return this.aspects.getAmount( aspect );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a cached array of the required aspects for this pattern.
|
||||
*
|
||||
@@ -270,10 +311,31 @@ public class ArcaneCraftingPattern
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the result of the craft.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IAEItemStack getResult()
|
||||
{
|
||||
return this.result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCraftable()
|
||||
{
|
||||
return( this.result != null );
|
||||
// Returning false prevents substitutions.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the recipe is valid.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isPatternValid()
|
||||
{
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -318,78 +380,202 @@ public class ArcaneCraftingPattern
|
||||
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
// Sanity check.
|
||||
if( data == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Assume the recipe is valid
|
||||
this.setPatternValidity( true );
|
||||
|
||||
// Read the aspects
|
||||
this.aspects.readFromNBT( data );
|
||||
|
||||
// Read ingredients
|
||||
for( int index = 0; index < ArcaneCraftingPattern.GRID_SIZE; index++ )
|
||||
// Validate aspects
|
||||
if( this.aspects.size() == 0 )
|
||||
{
|
||||
if( data.hasKey( ArcaneCraftingPattern.NBTKEY_INGREDIENT_NUM + index ) )
|
||||
this.setPatternValidity( false );
|
||||
return;
|
||||
}
|
||||
|
||||
// Read ingredients
|
||||
for( int slotNumber = 0; ( this.isValid && ( slotNumber < ArcaneCraftingPattern.GRID_SIZE ) ); slotNumber++ )
|
||||
{
|
||||
// Is there an ingredient for this slot?
|
||||
if( !data.hasKey( ArcaneCraftingPattern.NBTKEY_INGREDIENT_NUM + slotNumber ) )
|
||||
{
|
||||
// Get the tag
|
||||
NBTTagCompound ingData = data.getCompoundTag( ArcaneCraftingPattern.NBTKEY_INGREDIENT_NUM + index );
|
||||
// No ingredient
|
||||
continue;
|
||||
}
|
||||
|
||||
// What type is the tag?
|
||||
if( ingData.hasKey( ArcaneCraftingPattern.NBTKEY_INGREDIENT_TYPE ) )
|
||||
// Get the tag
|
||||
NBTTagCompound ingData = data.getCompoundTag( ArcaneCraftingPattern.NBTKEY_INGREDIENT_NUM + slotNumber );
|
||||
|
||||
// Validate the tag
|
||||
if( ( ingData == null ) || ( ingData.hasNoTags() ) )
|
||||
{
|
||||
// Invalid tag
|
||||
this.setPatternValidity( false );
|
||||
return;
|
||||
}
|
||||
|
||||
// Does the tag have a type?
|
||||
if( !ingData.hasKey( ArcaneCraftingPattern.NBTKEY_INGREDIENT_TYPE ) )
|
||||
{
|
||||
// Old AE tag
|
||||
try
|
||||
{
|
||||
int type = ingData.getInteger( ArcaneCraftingPattern.NBTKEY_INGREDIENT_TYPE );
|
||||
// Load the AE stack
|
||||
IAEItemStack ingAE = AEItemStack.loadItemStackFromNBT( ingData );
|
||||
|
||||
// Itemstack
|
||||
if( type == ArcaneCraftingPattern.NBTKEY_ITEMTYPE )
|
||||
// Null check
|
||||
if( ingAE == null )
|
||||
{
|
||||
this.ingredients[index] = ItemStack.loadItemStackFromNBT( ingData );
|
||||
this.setPatternValidity( false );
|
||||
return;
|
||||
}
|
||||
// Array
|
||||
else if( type == ArcaneCraftingPattern.NBTKEY_ARRAYTYPE )
|
||||
|
||||
// Get the item stack
|
||||
ItemStack ing = ingAE.getItemStack();
|
||||
|
||||
// Null check
|
||||
if( ing == null )
|
||||
{
|
||||
// Create the list
|
||||
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
|
||||
this.setPatternValidity( false );
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the count
|
||||
int count = ingData.getInteger( ArcaneCraftingPattern.NBTKEY_ARRAY_SIZE );
|
||||
// Set the stack
|
||||
this.ingredients[slotNumber] = ing;
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Recipe is invalid.
|
||||
this.setPatternValidity( false );
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
for( int i = 0; i < count; ++i )
|
||||
// What type is the tag?
|
||||
int type = ingData.getInteger( ArcaneCraftingPattern.NBTKEY_INGREDIENT_TYPE );
|
||||
|
||||
// Itemstack
|
||||
if( type == ArcaneCraftingPattern.NBTKEY_ITEMTYPE )
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get the item
|
||||
ItemStack ing = ItemStack.loadItemStackFromNBT( ingData );
|
||||
|
||||
// Null check
|
||||
if( ing == null )
|
||||
{
|
||||
this.setPatternValidity( false );
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the stack
|
||||
this.ingredients[slotNumber] = ing;
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
this.setPatternValidity( false );
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Array
|
||||
else if( type == ArcaneCraftingPattern.NBTKEY_ARRAYTYPE )
|
||||
{
|
||||
// Create the list
|
||||
ArrayList<ItemStack> itemList = new ArrayList<ItemStack>();
|
||||
|
||||
// Has count?
|
||||
if( !ingData.hasKey( ArcaneCraftingPattern.NBTKEY_ARRAY_SIZE ) )
|
||||
{
|
||||
this.setPatternValidity( false );
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the count
|
||||
int count = ingData.getInteger( ArcaneCraftingPattern.NBTKEY_ARRAY_SIZE );
|
||||
|
||||
for( int arrayIndex = 0; arrayIndex < count; ++arrayIndex )
|
||||
{
|
||||
// Get the subtag
|
||||
NBTTagCompound subTag = ingData.getCompoundTag( ArcaneCraftingPattern.NBTKEY_INGREDIENT_NUM + arrayIndex );
|
||||
|
||||
if( ( subTag == null ) || ( subTag.hasNoTags() ) )
|
||||
{
|
||||
// Ignore invalid entry
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Load the stack
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT( subTag );
|
||||
if( stack != null )
|
||||
{
|
||||
// Get the subtag
|
||||
NBTTagCompound subTag = ingData.getCompoundTag( ArcaneCraftingPattern.NBTKEY_INGREDIENT_NUM + i );
|
||||
|
||||
// Get the stack
|
||||
try
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT( subTag );
|
||||
if( stack != null )
|
||||
{
|
||||
list.add( stack );
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Silently ignore invalid items
|
||||
}
|
||||
itemList.add( stack );
|
||||
}
|
||||
|
||||
// Set the ingredient to the list
|
||||
this.ingredients[index] = list;
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Ignore invalid items
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
// Were any items loaded?
|
||||
if( itemList.size() == 0 )
|
||||
{
|
||||
// Old AE tag
|
||||
IAEItemStack ing = AEItemStack.loadItemStackFromNBT( ingData );
|
||||
this.ingredients[index] = ing.getItemStack();
|
||||
this.setPatternValidity( false );
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the ingredient to the list
|
||||
this.ingredients[slotNumber] = itemList;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ingredients[index] = null;
|
||||
// Unknown type
|
||||
this.setPatternValidity( false );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Read the result
|
||||
if( data.hasKey( ArcaneCraftingPattern.NBTKEY_RESULT ) )
|
||||
{
|
||||
NBTTagCompound outData = data.getCompoundTag( ArcaneCraftingPattern.NBTKEY_RESULT );
|
||||
this.result = AEItemStack.loadItemStackFromNBT( outData );
|
||||
// Get the result
|
||||
NBTTagCompound resultData = data.getCompoundTag( ArcaneCraftingPattern.NBTKEY_RESULT );
|
||||
|
||||
// Validate
|
||||
if( ( resultData == null ) || ( resultData.hasNoTags() ) )
|
||||
{
|
||||
this.setPatternValidity( false );
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Get result item
|
||||
this.result = AEItemStack.loadItemStackFromNBT( resultData );
|
||||
|
||||
// Check item
|
||||
if( this.result == null )
|
||||
{
|
||||
this.setPatternValidity( false );
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
this.setPatternValidity( false );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,53 +600,59 @@ public class ArcaneCraftingPattern
|
||||
for( int index = 0; index < ArcaneCraftingPattern.GRID_SIZE; index++ )
|
||||
{
|
||||
// Ensure it is not null
|
||||
if( this.ingredients[index] != null )
|
||||
if( this.ingredients[index] == null )
|
||||
{
|
||||
// Get the ingredient
|
||||
Object ing = this.ingredients[index];
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create the tag
|
||||
NBTTagCompound ingData = new NBTTagCompound();
|
||||
// Get the ingredient
|
||||
Object ing = this.ingredients[index];
|
||||
|
||||
// What type is the ingredient?
|
||||
if( ing instanceof IAEItemStack )
|
||||
// Create the tag
|
||||
NBTTagCompound ingData = new NBTTagCompound();
|
||||
|
||||
// What type is the ingredient?
|
||||
if( ing instanceof IAEItemStack )
|
||||
{
|
||||
// Write the ingredient data
|
||||
( (IAEItemStack)ing ).getItemStack().writeToNBT( ingData );
|
||||
ingData.setInteger( ArcaneCraftingPattern.NBTKEY_INGREDIENT_TYPE, ArcaneCraftingPattern.NBTKEY_ITEMTYPE );
|
||||
}
|
||||
else if( ing instanceof ItemStack )
|
||||
{
|
||||
( (ItemStack)ing ).writeToNBT( ingData );
|
||||
ingData.setInteger( ArcaneCraftingPattern.NBTKEY_INGREDIENT_TYPE, ArcaneCraftingPattern.NBTKEY_ITEMTYPE );
|
||||
}
|
||||
else if( ing instanceof ArrayList )
|
||||
{
|
||||
// Cast to array list
|
||||
ArrayList<ItemStack> ingList = (ArrayList<ItemStack>)ing;
|
||||
|
||||
// Set type and count
|
||||
ingData.setInteger( ArcaneCraftingPattern.NBTKEY_INGREDIENT_TYPE, ArcaneCraftingPattern.NBTKEY_ARRAYTYPE );
|
||||
ingData.setInteger( ArcaneCraftingPattern.NBTKEY_ARRAY_SIZE, ingList.size() );
|
||||
|
||||
// Add each item
|
||||
for( int i = 0; i < ingList.size(); ++i )
|
||||
{
|
||||
// Write the ingredient data
|
||||
( (IAEItemStack)ing ).getItemStack().writeToNBT( ingData );
|
||||
ingData.setInteger( ArcaneCraftingPattern.NBTKEY_INGREDIENT_TYPE, ArcaneCraftingPattern.NBTKEY_ITEMTYPE );
|
||||
}
|
||||
else if( ing instanceof ItemStack )
|
||||
{
|
||||
( (ItemStack)ing ).writeToNBT( ingData );
|
||||
ingData.setInteger( ArcaneCraftingPattern.NBTKEY_INGREDIENT_TYPE, ArcaneCraftingPattern.NBTKEY_ITEMTYPE );
|
||||
}
|
||||
else if( ing instanceof ArrayList )
|
||||
{
|
||||
// Cast to array list
|
||||
ArrayList<ItemStack> ingList = (ArrayList<ItemStack>)ing;
|
||||
// Create a new tag
|
||||
NBTTagCompound subTag = new NBTTagCompound();
|
||||
|
||||
// Set type and count
|
||||
ingData.setInteger( ArcaneCraftingPattern.NBTKEY_INGREDIENT_TYPE, ArcaneCraftingPattern.NBTKEY_ARRAYTYPE );
|
||||
ingData.setInteger( ArcaneCraftingPattern.NBTKEY_ARRAY_SIZE, ingList.size() );
|
||||
|
||||
// Add each item
|
||||
for( int i = 0; i < ingList.size(); ++i )
|
||||
{
|
||||
// Create a new tag
|
||||
NBTTagCompound subTag = new NBTTagCompound();
|
||||
|
||||
// Write the item
|
||||
ingList.get( i ).writeToNBT( subTag );
|
||||
|
||||
// Add the sub tag
|
||||
ingData.setTag( ArcaneCraftingPattern.NBTKEY_INGREDIENT_NUM + i, subTag );
|
||||
}
|
||||
// Write the item
|
||||
ingList.get( i ).writeToNBT( subTag );
|
||||
|
||||
// Add the sub tag
|
||||
ingData.setTag( ArcaneCraftingPattern.NBTKEY_INGREDIENT_NUM + i, subTag );
|
||||
}
|
||||
|
||||
// Write into the main data tag
|
||||
}
|
||||
|
||||
// Write into the main data tag
|
||||
if( !ingData.hasNoTags() )
|
||||
{
|
||||
data.setTag( ArcaneCraftingPattern.NBTKEY_INGREDIENT_NUM + index, ingData );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Write the result
|
||||
|
||||
@@ -74,7 +74,22 @@ public class HandlerKnowledgeCore
|
||||
// Read in each pattern
|
||||
for( int index = 0; index < plist.tagCount(); index++ )
|
||||
{
|
||||
this.patterns.add( new ArcaneCraftingPattern( this.kCore, plist.getCompoundTagAt( index ) ) );
|
||||
try
|
||||
{
|
||||
// Load the pattern
|
||||
ArcaneCraftingPattern pattern = new ArcaneCraftingPattern( this.kCore, plist.getCompoundTagAt( index ) );
|
||||
|
||||
// Is the pattern valid?
|
||||
if( pattern.isPatternValid() )
|
||||
{
|
||||
// Add the pattern
|
||||
this.patterns.add( pattern );
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// Ignore invalid patterns
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,8 +109,8 @@ public class HandlerKnowledgeCore
|
||||
// Save each pattern
|
||||
for( ArcaneCraftingPattern pattern : this.patterns )
|
||||
{
|
||||
// Ensure the pattern is not null
|
||||
if( pattern == null )
|
||||
// Ensure the pattern is valid
|
||||
if( ( pattern == null ) || ( !pattern.isPatternValid() ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -116,6 +131,12 @@ public class HandlerKnowledgeCore
|
||||
*/
|
||||
public void addPattern( final ArcaneCraftingPattern pattern )
|
||||
{
|
||||
// Validate the pattern
|
||||
if( ( pattern == null ) || ( !pattern.isPatternValid() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure there is room to store the pattern
|
||||
if( !this.hasRoomToStorePattern() )
|
||||
{
|
||||
@@ -123,7 +144,7 @@ public class HandlerKnowledgeCore
|
||||
}
|
||||
|
||||
// Check for duplicate patterns
|
||||
ArcaneCraftingPattern existingPattern = this.getPatternForItem( pattern.result.getItemStack() );
|
||||
ArcaneCraftingPattern existingPattern = this.getPatternForItem( pattern.getResult().getItemStack() );
|
||||
|
||||
if( existingPattern == null )
|
||||
{
|
||||
@@ -157,10 +178,10 @@ public class HandlerKnowledgeCore
|
||||
for( ArcaneCraftingPattern p : this.patterns )
|
||||
{
|
||||
// Does the pattern have a valid output?
|
||||
if( ( p != null ) && ( p.result != null ) )
|
||||
if( ( p != null ) && ( p.getResult() != null ) )
|
||||
{
|
||||
// Is the output equal to the specified result?
|
||||
if( ItemStack.areItemStacksEqual( p.result.getItemStack(), resultStack ) )
|
||||
if( ItemStack.areItemStacksEqual( p.getResult().getItemStack(), resultStack ) )
|
||||
{
|
||||
// Found the pattern
|
||||
return p;
|
||||
@@ -195,9 +216,9 @@ public class HandlerKnowledgeCore
|
||||
// Add each stored patterns output
|
||||
for( ArcaneCraftingPattern p : this.patterns )
|
||||
{
|
||||
if( ( p != null ) && ( p.result != null ) )
|
||||
if( ( p != null ) && ( p.getResult() != null ) )
|
||||
{
|
||||
results.add( p.result.getItemStack() );
|
||||
results.add( p.getResult().getItemStack() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -308,7 +308,15 @@ public abstract class AbstractPacket
|
||||
*/
|
||||
public static Aspect readAspect( final ByteBuf stream )
|
||||
{
|
||||
return Aspect.aspects.get( readString( stream ) );
|
||||
// Read the name
|
||||
String name = readString( stream );
|
||||
if( name != "" )
|
||||
{
|
||||
// Return the aspect
|
||||
return Aspect.aspects.get( name );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,35 @@
|
||||
package thaumicenergistics.tileentities;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumicenergistics.api.ThEApi;
|
||||
import thaumicenergistics.blocks.BlockArcaneAssembler;
|
||||
import thaumicenergistics.integration.IWailaSource;
|
||||
import thaumicenergistics.integration.tc.ArcaneCraftingPattern;
|
||||
import thaumicenergistics.integration.tc.DigiVisSourceData;
|
||||
import thaumicenergistics.integration.tc.IDigiVisSource;
|
||||
import thaumicenergistics.integration.tc.VisCraftingHelper;
|
||||
import thaumicenergistics.inventory.HandlerKnowledgeCore;
|
||||
import thaumicenergistics.items.ItemKnowledgeCore;
|
||||
import thaumicenergistics.util.EffectiveSide;
|
||||
import thaumicenergistics.util.GuiHelper;
|
||||
import thaumicenergistics.util.IInventoryUpdateReceiver;
|
||||
import thaumicenergistics.util.PrivateInventory;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
@@ -36,37 +66,6 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumicenergistics.api.ThEApi;
|
||||
import thaumicenergistics.blocks.BlockArcaneAssembler;
|
||||
import thaumicenergistics.integration.IWailaSource;
|
||||
import thaumicenergistics.integration.tc.ArcaneCraftingPattern;
|
||||
import thaumicenergistics.integration.tc.DigiVisSourceData;
|
||||
import thaumicenergistics.integration.tc.IDigiVisSource;
|
||||
import thaumicenergistics.integration.tc.VisCraftingHelper;
|
||||
import thaumicenergistics.inventory.HandlerKnowledgeCore;
|
||||
import thaumicenergistics.items.ItemKnowledgeCore;
|
||||
import thaumicenergistics.util.EffectiveSide;
|
||||
import thaumicenergistics.util.GuiHelper;
|
||||
import thaumicenergistics.util.IInventoryUpdateReceiver;
|
||||
import thaumicenergistics.util.PrivateInventory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class TileArcaneAssembler
|
||||
extends AENetworkInvTile
|
||||
@@ -315,13 +314,14 @@ public class TileArcaneAssembler
|
||||
IStorageGrid storageGrid = this.getGridProxy().getStorage();
|
||||
|
||||
// Simulate placing the items
|
||||
IAEItemStack rejected = storageGrid.getItemInventory().injectItems( this.currentPattern.result, Actionable.SIMULATE, this.mySource );
|
||||
IAEItemStack rejected = storageGrid.getItemInventory().injectItems( this.currentPattern.getResult(), Actionable.SIMULATE,
|
||||
this.mySource );
|
||||
|
||||
// Was all items accepted?
|
||||
if( ( rejected == null ) || ( rejected.getStackSize() == 0 ) )
|
||||
{
|
||||
// Inject into the network
|
||||
storageGrid.getItemInventory().injectItems( this.currentPattern.result.copy(), Actionable.MODULATE, this.mySource );
|
||||
storageGrid.getItemInventory().injectItems( this.currentPattern.getResult().copy(), Actionable.MODULATE, this.mySource );
|
||||
|
||||
// Mark the assembler as no longer crafting
|
||||
this.isCrafting = false;
|
||||
@@ -386,8 +386,7 @@ public class TileArcaneAssembler
|
||||
*/
|
||||
private int getRequiredAmountForAspect( final Aspect aspect )
|
||||
{
|
||||
return (int)Math.ceil( this.visDiscount.get( aspect ) *
|
||||
( this.currentPattern.aspects.getAmount( aspect ) * TileArcaneAssembler.CVIS_MULTIPLER ) );
|
||||
return (int)Math.ceil( this.visDiscount.get( aspect ) * ( this.currentPattern.getAspectCost( aspect ) * TileArcaneAssembler.CVIS_MULTIPLER ) );
|
||||
}
|
||||
|
||||
private boolean hasEnoughVisForCraft()
|
||||
@@ -861,21 +860,28 @@ public class TileArcaneAssembler
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void onLoadNBT( final NBTTagCompound data )
|
||||
{
|
||||
// Is there a saved core?
|
||||
if( data.hasKey( TileArcaneAssembler.NBTKEY_KCORE ) )
|
||||
try
|
||||
{
|
||||
// Load the saved core
|
||||
this.internalInventory.slots[TileArcaneAssembler.KCORE_SLOT_INDEX] = ItemStack.loadItemStackFromNBT( data
|
||||
.getCompoundTag( TileArcaneAssembler.NBTKEY_KCORE ) );
|
||||
// Is there a saved core?
|
||||
if( data.hasKey( TileArcaneAssembler.NBTKEY_KCORE ) )
|
||||
{
|
||||
// Load the saved core
|
||||
this.internalInventory.slots[TileArcaneAssembler.KCORE_SLOT_INDEX] = ItemStack.loadItemStackFromNBT( data
|
||||
.getCompoundTag( TileArcaneAssembler.NBTKEY_KCORE ) );
|
||||
|
||||
// Create the handler
|
||||
this.kCoreHandler = new HandlerKnowledgeCore( this.internalInventory.slots[TileArcaneAssembler.KCORE_SLOT_INDEX] );
|
||||
// Create the handler
|
||||
this.kCoreHandler = new HandlerKnowledgeCore( this.internalInventory.slots[TileArcaneAssembler.KCORE_SLOT_INDEX] );
|
||||
|
||||
// Update the pattern slots
|
||||
this.updatePatternSlots();
|
||||
// Update the pattern slots
|
||||
this.updatePatternSlots();
|
||||
|
||||
// Update the network
|
||||
this.stalePatterns = true;
|
||||
// Update the network
|
||||
this.stalePatterns = true;
|
||||
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1220,7 +1226,7 @@ public class TileArcaneAssembler
|
||||
this.currentPattern = (ArcaneCraftingPattern)patternDetails;
|
||||
|
||||
// Set the target item
|
||||
this.internalInventory.slots[TileArcaneAssembler.TARGET_SLOT_INDEX] = this.currentPattern.result.getItemStack();
|
||||
this.internalInventory.slots[TileArcaneAssembler.TARGET_SLOT_INDEX] = this.currentPattern.getResult().getItemStack();
|
||||
|
||||
// AE effects
|
||||
try
|
||||
@@ -1228,7 +1234,7 @@ public class TileArcaneAssembler
|
||||
NetworkRegistry.TargetPoint where = new NetworkRegistry.TargetPoint( this.worldObj.provider.dimensionId, this.xCoord, this.yCoord,
|
||||
this.zCoord, 32.0D );
|
||||
appeng.core.sync.network.NetworkHandler.instance.sendToAllAround( new PacketAssemblerAnimation( this.xCoord, this.yCoord,
|
||||
this.zCoord, (byte)( 10 + ( 9 * this.upgradeCount ) ), this.currentPattern.result ), where );
|
||||
this.zCoord, (byte)( 10 + ( 9 * this.upgradeCount ) ), this.currentPattern.getResult() ), where );
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
|
||||
@@ -27,16 +27,16 @@ thaumicenergistics.aeparts.essentia.storage.monitor.name=Essentia Storage Monito
|
||||
thaumicenergistics.aeparts.essentia.conversion.monitor.name=Essentia Conversion Monitor
|
||||
|
||||
#Items
|
||||
thaumicenergistics.item.essentia.cell.1k.name=ME 1k Essentia Storage Cell
|
||||
thaumicenergistics.item.essentia.cell.4k.name=ME 4k Essentia Storage Cell
|
||||
thaumicenergistics.item.essentia.cell.16k.name=ME 16k Essentia Storage Cell
|
||||
thaumicenergistics.item.essentia.cell.64k.name=ME 64k Essentia Storage Cell
|
||||
thaumicenergistics.item.essentia.cell.1k.name=1k ME Essentia Storage Cell
|
||||
thaumicenergistics.item.essentia.cell.4k.name=4k ME Essentia Storage Cell
|
||||
thaumicenergistics.item.essentia.cell.16k.name=16k ME Essentia Storage Cell
|
||||
thaumicenergistics.item.essentia.cell.64k.name=64k ME Essentia Storage Cell
|
||||
thaumicenergistics.item.essentia.cell.creative.name=Creative Essentia Storage Cell
|
||||
thaumicenergistics.item.storage.casing.name=ME Essentia Storage Housing
|
||||
thaumicenergistics.item.storage.component.1k.name=ME 1k Essentia Storage Component
|
||||
thaumicenergistics.item.storage.component.4k.name=ME 4k Essentia Storage Component
|
||||
thaumicenergistics.item.storage.component.16k.name=ME 16k Essentia Storage Component
|
||||
thaumicenergistics.item.storage.component.64k.name=ME 64k Essentia Storage Component
|
||||
thaumicenergistics.item.storage.component.1k.name=1k ME Essentia Storage Component
|
||||
thaumicenergistics.item.storage.component.4k.name=4k ME Essentia Storage Component
|
||||
thaumicenergistics.item.storage.component.16k.name=16k ME Essentia Storage Component
|
||||
thaumicenergistics.item.storage.component.64k.name=64k ME Essentia Storage Component
|
||||
thaumicenergistics.item.material.diffusion.core.name=Diffusion Core
|
||||
thaumicenergistics.item.material.coalescence.core.name=Coalescence Core
|
||||
thaumicenergistics.item.material.iron.gear.name=Iron Gear
|
||||
|
||||
Reference in new issue
Block a user