mirror of
https://github.com/GTNewHorizons/ThaumicEnergistics.git
synced 2026-10-25 20:32:27 +00:00
Cleanup + Config fix
Fixes #263: Replaced flawed conversion amount config item. Essentia cells should work correctly in the IO Port. Removed redundant tile entity code. Cleaned up inventory processing.
This commit is contained in:
1 parent
b215a36649
commit
e3e4a213a7
32 files changed
+838
-671
No files matched your search
@@ -1,4 +1,9 @@
|
||||
01/05/2016 0.10.0.0 - Beta
|
||||
Fixes #263: Replaced flawed conversion amount config item. Essentia cells should work correctly in the IO Port.
|
||||
Removed redundant tile entity code.
|
||||
Cleaned up inventory processing.
|
||||
|
||||
01/05/2016 0.10.0.0 - Beta
|
||||
Added recipe and Thaumonomicon entry for DPE.
|
||||
Reduced client packet overhead.
|
||||
More cleanup.
|
||||
|
||||
@@ -2,7 +2,18 @@ package thaumicenergistics.api.storage;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
/**
|
||||
* Implementer wants updates when an inventory is changed.
|
||||
*
|
||||
* @author Nividica
|
||||
*
|
||||
*/
|
||||
public interface IInventoryUpdateReceiver
|
||||
{
|
||||
/**
|
||||
* Called when an inventory is changed.
|
||||
*
|
||||
* @param sourceInventory
|
||||
*/
|
||||
public void onInventoryChanged( IInventory sourceInventory );
|
||||
}
|
||||
@@ -218,6 +218,9 @@ public abstract class ThEScrollbarGui
|
||||
@Override
|
||||
public void drawScreen( final int mouseX, final int mouseY, final float mouseBtn )
|
||||
{
|
||||
// Call super
|
||||
super.drawScreen( mouseX, mouseY, mouseBtn );
|
||||
|
||||
// Is the mouse holding the scroll bar?
|
||||
if( this.isScrollBarHeld )
|
||||
{
|
||||
@@ -271,9 +274,6 @@ public abstract class ThEScrollbarGui
|
||||
}
|
||||
}
|
||||
|
||||
// Call super
|
||||
super.drawScreen( mouseX, mouseY, mouseBtn );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ public class CommonProxy
|
||||
{
|
||||
for( BlockEnum block : BlockEnum.VALUES )
|
||||
{
|
||||
GameRegistry.registerBlock( block.getBlock(), block.getItemClass(), block.getUnlocalizedName() );
|
||||
GameRegistry.registerBlock( block.getBlock(), block.itemBlockClass, block.getUnlocalizedName() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,11 @@ class ConfigurationHandler
|
||||
/**
|
||||
* Default values.
|
||||
*/
|
||||
private static final int DEFAULT_CONVERSION = 250;
|
||||
private static final boolean DEFAULT_ESSENTIAPROVIDER = true, DEFAULT_INFUSIONPROVIDER = true, DEFAULT_QUARTZ = true, DEFAULT_GEARBOX = false,
|
||||
private static final int DEFAULT_CONVERSION_EXPONENT = 7;
|
||||
private static final boolean DEFAULT_ESSENTIAPROVIDER = true,
|
||||
DEFAULT_INFUSIONPROVIDER = true,
|
||||
DEFAULT_QUARTZ = true,
|
||||
DEFAULT_GEARBOX_DISABLED = false,
|
||||
DEFAULT_EXTRACELLS_BLIST = true;
|
||||
|
||||
/**
|
||||
@@ -30,33 +33,33 @@ class ConfigurationHandler
|
||||
* Controls the conversion ratio of essentia/fluid. <BR>
|
||||
* 1 essentia unit is converted to this many mb's of fluid.
|
||||
*/
|
||||
private int conversionMultiplier = 250;
|
||||
private int conversionMultiplier = (int)Math.pow( 2, DEFAULT_CONVERSION_EXPONENT );
|
||||
|
||||
/**
|
||||
* Controls if the Essentia Provider is allowed to be crafted.
|
||||
*/
|
||||
private boolean allowEssentiaProvider = true;
|
||||
private boolean allowEssentiaProvider = DEFAULT_ESSENTIAPROVIDER;
|
||||
|
||||
/**
|
||||
* Controls if the Infusion Provider is allowed to be crafted.
|
||||
*/
|
||||
private boolean allowInfusionProvider = true;
|
||||
private boolean allowInfusionProvider = DEFAULT_INFUSIONPROVIDER;
|
||||
|
||||
/**
|
||||
* Controls if Certus Quartz can be duped in the crucible.
|
||||
*/
|
||||
private boolean allowCertusDupe = true;
|
||||
private boolean allowCertusDupe = DEFAULT_QUARTZ;
|
||||
|
||||
/**
|
||||
* Controls if the iron and thaumium gearbox's will be rendered as a
|
||||
* standard block.
|
||||
*/
|
||||
private boolean gearboxModelDisabled = false;
|
||||
private boolean gearboxModelDisabled = DEFAULT_GEARBOX_DISABLED;
|
||||
|
||||
/**
|
||||
* Controls if essentia gas is blacklisted
|
||||
*/
|
||||
private boolean extracellsBlacklist = true;
|
||||
private boolean extracellsBlacklist = DEFAULT_EXTRACELLS_BLIST;
|
||||
|
||||
private ConfigurationHandler( final Configuration config )
|
||||
{
|
||||
@@ -85,16 +88,17 @@ class ConfigurationHandler
|
||||
private void synchronizeConfigFile()
|
||||
{
|
||||
// Sync the essentia fluid conversion ratio
|
||||
this.conversionMultiplier = this.configSettings
|
||||
int fluidPow = this.configSettings
|
||||
.getInt(
|
||||
"Essentia Fluid Ratio",
|
||||
"Essentia Fluid Ratio Exponent",
|
||||
Configuration.CATEGORY_GENERAL,
|
||||
ConfigurationHandler.DEFAULT_CONVERSION,
|
||||
ConfigurationHandler.DEFAULT_CONVERSION_EXPONENT,
|
||||
1,
|
||||
10000,
|
||||
"Controls the conversion ratio of essentia/fluid. 1 essentia is converted to this many milibuckets of fluid. "
|
||||
11,
|
||||
"Controls the conversion ratio of essentia/fluid. 1 essentia is converted to (2^this) milibuckets of fluid. "
|
||||
+ "Please be aware that this value effects how much fluid is transferred through the AE system, which also effects transfer speed and power consumption. "
|
||||
+ "Very high values may make it impossible to use fluid transfer devices such as the ME IO Port, or anything from EC2." );
|
||||
+ "Values above 11 make it impossible to use fluid transfer devices such as the ME IO Port, or anything from EC2." );
|
||||
this.conversionMultiplier = (int)Math.pow( 2, Math.min( fluidPow, 11 ) );
|
||||
|
||||
// Sync essentia provider
|
||||
this.allowEssentiaProvider = this.configSettings.getBoolean( "Allow Crafting Essentia Provider", ConfigurationHandler.CATEGORY_CRAFTING,
|
||||
@@ -110,7 +114,7 @@ class ConfigurationHandler
|
||||
|
||||
// Gearbox model
|
||||
this.gearboxModelDisabled = this.configSettings.getBoolean( "Disable Gearbox Model", ConfigurationHandler.CATEGORY_CLIENT,
|
||||
ConfigurationHandler.DEFAULT_GEARBOX, "The iron and thaumium gearboxes will be rendered as a standard block." );
|
||||
ConfigurationHandler.DEFAULT_GEARBOX_DISABLED, "The iron and thaumium gearboxes will be rendered as a standard block." );
|
||||
|
||||
// Extra cells blacklist
|
||||
this.extracellsBlacklist = this.configSettings.getBoolean( "ExtraCells Blacklist", ConfigurationHandler.CATEGORY_INTEGRATION,
|
||||
|
||||
@@ -74,8 +74,8 @@ public class BlockArcaneAssembler
|
||||
}
|
||||
else
|
||||
{
|
||||
// Does the player have permission?
|
||||
if( ( (TileArcaneAssembler)tileAssembler ).canPlayerOpenGUI( player ) )
|
||||
// Can the player interact with the assembler?
|
||||
if( ( (TileArcaneAssembler)tileAssembler ).isUseableByPlayer( player ) )
|
||||
{
|
||||
// Launch the gui.
|
||||
ThEGuiHandler.launchGui( ThEGuiHandler.ARCANE_ASSEMBLER_ID, player, world, x, y, z );
|
||||
@@ -103,14 +103,14 @@ public class BlockArcaneAssembler
|
||||
// Create a compound tag
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
// Save the tile entity state
|
||||
( (TileArcaneAssembler)tileAssembler ).onSaveNBT( data );
|
||||
// Save the vis levels
|
||||
( (TileArcaneAssembler)tileAssembler ).writeVisLevelsToNBT( data );
|
||||
|
||||
// Set the itemstack tag
|
||||
itemStack.setTagCompound( data );
|
||||
|
||||
// Set that it was dismantled
|
||||
( (TileArcaneAssembler)tileAssembler ).onDismantled();
|
||||
if( !data.hasNoTags() )
|
||||
{
|
||||
itemStack.setTagCompound( data );
|
||||
}
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
@@ -154,7 +154,7 @@ public class BlockArcaneAssembler
|
||||
@Override
|
||||
public TileEntity createNewTileEntity( final World world, final int metadata )
|
||||
{
|
||||
return new TileArcaneAssembler().setupAssemblerTile();
|
||||
return new TileArcaneAssembler();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,10 +197,10 @@ public class BlockArcaneAssembler
|
||||
|
||||
if( tileAssembler instanceof TileArcaneAssembler )
|
||||
{
|
||||
if( itemStack.getTagCompound() != null )
|
||||
if( itemStack.hasTagCompound() )
|
||||
{
|
||||
// Load the saved data
|
||||
( (TileArcaneAssembler)tileAssembler ).onLoadNBT( itemStack.getTagCompound() );
|
||||
// Load the vis data
|
||||
( (TileArcaneAssembler)tileAssembler ).readVisLevelsFromNBT( itemStack.getTagCompound() );
|
||||
}
|
||||
|
||||
if( player instanceof EntityPlayer )
|
||||
|
||||
@@ -67,8 +67,8 @@ public class BlockKnowledgeInscriber
|
||||
if( tileKI.hasKCore() )
|
||||
{
|
||||
// Spawn the core as an item entity.
|
||||
world.spawnEntityInWorld( new EntityItem( world, 0.5 + x, 0.5 + y, 0.2 + z, tileKI.getInventory().getStackInSlot(
|
||||
TileKnowledgeInscriber.KCORE_SLOT ) ) );
|
||||
world.spawnEntityInWorld( new EntityItem( world, 0.5 + x, 0.5 + y, 0.2 + z, tileKI.getStackInSlot(
|
||||
TileKnowledgeInscriber.KCORE_SLOT ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,14 @@ public class ContainerArcaneAssembler
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
// Ensure there is an assembler
|
||||
if( this.assembler != null )
|
||||
{
|
||||
// Ask it if this player can interact
|
||||
return this.assembler.isUseableByPlayer( player );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+9
-12
@@ -2,7 +2,6 @@ package thaumicenergistics.common.container;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
@@ -63,7 +62,7 @@ public class ContainerDistillationEncoder
|
||||
/**
|
||||
* Host encoder.
|
||||
*/
|
||||
protected TileDistillationEncoder hostTile;
|
||||
protected TileDistillationEncoder encoder;
|
||||
|
||||
/**
|
||||
* Slot holding the source item.
|
||||
@@ -96,7 +95,7 @@ public class ContainerDistillationEncoder
|
||||
protected DistillationPatternHelper patternHelper;
|
||||
|
||||
/**
|
||||
* Who/what to send updates to when slots change.
|
||||
* Gui to send updates to when slots change.
|
||||
*/
|
||||
public IInventoryUpdateReceiver slotUpdateReceiver;
|
||||
|
||||
@@ -115,13 +114,10 @@ public class ContainerDistillationEncoder
|
||||
this.player = player;
|
||||
|
||||
// Get the encoder
|
||||
this.hostTile = (TileDistillationEncoder)world.getTileEntity( x, y, z );
|
||||
|
||||
// Get the encoder's inventory
|
||||
IInventory hostInv = this.hostTile.getInventory();
|
||||
this.encoder = (TileDistillationEncoder)world.getTileEntity( x, y, z );
|
||||
|
||||
// Add the source item slot
|
||||
this.slotSourceItem = new SlotFake( hostInv, TileDistillationEncoder.SLOT_SOURCE_ITEM, SLOT_SOURCE_ITEM_POS_X, SLOT_SOURCE_ITEM_POS_Y );
|
||||
this.slotSourceItem = new SlotFake( this.encoder, TileDistillationEncoder.SLOT_SOURCE_ITEM, SLOT_SOURCE_ITEM_POS_X, SLOT_SOURCE_ITEM_POS_Y );
|
||||
this.addSlotToContainer( this.slotSourceItem );
|
||||
|
||||
// Add the source aspect slots
|
||||
@@ -131,7 +127,8 @@ public class ContainerDistillationEncoder
|
||||
int posY = SLOT_SOURCE_ASPECTS_POS_Y + ( index * 18 );
|
||||
|
||||
// Create the slot
|
||||
this.slotSourceAspects[index] = new SlotFake( hostInv, TileDistillationEncoder.SLOT_SOURCE_ASPECTS + index, SLOT_SOURCE_ASPECTS_POS_X,
|
||||
this.slotSourceAspects[index] = new SlotFake( this.encoder, TileDistillationEncoder.SLOT_SOURCE_ASPECTS + index,
|
||||
SLOT_SOURCE_ASPECTS_POS_X,
|
||||
posY );
|
||||
|
||||
// Add it
|
||||
@@ -139,17 +136,17 @@ public class ContainerDistillationEncoder
|
||||
}
|
||||
|
||||
// Add the selected aspect slot
|
||||
this.slotSelectedAspect = new SlotFake( hostInv, TileDistillationEncoder.SLOT_SELECTED_ASPECT, SLOT_SELECTED_ASPECT_POS_X,
|
||||
this.slotSelectedAspect = new SlotFake( this.encoder, TileDistillationEncoder.SLOT_SELECTED_ASPECT, SLOT_SELECTED_ASPECT_POS_X,
|
||||
SLOT_SELECTED_ASPECT_POS_Y );
|
||||
this.addSlotToContainer( this.slotSelectedAspect );
|
||||
|
||||
// Add blank pattern slot
|
||||
this.slotPatternsBlank = new SlotRestrictive( hostInv, TileDistillationEncoder.SLOT_BLANK_PATTERNS,
|
||||
this.slotPatternsBlank = new SlotRestrictive( this.encoder, TileDistillationEncoder.SLOT_BLANK_PATTERNS,
|
||||
SLOT_PATTERNS_BLANK_POS_X, SLOT_PATTERNS_BLANK_POS_Y );
|
||||
this.addSlotToContainer( this.slotPatternsBlank );
|
||||
|
||||
// Add encoded pattern slot
|
||||
this.slotPatternEncoded = new SlotRestrictive( hostInv, TileDistillationEncoder.SLOT_ENCODED_PATTERN,
|
||||
this.slotPatternEncoded = new SlotRestrictive( this.encoder, TileDistillationEncoder.SLOT_ENCODED_PATTERN,
|
||||
SLOT_PATTERN_ENCODED_POS_X, SLOT_PATTERN_ENCODED_POS_Y );
|
||||
this.addSlotToContainer( this.slotPatternEncoded );
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import thaumicenergistics.api.storage.IAspectStack;
|
||||
import thaumicenergistics.common.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.grid.EssentiaMonitor;
|
||||
import thaumicenergistics.common.inventory.HandlerItemEssentiaCell;
|
||||
import thaumicenergistics.common.inventory.PrivateInventory;
|
||||
import thaumicenergistics.common.inventory.TheInternalInventory;
|
||||
import thaumicenergistics.common.items.ItemEssentiaCell;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_EssentiaCellTerminal;
|
||||
import thaumicenergistics.common.network.packet.server.Packet_S_EssentiaCellTerminal;
|
||||
@@ -62,7 +62,7 @@ public class ContainerEssentiaCell
|
||||
/**
|
||||
* Import and export inventory slots.
|
||||
*/
|
||||
private PrivateInventory privateInventory = new PrivateInventory( ThaumicEnergistics.MOD_ID + ".item.essentia.cell.inventory", 2, 64 )
|
||||
private TheInternalInventory privateInventory = new TheInternalInventory( ThaumicEnergistics.MOD_ID + ".item.essentia.cell.inventory", 2, 64 )
|
||||
{
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int slotID, final ItemStack itemStack )
|
||||
|
||||
+16
-21
@@ -18,9 +18,7 @@ import thaumicenergistics.api.gui.IAspectSelectorContainer;
|
||||
import thaumicenergistics.api.gui.ICraftingIssuerContainer;
|
||||
import thaumicenergistics.api.storage.IAspectStack;
|
||||
import thaumicenergistics.api.storage.IEssentiaRepo;
|
||||
import thaumicenergistics.api.storage.IInventoryUpdateReceiver;
|
||||
import thaumicenergistics.common.container.slot.SlotRestrictive;
|
||||
import thaumicenergistics.common.inventory.PrivateInventory;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_EssentiaCellTerminal;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_Sync;
|
||||
import thaumicenergistics.common.network.packet.server.Packet_S_EssentiaCellTerminal;
|
||||
@@ -46,7 +44,7 @@ import appeng.api.networking.security.PlayerSource;
|
||||
*/
|
||||
public abstract class ContainerEssentiaCellTerminalBase
|
||||
extends ContainerWithPlayerInventory
|
||||
implements IMEEssentiaMonitorReceiver, IAspectSelectorContainer, IInventoryUpdateReceiver, ICraftingIssuerContainer
|
||||
implements IMEEssentiaMonitorReceiver, IAspectSelectorContainer, ICraftingIssuerContainer
|
||||
{
|
||||
/**
|
||||
* X position for the output slot
|
||||
@@ -124,7 +122,7 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
/**
|
||||
* Import and export inventory
|
||||
*/
|
||||
protected PrivateInventory inventory;
|
||||
protected IInventory inventory;
|
||||
|
||||
/**
|
||||
* The last known stack size stored in the export slot
|
||||
@@ -417,14 +415,11 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
*
|
||||
* @param inventory
|
||||
*/
|
||||
protected void bindToInventory( final PrivateInventory inventory )
|
||||
protected void bindToInventory( final IInventory inventory )
|
||||
{
|
||||
// Set the inventory
|
||||
this.inventory = inventory;
|
||||
|
||||
// Register the container as an update receiver
|
||||
this.inventory.setReceiver( this );
|
||||
|
||||
// Create the input slot
|
||||
this.inputSlot = new SlotRestrictive( inventory, ContainerEssentiaCellTerminalBase.INPUT_INV_INDEX,
|
||||
ContainerEssentiaCellTerminalBase.INPUT_POSITION_X, ContainerEssentiaCellTerminalBase.INPUT_POSITION_Y );
|
||||
@@ -840,19 +835,6 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the list of fluids on the ME network changes.
|
||||
*/
|
||||
@Override
|
||||
public void onInventoryChanged( final IInventory sourceInventory )
|
||||
{
|
||||
// Is this client side?
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
this.playTransferSound( null, true, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the gui when the aspect list arrives.
|
||||
*
|
||||
@@ -1025,6 +1007,19 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStackInSlot( final int slotNumber, final ItemStack stack )
|
||||
{
|
||||
// Call super
|
||||
super.putStackInSlot( slotNumber, stack );
|
||||
|
||||
// Is this client side?
|
||||
if( ( this.outputSlot.slotNumber == slotNumber ) && EffectiveSide.isClientSide() )
|
||||
{
|
||||
this.playTransferSound( null, true, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user has clicked on an aspect.
|
||||
* Sends that change to the server for validation.
|
||||
|
||||
+16
-15
@@ -119,22 +119,19 @@ public class ContainerKnowledgeInscriber
|
||||
// Get the inscriber
|
||||
this.inscriber = (TileKnowledgeInscriber)world.getTileEntity( x, y, z );
|
||||
|
||||
// Get the inscriber's inventory
|
||||
IInventory inscriberInventory = this.inscriber.getInventory();
|
||||
|
||||
// Create the Kcore slot
|
||||
this.kCoreSlot = new SlotRestrictive( inscriberInventory, TileKnowledgeInscriber.KCORE_SLOT, ContainerKnowledgeInscriber.KCORE_SLOT_X,
|
||||
this.kCoreSlot = new SlotRestrictive( this.inscriber, TileKnowledgeInscriber.KCORE_SLOT, ContainerKnowledgeInscriber.KCORE_SLOT_X,
|
||||
ContainerKnowledgeInscriber.KCORE_SLOT_Y );
|
||||
this.addSlotToContainer( this.kCoreSlot );
|
||||
|
||||
// Create pattern slots
|
||||
this.initPatternSlots( inscriberInventory );
|
||||
this.initPatternSlots();
|
||||
|
||||
// Create crafting slots
|
||||
this.initCraftingSlots( inscriberInventory );
|
||||
this.initCraftingSlots();
|
||||
|
||||
// Create the result slot
|
||||
this.resultSlot = new SlotFake( inscriberInventory, TileKnowledgeInscriber.CRAFTING_RESULT_SLOT, 116, 108 );
|
||||
this.resultSlot = new SlotFake( this.inscriber, TileKnowledgeInscriber.CRAFTING_RESULT_SLOT, 116, 108 );
|
||||
this.addSlotToContainer( this.resultSlot );
|
||||
|
||||
// Perform server side only setup
|
||||
@@ -154,7 +151,7 @@ public class ContainerKnowledgeInscriber
|
||||
this.updatePatternSlots();
|
||||
|
||||
// Update the result
|
||||
this.onCraftMatrixChanged( inscriberInventory );
|
||||
this.onCraftMatrixChanged( this.inscriber );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -181,7 +178,7 @@ public class ContainerKnowledgeInscriber
|
||||
else
|
||||
{
|
||||
// Get the recipe output
|
||||
ItemStack recipeOutput = ArcaneRecipeHelper.INSTANCE.getRecipeOutput( this.inscriber.getInventory(),
|
||||
ItemStack recipeOutput = ArcaneRecipeHelper.INSTANCE.getRecipeOutput( this.inscriber,
|
||||
TileKnowledgeInscriber.CRAFTING_MATRIX_SLOT, 9, this.activeRecipe );
|
||||
|
||||
// Ensure there is an output
|
||||
@@ -220,7 +217,7 @@ public class ContainerKnowledgeInscriber
|
||||
return saveState;
|
||||
}
|
||||
|
||||
private void initCraftingSlots( final IInventory inscriberInventory )
|
||||
private void initCraftingSlots()
|
||||
{
|
||||
int slotIndex;
|
||||
// Create the crafting slots
|
||||
@@ -237,7 +234,7 @@ public class ContainerKnowledgeInscriber
|
||||
int posY = ContainerKnowledgeInscriber.CRAFTING_SLOT_Y + ( ContainerKnowledgeInscriber.CRAFTING_SLOT_SPACING * row );
|
||||
|
||||
// Add to the array
|
||||
this.craftingSlots[index] = new SlotFakeCraftingMatrix( inscriberInventory, slotIndex++ , posX, posY );
|
||||
this.craftingSlots[index] = new SlotFakeCraftingMatrix( this.inscriber, slotIndex++ , posX, posY );
|
||||
|
||||
// Add the slot
|
||||
this.addSlotToContainer( this.craftingSlots[index] );
|
||||
@@ -248,7 +245,7 @@ public class ContainerKnowledgeInscriber
|
||||
this.craftingSlot_last = this.craftingSlots[this.craftingSlots.length - 1].slotNumber;
|
||||
}
|
||||
|
||||
private void initPatternSlots( final IInventory inscriberInventory )
|
||||
private void initPatternSlots()
|
||||
{
|
||||
int slotIndex;
|
||||
// Create the pattern slots
|
||||
@@ -265,7 +262,7 @@ public class ContainerKnowledgeInscriber
|
||||
int posY = ContainerKnowledgeInscriber.PATTERN_SLOT_Y + ( ContainerKnowledgeInscriber.PATTERN_SLOT_SPACING * row );
|
||||
|
||||
// Add to the array
|
||||
this.patternSlots[index] = new SlotInaccessible( inscriberInventory, slotIndex++ , posX, posY );
|
||||
this.patternSlots[index] = new SlotInaccessible( this.inscriber, slotIndex++ , posX, posY );
|
||||
|
||||
// Add the slot
|
||||
this.addSlotToContainer( this.patternSlots[index] );
|
||||
@@ -379,7 +376,11 @@ public class ContainerKnowledgeInscriber
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
if( this.inscriber != null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -481,7 +482,7 @@ public class ContainerKnowledgeInscriber
|
||||
}
|
||||
|
||||
// Get the aspect cost
|
||||
AspectList recipeAspects = ArcaneRecipeHelper.INSTANCE.getRecipeAspectCost( this.inscriber.getInventory(),
|
||||
AspectList recipeAspects = ArcaneRecipeHelper.INSTANCE.getRecipeAspectCost( this.inscriber,
|
||||
TileKnowledgeInscriber.CRAFTING_MATRIX_SLOT, 9, this.activeRecipe );
|
||||
|
||||
// Create the pattern
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import thaumicenergistics.api.grid.ICraftingIssuerHost;
|
||||
import thaumicenergistics.common.ThEGuiHandler;
|
||||
import thaumicenergistics.common.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.inventory.HandlerWirelessEssentiaTerminal;
|
||||
import thaumicenergistics.common.inventory.PrivateInventory;
|
||||
import thaumicenergistics.common.inventory.TheInternalInventory;
|
||||
import thaumicenergistics.common.items.ItemCraftingAspect;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_EssentiaCellTerminal;
|
||||
import thaumicenergistics.common.network.packet.server.Packet_S_EssentiaCellTerminal;
|
||||
@@ -44,7 +44,7 @@ public class ContainerWirelessEssentiaTerminal
|
||||
/**
|
||||
* Import and export inventory slots.
|
||||
*/
|
||||
private PrivateInventory privateInventory = new PrivateInventory( ThaumicEnergistics.MOD_ID + ".item.essentia.cell.inventory", 2, 64 )
|
||||
private TheInternalInventory privateInventory = new TheInternalInventory( ThaumicEnergistics.MOD_ID + ".item.essentia.cell.inventory", 2, 64 )
|
||||
{
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int slotID, final ItemStack itemStack )
|
||||
|
||||
+3
-4
@@ -460,9 +460,6 @@ class HandlerEssentiaStorageBusContainer
|
||||
@Override
|
||||
public void tickingRequest( final IGridNode node, final int TicksSinceLastCall )
|
||||
{
|
||||
// Alteration list
|
||||
List<IAEFluidStack> alterations = null;
|
||||
|
||||
// Create the checklist
|
||||
HashSet<Aspect> aspectsToCheck = new HashSet<Aspect>();
|
||||
|
||||
@@ -489,6 +486,9 @@ class HandlerEssentiaStorageBusContainer
|
||||
return;
|
||||
}
|
||||
|
||||
// Alteration list
|
||||
List<IAEFluidStack> alterations = null;
|
||||
|
||||
// Compare all amounts
|
||||
for( Aspect aspect : aspectsToCheck )
|
||||
{
|
||||
@@ -530,7 +530,6 @@ class HandlerEssentiaStorageBusContainer
|
||||
// Any alterations?
|
||||
if( alterations != null )
|
||||
{
|
||||
// TODO: This needs to be updated to use the new EssentiaGrid
|
||||
// Post the changes
|
||||
this.postAlterationToHostGrid( alterations );
|
||||
}
|
||||
|
||||
@@ -19,13 +19,11 @@ import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
|
||||
public class HandlerItemEssentiaCell
|
||||
implements IMEInventoryHandler<IAEFluidStack>
|
||||
@@ -548,18 +546,8 @@ public class HandlerItemEssentiaCell
|
||||
// Copy the request
|
||||
IAEFluidStack extractedFluid = request.copy();
|
||||
|
||||
/*
|
||||
* NOTE: I don't like this 'fix'
|
||||
* If the machine requesting the extraction is the IO port, lie and say that the full request
|
||||
* was extracted. If I report the actual amount extracted, it gets hung in an infinite loop and
|
||||
* suddenly the network thinks we only have 6mb of essentia gas stored.
|
||||
*/
|
||||
if( !( ( src instanceof MachineSource ) && ( ( (MachineSource)src ).via instanceof TileIOPort ) ) )
|
||||
{
|
||||
// Not IO port, set the actual amount extracted
|
||||
extractedFluid.setStackSize( EssentiaConversionHelper.INSTANCE.convertEssentiaAmountToFluidAmount( extractedEssentiaAmount ) );
|
||||
}
|
||||
|
||||
// Set the amount extracted
|
||||
extractedFluid.setStackSize( EssentiaConversionHelper.INSTANCE.convertEssentiaAmountToFluidAmount( extractedEssentiaAmount ) );
|
||||
return extractedFluid;
|
||||
|
||||
}
|
||||
|
||||
+126
-53
@@ -1,35 +1,65 @@
|
||||
package thaumicenergistics.common.inventory;
|
||||
|
||||
import thaumicenergistics.api.storage.IInventoryUpdateReceiver;
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import thaumicenergistics.common.parts.ThEPartBase;
|
||||
import appeng.api.parts.IPartHost;
|
||||
|
||||
public class PrivateInventory
|
||||
public class TheInternalInventory
|
||||
implements IInventory
|
||||
{
|
||||
|
||||
/**
|
||||
* NBT keys
|
||||
*/
|
||||
private static final String NBT_KEY_SLOT = "Slot";
|
||||
|
||||
public ItemStack[] slots;
|
||||
public String customName;
|
||||
private int stackLimit;
|
||||
private IInventoryUpdateReceiver receiver = null;
|
||||
/**
|
||||
* The squared reach distance.
|
||||
*/
|
||||
private static final double SQUARED_REACH = 64.0D;
|
||||
|
||||
public PrivateInventory( final String customName, final int size, final int stackLimit )
|
||||
/**
|
||||
* Stack size limit.
|
||||
*/
|
||||
private final int stackLimit;
|
||||
|
||||
/**
|
||||
* The inventory slots.
|
||||
*/
|
||||
private final ItemStack[] slots;
|
||||
|
||||
/**
|
||||
* Name of the inventory.
|
||||
*/
|
||||
private final String customName;
|
||||
|
||||
/**
|
||||
* Creates the inventory.
|
||||
*
|
||||
* @param customName
|
||||
* @param size
|
||||
* @param stackLimit
|
||||
*/
|
||||
public TheInternalInventory( final String customName, final int size, final int stackLimit )
|
||||
{
|
||||
this.slots = new ItemStack[size];
|
||||
this.customName = customName;
|
||||
this.stackLimit = stackLimit;
|
||||
}
|
||||
|
||||
public PrivateInventory( final String customName, final int size, final int stackLimit, final IInventoryUpdateReceiver receiver )
|
||||
/**
|
||||
* Clears the specified slot.
|
||||
*
|
||||
* @param slotIndex
|
||||
*/
|
||||
public void clearSlot( final int slotIndex )
|
||||
{
|
||||
this( customName, size, stackLimit );
|
||||
|
||||
this.receiver = receiver;
|
||||
this.slots[slotIndex] = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,10 +68,10 @@ public class PrivateInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int slotId, final int amount )
|
||||
public ItemStack decrStackSize( final int slotIndex, final int amount )
|
||||
{
|
||||
// Get the stack
|
||||
ItemStack slotStack = this.slots[slotId];
|
||||
ItemStack slotStack = this.slots[slotIndex];
|
||||
ItemStack resultStack = null;
|
||||
|
||||
// Is the slot empty?
|
||||
@@ -60,11 +90,11 @@ public class PrivateInventory
|
||||
// Is there anything remaining in the slot?
|
||||
if( remAmount > 0 )
|
||||
{
|
||||
this.slots[slotId].stackSize = remAmount;
|
||||
this.slots[slotIndex].stackSize = remAmount;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.slots[slotId] = null;
|
||||
this.slots[slotIndex] = null;
|
||||
}
|
||||
|
||||
// Was any amount gotten?
|
||||
@@ -79,6 +109,17 @@ public class PrivateInventory
|
||||
return resultStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if there is a stack in the specified slot.
|
||||
*
|
||||
* @param slotIndex
|
||||
* @return
|
||||
*/
|
||||
public boolean getHasStack( final int slotIndex )
|
||||
{
|
||||
return this.slots[slotIndex] != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
@@ -98,15 +139,15 @@ public class PrivateInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot( final int index )
|
||||
public ItemStack getStackInSlot( final int slotIndex )
|
||||
{
|
||||
return this.slots[index];
|
||||
return this.slots[slotIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing( final int slotId )
|
||||
public ItemStack getStackInSlotOnClosing( final int slotIndex )
|
||||
{
|
||||
return this.slots[slotId];
|
||||
return this.slots[slotIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,14 +160,14 @@ public class PrivateInventory
|
||||
* Increases the stack size of the specified slot, and marks the inventory
|
||||
* as dirty.
|
||||
*
|
||||
* @param slotId
|
||||
* @param slotIndex
|
||||
* @param amount
|
||||
* @return The amount that was added.
|
||||
*/
|
||||
public int incrStackSize( final int slotId, final int amount )
|
||||
public int incrStackSize( final int slotIndex, final int amount )
|
||||
{
|
||||
// Get the stack
|
||||
ItemStack slotStack = this.slots[slotId];
|
||||
ItemStack slotStack = this.slots[slotIndex];
|
||||
|
||||
// Assume none was added
|
||||
int added = 0;
|
||||
@@ -142,7 +183,7 @@ public class PrivateInventory
|
||||
// Can any be added?
|
||||
if( added > 0 )
|
||||
{
|
||||
this.slots[slotId].stackSize += added;
|
||||
this.slots[slotIndex].stackSize += added;
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
@@ -172,19 +213,70 @@ public class PrivateInventory
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must override, always return false.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int slotId, final ItemStack itemStack )
|
||||
public boolean isItemValidForSlot( final int slotIndex, final ItemStack itemStack )
|
||||
{
|
||||
// Assume it is not valid
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns true.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean isUseableByPlayer( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Is this ever even used?
|
||||
public boolean isUseableByPlayer( @Nonnull final EntityPlayer player, @Nonnull final ThEPartBase part )
|
||||
{
|
||||
// Get and check the host
|
||||
TileEntity tile = part.getHostTile();
|
||||
if( ( tile == null ) || !( tile instanceof IPartHost ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IPartHost host = (IPartHost)tile;
|
||||
|
||||
// Is the part still attached?
|
||||
if( host.getPart( part.getSide() ) != part )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Perform reach and tile checks.
|
||||
return this.isUseableByPlayer( player, tile );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the tile still exists and the player is within reach range.
|
||||
*
|
||||
* @param player
|
||||
* @param tile
|
||||
* @return
|
||||
*/
|
||||
public boolean isUseableByPlayer( @Nonnull final EntityPlayer player, @Nonnull final TileEntity tile )
|
||||
{
|
||||
return ( tile.getWorldObj().getTileEntity( tile.xCoord, tile.yCoord, tile.zCoord ) == tile )
|
||||
&& ( player.getDistanceSq( tile.xCoord + 0.5D, tile.yCoord + 0.5D, tile.zCoord + 0.5D ) <= SQUARED_REACH );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
}
|
||||
|
||||
public final void readFromNBT( final NBTTagCompound data, final String tagName )
|
||||
{
|
||||
// Ensure there is a data tag
|
||||
@@ -209,7 +301,7 @@ public class PrivateInventory
|
||||
NBTTagCompound nbtCompound = invList.getCompoundTagAt( index );
|
||||
|
||||
// Get the slot number
|
||||
int slotIndex = nbtCompound.getByte( PrivateInventory.NBT_KEY_SLOT ) & 0xFF;
|
||||
int slotIndex = nbtCompound.getByte( TheInternalInventory.NBT_KEY_SLOT ) & 0xFF;
|
||||
|
||||
// Validate the slot number
|
||||
if( ( slotIndex >= 0 ) && ( slotIndex < this.slots.length ) )
|
||||
@@ -221,17 +313,17 @@ public class PrivateInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
public void setInventorySlotContents( final int slotIndex, final ItemStack itemStack )
|
||||
{
|
||||
if( this.receiver != null )
|
||||
// Is the stack size too large?
|
||||
if( ( itemStack != null ) && ( itemStack.stackSize > this.getInventoryStackLimit() ) )
|
||||
{
|
||||
this.receiver.onInventoryChanged( this );
|
||||
itemStack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
this.slots[slotIndex] = itemStack;
|
||||
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public final void writeToNBT( final NBTTagCompound data, final String tagName )
|
||||
@@ -255,7 +347,7 @@ public class PrivateInventory
|
||||
NBTTagCompound nbtCompound = new NBTTagCompound();
|
||||
|
||||
// Set the slot number
|
||||
nbtCompound.setByte( PrivateInventory.NBT_KEY_SLOT, (byte)slotIndex );
|
||||
nbtCompound.setByte( TheInternalInventory.NBT_KEY_SLOT, (byte)slotIndex );
|
||||
|
||||
// Save the inventory
|
||||
this.slots[slotIndex].writeToNBT( nbtCompound );
|
||||
@@ -272,23 +364,4 @@ public class PrivateInventory
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents( final int slotId, final ItemStack itemStack )
|
||||
{
|
||||
// Is the stack size too large?
|
||||
if( ( itemStack != null ) && ( itemStack.stackSize > this.getInventoryStackLimit() ) )
|
||||
{
|
||||
itemStack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
this.slots[slotId] = itemStack;
|
||||
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public void setReceiver( final IInventoryUpdateReceiver receiver )
|
||||
{
|
||||
this.receiver = receiver;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package thaumicenergistics.common.items;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import thaumicenergistics.common.registries.ThEStrings;
|
||||
import thaumicenergistics.common.tiles.TileArcaneAssembler;
|
||||
|
||||
public class ItemBlockArcaneAssembler
|
||||
extends ItemBlock
|
||||
{
|
||||
|
||||
public ItemBlockArcaneAssembler( final Block block )
|
||||
{
|
||||
super( block );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation( final ItemStack stack, final EntityPlayer player, final List displayList, final boolean advancedItemTooltips )
|
||||
{
|
||||
// Ensure the stack has a tag
|
||||
if( !stack.hasTagCompound() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure it has stored vis
|
||||
if( stack.getTagCompound().hasKey( TileArcaneAssembler.NBTKEY_STORED_VIS ) )
|
||||
{
|
||||
// Add the info
|
||||
displayList.add( EnumChatFormatting.WHITE.toString() + EnumChatFormatting.ITALIC.toString()
|
||||
+ ThEStrings.Tooltip_ArcaneAssemblerHasVis.getLocalized() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -115,7 +115,7 @@ public class ItemBlockEssentiaVibrationChamber
|
||||
{
|
||||
// Let the user know they can hold shift
|
||||
displayList.add( EnumChatFormatting.WHITE.toString() + EnumChatFormatting.ITALIC.toString() +
|
||||
ThEStrings.Tooltip_CellDetails.getLocalized() );
|
||||
ThEStrings.Tooltip_ItemStackDetails.getLocalized() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.storage.*;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.core.localization.GuiText;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemEssentiaCell
|
||||
extends Item
|
||||
@@ -150,7 +152,7 @@ public class ItemEssentiaCell
|
||||
{
|
||||
// Let the user know they can hold shift
|
||||
displayList.add( EnumChatFormatting.WHITE.toString() + EnumChatFormatting.ITALIC.toString() +
|
||||
ThEStrings.Tooltip_CellDetails.getLocalized() );
|
||||
ThEStrings.Tooltip_ItemStackDetails.getLocalized() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,6 +270,7 @@ public class ItemEssentiaCell
|
||||
* ME Chest icon
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getTopTexture_Dark()
|
||||
{
|
||||
return BlockTextureManager.ESSENTIA_TERMINAL.getTextures()[0];
|
||||
@@ -277,6 +280,7 @@ public class ItemEssentiaCell
|
||||
* ME Chest icon
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getTopTexture_Light()
|
||||
{
|
||||
return BlockTextureManager.ESSENTIA_TERMINAL.getTextures()[2];
|
||||
@@ -286,6 +290,7 @@ public class ItemEssentiaCell
|
||||
* ME Chest icon
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getTopTexture_Medium()
|
||||
{
|
||||
return BlockTextureManager.ESSENTIA_TERMINAL.getTextures()[1];
|
||||
|
||||
@@ -95,8 +95,16 @@ public class ItemStorageComponent
|
||||
// Add each type
|
||||
for( int i = 0; i < this.icons.length; i++ )
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon( ThaumicEnergistics.MOD_ID + ":storage.component." +
|
||||
EnumEssentiaStorageTypes.fromIndex[i].suffix );
|
||||
// Skip creative
|
||||
if( i == EnumEssentiaStorageTypes.Type_Creative.index )
|
||||
{
|
||||
this.icons[i] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon( ThaumicEnergistics.MOD_ID + ":storage.component." +
|
||||
EnumEssentiaStorageTypes.fromIndex[i].suffix );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.api.storage.IInventoryUpdateReceiver;
|
||||
import thaumicenergistics.client.gui.GuiEssentiaStorageBus;
|
||||
import thaumicenergistics.client.textures.BlockTextureManager;
|
||||
import thaumicenergistics.common.container.ContainerPartEssentiaStorageBus;
|
||||
@@ -52,7 +51,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartEssentiaStorageBus
|
||||
extends ThEPartBase
|
||||
implements IGridTickable, ICellContainer, IInventoryUpdateReceiver, IAspectSlotPart, IAEAppEngInventory, IPriorityHost
|
||||
implements IGridTickable, ICellContainer, IAspectSlotPart, IAEAppEngInventory, IPriorityHost
|
||||
{
|
||||
/**
|
||||
* Number of filtered aspects we can have
|
||||
@@ -121,6 +120,15 @@ public class PartEssentiaStorageBus
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the handler on the inverted state.
|
||||
*/
|
||||
private void updateInverterState()
|
||||
{
|
||||
boolean inverted = AEApi.instance().definitions().materials().cardInverter().isSameAs( this.upgradeInventory.getStackInSlot( 0 ) );
|
||||
this.handler.setInverted( inverted );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new filter from the specified itemstack.
|
||||
*
|
||||
@@ -372,7 +380,7 @@ public class PartEssentiaStorageBus
|
||||
@Override
|
||||
public void onChangeInventory( final IInventory inv, final int arg1, final InvOperation arg2, final ItemStack arg3, final ItemStack arg4 )
|
||||
{
|
||||
this.onInventoryChanged( inv );
|
||||
this.updateInverterState();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -403,16 +411,6 @@ public class PartEssentiaStorageBus
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the handler on the inverted state.
|
||||
*/
|
||||
@Override
|
||||
public void onInventoryChanged( final IInventory sourceInventory )
|
||||
{
|
||||
boolean inverted = AEApi.instance().definitions().materials().cardInverter().isSameAs( this.upgradeInventory.getStackInSlot( 0 ) );
|
||||
this.handler.setInverted( inverted );
|
||||
}
|
||||
|
||||
/**
|
||||
* /** Updates the grid and handler that a neighbor has changed.
|
||||
*/
|
||||
@@ -488,7 +486,7 @@ public class PartEssentiaStorageBus
|
||||
this.upgradeInventory.readFromNBT( data, PartEssentiaStorageBus.NBT_KEY_UPGRADES );
|
||||
|
||||
// Update the handler inverted
|
||||
this.onInventoryChanged( this.upgradeInventory );
|
||||
this.updateInverterState();
|
||||
}
|
||||
|
||||
// Read void
|
||||
|
||||
@@ -17,7 +17,7 @@ import thaumicenergistics.common.ThEGuiHandler;
|
||||
import thaumicenergistics.common.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.container.ContainerEssentiaCellTerminalBase;
|
||||
import thaumicenergistics.common.container.ContainerEssentiaTerminal;
|
||||
import thaumicenergistics.common.inventory.PrivateInventory;
|
||||
import thaumicenergistics.common.inventory.TheInternalInventory;
|
||||
import thaumicenergistics.common.network.packet.server.Packet_S_ChangeGui;
|
||||
import thaumicenergistics.common.registries.AEPartsEnum;
|
||||
import thaumicenergistics.common.registries.EnumCache;
|
||||
@@ -31,7 +31,6 @@ import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AEColor;
|
||||
@@ -42,7 +41,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartEssentiaTerminal
|
||||
extends ThERotateablePart
|
||||
implements ICraftingIssuerHost, ITerminalHost
|
||||
implements ICraftingIssuerHost
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -80,7 +79,7 @@ public class PartEssentiaTerminal
|
||||
*/
|
||||
private ViewItems viewMode = DEFAULT_VIEW_MODE;
|
||||
|
||||
private PrivateInventory inventory = new PrivateInventory( ThaumicEnergistics.MOD_ID + ".part.aspect.terminal", 2, 64 )
|
||||
private TheInternalInventory inventory = new TheInternalInventory( ThaumicEnergistics.MOD_ID + ".part.aspect.terminal", 2, 64 )
|
||||
{
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int slotId, final ItemStack itemStack )
|
||||
@@ -98,6 +97,18 @@ public class PartEssentiaTerminal
|
||||
super( AEPartsEnum.EssentiaTerminal );
|
||||
}
|
||||
|
||||
/**
|
||||
* Informs all open containers to update their respective clients
|
||||
* that the mode has changed.
|
||||
*/
|
||||
private void notifyListenersOfModeChanged()
|
||||
{
|
||||
for( ContainerEssentiaTerminal listener : this.listeners )
|
||||
{
|
||||
listener.onModeChanged( this.sortMode, this.viewMode );
|
||||
}
|
||||
}
|
||||
|
||||
public void addListener( final ContainerEssentiaCellTerminalBase container )
|
||||
{
|
||||
if( container instanceof ContainerEssentiaTerminal )
|
||||
@@ -197,7 +208,7 @@ public class PartEssentiaTerminal
|
||||
return PartEssentiaTerminal.IDLE_POWER_DRAIN;
|
||||
}
|
||||
|
||||
public PrivateInventory getInventory()
|
||||
public TheInternalInventory getInventory()
|
||||
{
|
||||
return this.inventory;
|
||||
}
|
||||
@@ -261,18 +272,6 @@ public class PartEssentiaTerminal
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Informs all open containers to update their respective clients
|
||||
* that the mode has changed.
|
||||
*/
|
||||
public void notifyListenersOfModeChanged()
|
||||
{
|
||||
for( ContainerEssentiaTerminal listener : this.listeners )
|
||||
{
|
||||
listener.onModeChanged( this.sortMode, this.viewMode );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player has changed sorting modes.
|
||||
*
|
||||
|
||||
@@ -10,7 +10,6 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.IAspectContainer;
|
||||
import thaumicenergistics.api.storage.IInventoryUpdateReceiver;
|
||||
import thaumicenergistics.client.gui.GuiEssentiaIO;
|
||||
import thaumicenergistics.common.container.ContainerPartEssentiaIOBus;
|
||||
import thaumicenergistics.common.network.IAspectSlotPart;
|
||||
@@ -38,7 +37,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class ThEPartEssentiaIOBus_Base
|
||||
extends ThEPartBase
|
||||
implements IGridTickable, IInventoryUpdateReceiver, IAspectSlotPart, IAEAppEngInventory
|
||||
implements IGridTickable, IAspectSlotPart, IAEAppEngInventory
|
||||
{
|
||||
/**
|
||||
* How much essentia can be transfered per second.
|
||||
@@ -235,6 +234,54 @@ public abstract class ThEPartEssentiaIOBus_Base
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUpgradeState()
|
||||
{
|
||||
int oldFilterSize = this.filterSize;
|
||||
|
||||
this.filterSize = 0;
|
||||
this.redstoneControlled = false;
|
||||
this.upgradeSpeedCount = 0;
|
||||
|
||||
IMaterials aeMaterals = AEApi.instance().definitions().materials();
|
||||
|
||||
for( int i = 0; i < this.upgradeInventory.getSizeInventory(); i++ )
|
||||
{
|
||||
ItemStack slotStack = this.upgradeInventory.getStackInSlot( i );
|
||||
|
||||
if( slotStack != null )
|
||||
{
|
||||
if( aeMaterals.cardCapacity().isSameAs( slotStack ) )
|
||||
{
|
||||
this.filterSize++ ;
|
||||
}
|
||||
else if( aeMaterals.cardRedstone().isSameAs( slotStack ) )
|
||||
{
|
||||
this.redstoneControlled = true;
|
||||
}
|
||||
else if( aeMaterals.cardSpeed().isSameAs( slotStack ) )
|
||||
{
|
||||
this.upgradeSpeedCount++ ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Did the filter size change?
|
||||
if( oldFilterSize != this.filterSize )
|
||||
{
|
||||
this.resizeAvailableArray();
|
||||
}
|
||||
|
||||
// Is this client side?
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.notifyListenersOfFilterSizeChange();
|
||||
|
||||
this.notifyListenersOfRedstoneControlledChange();
|
||||
}
|
||||
|
||||
public boolean addFilteredAspectFromItemstack( final EntityPlayer player, final ItemStack itemStack )
|
||||
{
|
||||
Aspect itemAspect = EssentiaItemContainerHelper.INSTANCE.getFilterAspectFromItem( itemStack );
|
||||
@@ -365,7 +412,7 @@ public abstract class ThEPartEssentiaIOBus_Base
|
||||
{
|
||||
boolean activated = super.onActivate( player, position );
|
||||
|
||||
this.onInventoryChanged( null );
|
||||
this.updateUpgradeState();
|
||||
|
||||
return activated;
|
||||
}
|
||||
@@ -375,7 +422,7 @@ public abstract class ThEPartEssentiaIOBus_Base
|
||||
{
|
||||
if( inv == this.upgradeInventory )
|
||||
{
|
||||
this.onInventoryChanged( inv );
|
||||
this.updateUpgradeState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,55 +463,6 @@ public abstract class ThEPartEssentiaIOBus_Base
|
||||
Packet_C_EssentiaIOBus.sendBusState( player, this.redstoneMode, this.filterSize, this.redstoneControlled );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged( final IInventory sourceInventory )
|
||||
{
|
||||
int oldFilterSize = this.filterSize;
|
||||
|
||||
this.filterSize = 0;
|
||||
this.redstoneControlled = false;
|
||||
this.upgradeSpeedCount = 0;
|
||||
|
||||
IMaterials aeMaterals = AEApi.instance().definitions().materials();
|
||||
|
||||
for( int i = 0; i < this.upgradeInventory.getSizeInventory(); i++ )
|
||||
{
|
||||
ItemStack slotStack = this.upgradeInventory.getStackInSlot( i );
|
||||
|
||||
if( slotStack != null )
|
||||
{
|
||||
if( aeMaterals.cardCapacity().isSameAs( slotStack ) )
|
||||
{
|
||||
this.filterSize++ ;
|
||||
}
|
||||
else if( aeMaterals.cardRedstone().isSameAs( slotStack ) )
|
||||
{
|
||||
this.redstoneControlled = true;
|
||||
}
|
||||
else if( aeMaterals.cardSpeed().isSameAs( slotStack ) )
|
||||
{
|
||||
this.upgradeSpeedCount++ ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Did the filter size change?
|
||||
if( oldFilterSize != this.filterSize )
|
||||
{
|
||||
this.resizeAvailableArray();
|
||||
}
|
||||
|
||||
// Is this client side?
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.notifyListenersOfFilterSizeChange();
|
||||
|
||||
this.notifyListenersOfRedstoneControlledChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
@@ -568,7 +566,7 @@ public abstract class ThEPartEssentiaIOBus_Base
|
||||
{
|
||||
this.upgradeInventory.readFromNBT( data, ThEPartEssentiaIOBus_Base.NBT_KEY_UPGRADE_INV );
|
||||
|
||||
this.onInventoryChanged( this.upgradeInventory );
|
||||
this.updateUpgradeState();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package thaumicenergistics.common.registries;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import thaumicenergistics.common.blocks.*;
|
||||
import thaumicenergistics.common.items.ItemBlockArcaneAssembler;
|
||||
import thaumicenergistics.common.items.ItemBlockEssentiaVibrationChamber;
|
||||
|
||||
public enum BlockEnum
|
||||
@@ -12,7 +13,7 @@ public enum BlockEnum
|
||||
IRON_GEAR_BOX (ThEStrings.Block_IronGearbox, new BlockGearBox()),
|
||||
THAUMIUM_GEAR_BOX (ThEStrings.Block_ThaumiumGearbox, new BlockGolemGearBox()),
|
||||
ESSENTIA_CELL_WORKBENCH (ThEStrings.Block_EssentiaCellWorkbench, new BlockEssentiaCellWorkbench()),
|
||||
ARCANE_ASSEMBLER (ThEStrings.Block_ArcaneAssembler, new BlockArcaneAssembler()),
|
||||
ARCANE_ASSEMBLER (ThEStrings.Block_ArcaneAssembler, new BlockArcaneAssembler(), ItemBlockArcaneAssembler.class),
|
||||
KNOWLEDGE_INSCRIBER (ThEStrings.Block_KnowledgeInscriber, new BlockKnowledgeInscriber()),
|
||||
ESSENTIA_VIBRATION_CHAMBER (ThEStrings.Block_EssentiaVibrationChamber, new BlockEssentiaVibrationChamber(),
|
||||
ItemBlockEssentiaVibrationChamber.class),
|
||||
@@ -31,7 +32,7 @@ public enum BlockEnum
|
||||
/**
|
||||
* Custom item
|
||||
*/
|
||||
private final Class<? extends ItemBlock> itemBlockClass;
|
||||
public final Class<? extends ItemBlock> itemBlockClass;
|
||||
|
||||
/**
|
||||
* Cache of the enum values
|
||||
@@ -77,11 +78,6 @@ public enum BlockEnum
|
||||
return this.block;
|
||||
}
|
||||
|
||||
public Class<? extends ItemBlock> getItemClass()
|
||||
{
|
||||
return this.itemBlockClass;
|
||||
}
|
||||
|
||||
// Return the name
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
|
||||
@@ -56,9 +56,10 @@ public enum ThEStrings
|
||||
Item_FocusAEWrench_Disabled ("item.focus.aewrench.disabled", true),
|
||||
|
||||
// Tooltips
|
||||
Tooltip_ItemStackDetails ("tooltip.itemstack.details", false),
|
||||
Tooltip_CellBytes ("tooltip.essentia.cell.bytes", false),
|
||||
Tooltip_CellTypes ("tooltip.essentia.cell.types", false),
|
||||
Tooltip_CellDetails ("tooltip.essentia.cell.details", false),
|
||||
Tooltip_ArcaneAssemblerHasVis ("tooltip.arcane.assembler.hasVis", false),
|
||||
|
||||
// Button Tooltips
|
||||
TooltipButton_DepositCraftingGrid ("tooltip.button.clear.crafting", false),
|
||||
|
||||
@@ -19,11 +19,10 @@ import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumicenergistics.api.ThEApi;
|
||||
import thaumicenergistics.api.grid.IDigiVisSource;
|
||||
import thaumicenergistics.api.storage.IInventoryUpdateReceiver;
|
||||
import thaumicenergistics.client.gui.ThEGuiHelper;
|
||||
import thaumicenergistics.common.blocks.BlockArcaneAssembler;
|
||||
import thaumicenergistics.common.inventory.HandlerKnowledgeCore;
|
||||
import thaumicenergistics.common.inventory.PrivateInventory;
|
||||
import thaumicenergistics.common.inventory.TheInternalInventory;
|
||||
import thaumicenergistics.common.items.ItemKnowledgeCore;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import thaumicenergistics.integration.IWailaSource;
|
||||
@@ -55,7 +54,6 @@ import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.core.sync.packets.PacketAssemblerAnimation;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.GridException;
|
||||
import appeng.parts.automation.BlockUpgradeInventory;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.tile.TileEvent;
|
||||
@@ -69,39 +67,19 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileArcaneAssembler
|
||||
extends AENetworkInvTile
|
||||
implements ICraftingProvider, IInventoryUpdateReceiver, IWailaSource
|
||||
implements ICraftingProvider, IWailaSource
|
||||
{
|
||||
private class AssemblerInventory
|
||||
extends PrivateInventory
|
||||
{
|
||||
|
||||
public AssemblerInventory()
|
||||
{
|
||||
super( "ArcaneAssemblerInventory", TileArcaneAssembler.SLOT_COUNT, 64, TileArcaneAssembler.this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int slotId, final ItemStack itemStack )
|
||||
{
|
||||
// Is the slot being assigned the knowledge core slot?
|
||||
if( slotId == TileArcaneAssembler.KCORE_SLOT_INDEX )
|
||||
{
|
||||
// Ensure the item is a knowledge core.
|
||||
return( ( itemStack == null ) || ( itemStack.getItem() instanceof ItemKnowledgeCore ) );
|
||||
}
|
||||
|
||||
// Assume it is not valid
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* NBT Keys
|
||||
*/
|
||||
private static final String NBTKEY_KCORE = "kcore", NBTKEY_VIS_INTERFACE = "vis_interface", NBTKEY_STORED_VIS = "stored_vis",
|
||||
private static final String NBTKEY_VIS_INTERFACE = "vis_interface",
|
||||
NBTKEY_UPGRADES = "upgradeCount", NBTKEY_UPGRADEINV = "upgrades", NBTKEY_CRAFTING = "isCrafting",
|
||||
NBTKEY_CRAFTING_PATTERN = "pattern", NBTKEY_DISCOUNT_ARMOR = "discount_armor#";
|
||||
NBTKEY_CRAFTING_PATTERN = "pattern";
|
||||
|
||||
/**
|
||||
* NBT Key for stored vis.
|
||||
*/
|
||||
public static final String NBTKEY_STORED_VIS = "stored_vis";
|
||||
|
||||
/**
|
||||
* Used to simulate floating point amounts of vis.
|
||||
@@ -142,7 +120,7 @@ public class TileArcaneAssembler
|
||||
/**
|
||||
* Holds the patterns and the kcore
|
||||
*/
|
||||
private AssemblerInventory internalInventory;
|
||||
private final TheInternalInventory internalInventory;
|
||||
|
||||
/**
|
||||
* Holds the upgrades
|
||||
@@ -199,11 +177,6 @@ public class TileArcaneAssembler
|
||||
*/
|
||||
private int upgradeCount = 0;
|
||||
|
||||
/**
|
||||
* Set to true when being dismantled by a wrench.
|
||||
*/
|
||||
private boolean wasDismantled = false;
|
||||
|
||||
/**
|
||||
* How much discount each aspect is receiving.
|
||||
*/
|
||||
@@ -219,13 +192,18 @@ public class TileArcaneAssembler
|
||||
*/
|
||||
private boolean delayedUpdate = false;
|
||||
|
||||
/**
|
||||
* Set true when the tile is ready.
|
||||
*/
|
||||
private boolean isReady = false;
|
||||
|
||||
/**
|
||||
* Creates the assembler and it's inventory.
|
||||
*/
|
||||
public TileArcaneAssembler()
|
||||
{
|
||||
// Create the inventory
|
||||
this.internalInventory = new AssemblerInventory();
|
||||
// Create the internal inventory
|
||||
this.internalInventory = new TheInternalInventory( "ArcaneAssemblerInventory", TileArcaneAssembler.SLOT_COUNT, 64 );
|
||||
|
||||
// Create the upgrade inventory
|
||||
this.upgradeInventory = new BlockUpgradeInventory( ThEApi.instance().blocks().ArcaneAssembler.getBlock(), this,
|
||||
@@ -325,7 +303,7 @@ public class TileArcaneAssembler
|
||||
|
||||
// Mark the assembler as no longer crafting
|
||||
this.isCrafting = false;
|
||||
this.internalInventory.slots[TileArcaneAssembler.TARGET_SLOT_INDEX] = null;
|
||||
this.internalInventory.clearSlot( TARGET_SLOT_INDEX );
|
||||
this.currentPattern = null;
|
||||
|
||||
// Mark for network update
|
||||
@@ -417,6 +395,27 @@ public class TileArcaneAssembler
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the tile is connected to the AE network and active.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isActive()
|
||||
{
|
||||
// Are we server side?
|
||||
if( EffectiveSide.isServerSide() )
|
||||
{
|
||||
// Do we have a proxy and grid node?
|
||||
if( ( this.getProxy() != null ) && ( this.getProxy().getNode() != null ) )
|
||||
{
|
||||
// Get the grid node activity
|
||||
this.isActive = this.getProxy().getNode().isActive();
|
||||
}
|
||||
}
|
||||
|
||||
return this.isActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the tile for a delayed update.
|
||||
*/
|
||||
@@ -478,6 +477,22 @@ public class TileArcaneAssembler
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the Assembler.
|
||||
*/
|
||||
private void setupAssemblerTile()
|
||||
{
|
||||
// Ignored on client side
|
||||
if( FMLCommonHandler.instance().getEffectiveSide().isServer() )
|
||||
{
|
||||
// Set idle power usage
|
||||
this.getProxy().setIdlePowerUsage( TileArcaneAssembler.IDLE_POWER );
|
||||
|
||||
// Set that we require a channel
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of ticks required to craft an item.
|
||||
*/
|
||||
@@ -506,12 +521,12 @@ public class TileArcaneAssembler
|
||||
if( ( pIterator != null ) && ( pIterator.hasNext() ) )
|
||||
{
|
||||
// Set to pattern result
|
||||
this.internalInventory.slots[index] = pIterator.next();
|
||||
this.internalInventory.setInventorySlotContents( index, pIterator.next() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear slot
|
||||
this.internalInventory.slots[index] = null;
|
||||
this.internalInventory.clearSlot( index );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -540,10 +555,10 @@ public class TileArcaneAssembler
|
||||
}
|
||||
|
||||
// Is the assembler crafting anything?
|
||||
if( ( this.isCrafting ) && ( this.internalInventory.slots[TileArcaneAssembler.TARGET_SLOT_INDEX] != null ) )
|
||||
if( ( this.isCrafting ) && this.internalInventory.getHasStack( TARGET_SLOT_INDEX ) )
|
||||
{
|
||||
// Add what is being crafted and the percent it is complete
|
||||
tooltip.add( String.format( "%s, %.0f%%", this.internalInventory.slots[TileArcaneAssembler.TARGET_SLOT_INDEX].getDisplayName(),
|
||||
tooltip.add( String.format( "%s, %.0f%%", this.internalInventory.getStackInSlot( TARGET_SLOT_INDEX ).getDisplayName(),
|
||||
( ( this.getPercentComplete() * 100.0F ) ) ) );
|
||||
}
|
||||
|
||||
@@ -573,39 +588,9 @@ public class TileArcaneAssembler
|
||||
tooltip.add( strAspects.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player has the security permissions to open the GUI.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean canPlayerOpenGUI( final EntityPlayer player )
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get the security grid
|
||||
ISecurityGrid sGrid = this.getProxy().getSecurity();
|
||||
|
||||
// Return true if the player has inject and extract permissions
|
||||
return( ( sGrid.hasPermission( player, SecurityPermissions.INJECT ) ) && ( sGrid.hasPermission( player, SecurityPermissions.EXTRACT ) ) );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public final void channelEvent( final MENetworkChannelsChanged event )
|
||||
{
|
||||
/*
|
||||
// Update the grid node
|
||||
if( this.gridProxy.isReady() )
|
||||
{
|
||||
this.gridProxy.getNode().updateState();
|
||||
}
|
||||
*/
|
||||
|
||||
// Mark for update
|
||||
this.markForUpdate();
|
||||
}
|
||||
@@ -633,37 +618,33 @@ public class TileArcaneAssembler
|
||||
@Override
|
||||
public void getDrops( final World world, final int x, final int y, final int z, final List<ItemStack> drops )
|
||||
{
|
||||
if( !this.wasDismantled )
|
||||
// Add the kCore
|
||||
ItemStack kCore = this.internalInventory.getStackInSlot( TileArcaneAssembler.KCORE_SLOT_INDEX );
|
||||
if( kCore != null )
|
||||
{
|
||||
// Add the kCore
|
||||
ItemStack kCore = this.internalInventory.slots[TileArcaneAssembler.KCORE_SLOT_INDEX];
|
||||
if( kCore != null )
|
||||
drops.add( kCore );
|
||||
}
|
||||
|
||||
// Add upgrades
|
||||
for( int i = 0; i < this.upgradeInventory.getSizeInventory(); i++ )
|
||||
{
|
||||
ItemStack upgrade = this.upgradeInventory.getStackInSlot( i );
|
||||
|
||||
if( upgrade != null )
|
||||
{
|
||||
drops.add( kCore );
|
||||
drops.add( upgrade );
|
||||
}
|
||||
}
|
||||
|
||||
// Add upgrades
|
||||
for( int i = 0; i < this.upgradeInventory.getSizeInventory(); i++ )
|
||||
// Add armor
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
ItemStack armor = this.internalInventory.getStackInSlot( TileArcaneAssembler.DISCOUNT_ARMOR_INDEX + i );
|
||||
|
||||
if( armor != null )
|
||||
{
|
||||
ItemStack upgrade = this.upgradeInventory.getStackInSlot( i );
|
||||
|
||||
if( upgrade != null )
|
||||
{
|
||||
drops.add( upgrade );
|
||||
}
|
||||
drops.add( armor );
|
||||
}
|
||||
|
||||
// Add armor
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
ItemStack armor = this.internalInventory.slots[TileArcaneAssembler.DISCOUNT_ARMOR_INDEX + i];
|
||||
|
||||
if( armor != null )
|
||||
{
|
||||
drops.add( armor );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,6 +670,11 @@ public class TileArcaneAssembler
|
||||
return new DimensionalCoord( this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the percent the current crafting job is complete.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public float getPercentComplete()
|
||||
{
|
||||
float percent = 0.0F;
|
||||
@@ -727,86 +713,69 @@ public class TileArcaneAssembler
|
||||
return this.visDiscount.get( aspect );
|
||||
}
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
// Are we server side?
|
||||
if( EffectiveSide.isServerSide() )
|
||||
{
|
||||
// Do we have a proxy and grid node?
|
||||
if( ( this.getProxy() != null ) && ( this.getProxy().getNode() != null ) )
|
||||
{
|
||||
// Get the grid node activity
|
||||
this.isActive = this.getProxy().getNode().isActive();
|
||||
}
|
||||
}
|
||||
|
||||
return this.isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBusy()
|
||||
{
|
||||
return this.isCrafting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the tile entity is about to be destroyed by a block break.
|
||||
*/
|
||||
public void onBreak()
|
||||
{
|
||||
this.isCrafting = false;
|
||||
this.getProxy().invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the upgrade inventory changes
|
||||
*/
|
||||
@Override
|
||||
public void onChangeInventory( final IInventory inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
|
||||
public boolean isItemValidForSlot( final int slotId, final ItemStack itemStack )
|
||||
{
|
||||
// Reset the upgrade count
|
||||
this.upgradeCount = 0;
|
||||
|
||||
IMaterials aeMaterals = AEApi.instance().definitions().materials();
|
||||
|
||||
// Look for speed cards
|
||||
for( int i = 0; i < this.upgradeInventory.getSizeInventory(); i++ )
|
||||
// Is the slot being assigned the knowledge core slot?
|
||||
if( slotId == KCORE_SLOT_INDEX )
|
||||
{
|
||||
ItemStack slotStack = this.upgradeInventory.getStackInSlot( i );
|
||||
|
||||
if( slotStack != null )
|
||||
{
|
||||
if( aeMaterals.cardSpeed().isSameAs( slotStack ) )
|
||||
{
|
||||
this.upgradeCount++ ;
|
||||
}
|
||||
}
|
||||
// Ensure the item is a knowledge core.
|
||||
return( ( itemStack == null ) || ( itemStack.getItem() instanceof ItemKnowledgeCore ) );
|
||||
}
|
||||
|
||||
if( EffectiveSide.isServerSide() )
|
||||
{
|
||||
// Mark for save
|
||||
this.markDirty();
|
||||
// Assume it is not valid
|
||||
return false;
|
||||
}
|
||||
|
||||
// Mark for network update
|
||||
this.markForUpdate();
|
||||
@Override
|
||||
public boolean isUseableByPlayer( final EntityPlayer player )
|
||||
{
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
// Ignored on the client side.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check basic usability
|
||||
if( !this.internalInventory.isUseableByPlayer( player, this ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the security grid
|
||||
try
|
||||
{
|
||||
// Get the security grid
|
||||
ISecurityGrid sGrid = this.getProxy().getSecurity();
|
||||
|
||||
// Return true if the player has inject and extract permissions
|
||||
return( ( sGrid.hasPermission( player, SecurityPermissions.INJECT ) ) && ( sGrid.hasPermission( player, SecurityPermissions.EXTRACT ) ) );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when being dismantled.
|
||||
*/
|
||||
public void onDismantled()
|
||||
{
|
||||
this.wasDismantled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the internal inventory changes.
|
||||
*/
|
||||
@Override
|
||||
public void onInventoryChanged( final IInventory sourceInventory )
|
||||
public void markDirty()
|
||||
{
|
||||
// Call super
|
||||
super.markDirty();
|
||||
|
||||
// Is the tile ready?
|
||||
if( !this.isReady )
|
||||
{
|
||||
// Still in setup phase.
|
||||
return;
|
||||
}
|
||||
|
||||
// Is there a kcore?
|
||||
ItemStack kCore = this.internalInventory.getStackInSlot( TileArcaneAssembler.KCORE_SLOT_INDEX );
|
||||
if( kCore != null )
|
||||
@@ -849,94 +818,51 @@ public class TileArcaneAssembler
|
||||
|
||||
//Recalculate the vis discount.
|
||||
this.calculateVisDiscounts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the tile entity is about to be destroyed by a block break.
|
||||
*/
|
||||
public void onBreak()
|
||||
{
|
||||
this.isCrafting = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the upgrade inventory changes
|
||||
*/
|
||||
@Override
|
||||
public void onChangeInventory( final IInventory inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
|
||||
{
|
||||
// Reset the upgrade count
|
||||
this.upgradeCount = 0;
|
||||
|
||||
IMaterials aeMaterals = AEApi.instance().definitions().materials();
|
||||
|
||||
// Look for speed cards
|
||||
for( int i = 0; i < this.upgradeInventory.getSizeInventory(); i++ )
|
||||
{
|
||||
ItemStack slotStack = this.upgradeInventory.getStackInSlot( i );
|
||||
|
||||
if( slotStack != null )
|
||||
{
|
||||
if( aeMaterals.cardSpeed().isSameAs( slotStack ) )
|
||||
{
|
||||
this.upgradeCount++ ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( EffectiveSide.isServerSide() )
|
||||
{
|
||||
// Mark for save.
|
||||
// Mark for save
|
||||
this.markDirty();
|
||||
|
||||
// Mark for network update
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void onLoadNBT( final NBTTagCompound data )
|
||||
{
|
||||
try
|
||||
{
|
||||
// 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] );
|
||||
|
||||
// Update the pattern slots
|
||||
this.updatePatternSlots();
|
||||
|
||||
// Update the network
|
||||
this.stalePatterns = true;
|
||||
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Is there relay info?
|
||||
if( data.hasKey( TileArcaneAssembler.NBTKEY_VIS_INTERFACE ) )
|
||||
{
|
||||
this.visSourceInfo.readFromNBT( data, TileArcaneAssembler.NBTKEY_VIS_INTERFACE );
|
||||
}
|
||||
|
||||
// Is there stored vis info?
|
||||
if( data.hasKey( TileArcaneAssembler.NBTKEY_STORED_VIS ) )
|
||||
{
|
||||
this.storedVis.readFromNBT( data, TileArcaneAssembler.NBTKEY_STORED_VIS );
|
||||
}
|
||||
|
||||
// Read upgrade count
|
||||
if( data.hasKey( TileArcaneAssembler.NBTKEY_UPGRADES ) )
|
||||
{
|
||||
this.upgradeCount = data.getInteger( TileArcaneAssembler.NBTKEY_UPGRADES );
|
||||
}
|
||||
|
||||
// Read upgrade inventory
|
||||
this.upgradeInventory.readFromNBT( data, TileArcaneAssembler.NBTKEY_UPGRADEINV );
|
||||
|
||||
// Read the crafting status
|
||||
if( data.hasKey( TileArcaneAssembler.NBTKEY_CRAFTING ) )
|
||||
{
|
||||
this.isCrafting = data.getBoolean( TileArcaneAssembler.NBTKEY_CRAFTING );
|
||||
}
|
||||
|
||||
// Read the pattern
|
||||
if( data.hasKey( TileArcaneAssembler.NBTKEY_CRAFTING_PATTERN ) )
|
||||
{
|
||||
this.currentPattern = new ArcaneCraftingPattern( this.internalInventory.slots[TileArcaneAssembler.KCORE_SLOT_INDEX],
|
||||
data.getCompoundTag( TileArcaneAssembler.NBTKEY_CRAFTING_PATTERN ) );
|
||||
}
|
||||
|
||||
// Read the armor
|
||||
for( int index = 0; index < 4; index++ )
|
||||
{
|
||||
if( data.hasKey( TileArcaneAssembler.NBTKEY_DISCOUNT_ARMOR + index ) )
|
||||
{
|
||||
this.internalInventory.slots[TileArcaneAssembler.DISCOUNT_ARMOR_INDEX + index] = ItemStack.loadItemStackFromNBT( data
|
||||
.getCompoundTag( TileArcaneAssembler.NBTKEY_DISCOUNT_ARMOR + index ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Setup the assembler
|
||||
this.setupAssemblerTile();
|
||||
|
||||
// Recalculate the vis discounts
|
||||
this.calculateVisDiscounts();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the player right-clicks the assembler with a memory card in
|
||||
* hand.
|
||||
@@ -984,16 +910,43 @@ public class TileArcaneAssembler
|
||||
@Override
|
||||
public void onReady()
|
||||
{
|
||||
try
|
||||
// Call super
|
||||
super.onReady();
|
||||
|
||||
// Is there a knowledge core?
|
||||
if( this.internalInventory.getHasStack( KCORE_SLOT_INDEX ) )
|
||||
{
|
||||
this.getProxy().onReady();
|
||||
// Is there a pattern?
|
||||
if( this.currentPattern != null )
|
||||
{
|
||||
// Set the core
|
||||
this.currentPattern.setKnowledgeCore( this.internalInventory.getStackInSlot( KCORE_SLOT_INDEX ) );
|
||||
}
|
||||
|
||||
// Create the handler
|
||||
this.kCoreHandler = new HandlerKnowledgeCore( this.internalInventory.getStackInSlot( KCORE_SLOT_INDEX ) );
|
||||
|
||||
// Update the pattern slots
|
||||
this.updatePatternSlots();
|
||||
|
||||
// Update the network
|
||||
this.stalePatterns = true;
|
||||
}
|
||||
catch( GridException e )
|
||||
else if( this.currentPattern != null )
|
||||
{
|
||||
// Figure out the root cause of this when it happens
|
||||
// Unable to reproduce so far.
|
||||
this.isActive = false;
|
||||
// Clear the pattern
|
||||
this.isCrafting = false;
|
||||
this.currentPattern = null;
|
||||
}
|
||||
|
||||
// Setup the assembler
|
||||
this.setupAssemblerTile();
|
||||
|
||||
// Recalculate the vis discounts
|
||||
this.calculateVisDiscounts();
|
||||
|
||||
// Set ready
|
||||
this.isReady = true;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
@@ -1033,53 +986,6 @@ public class TileArcaneAssembler
|
||||
return true;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void onSaveNBT( final NBTTagCompound data )
|
||||
{
|
||||
// Get the kcore
|
||||
ItemStack kCore = this.internalInventory.slots[TileArcaneAssembler.KCORE_SLOT_INDEX];
|
||||
if( kCore != null )
|
||||
{
|
||||
// Write the kcore
|
||||
data.setTag( TileArcaneAssembler.NBTKEY_KCORE, kCore.writeToNBT( new NBTTagCompound() ) );
|
||||
}
|
||||
|
||||
// Write the vis interface
|
||||
this.visSourceInfo.writeToNBT( data, TileArcaneAssembler.NBTKEY_VIS_INTERFACE );
|
||||
|
||||
// Write the stored vis
|
||||
this.storedVis.writeToNBT( data, TileArcaneAssembler.NBTKEY_STORED_VIS );
|
||||
|
||||
// Write the number of upgrades
|
||||
data.setInteger( TileArcaneAssembler.NBTKEY_UPGRADES, this.upgradeCount );
|
||||
|
||||
// Write the upgrade inventory
|
||||
this.upgradeInventory.writeToNBT( data, TileArcaneAssembler.NBTKEY_UPGRADEINV );
|
||||
|
||||
// Write the crafting state
|
||||
data.setBoolean( TileArcaneAssembler.NBTKEY_CRAFTING, this.isCrafting );
|
||||
|
||||
// Write the current pattern
|
||||
if( this.currentPattern != null )
|
||||
{
|
||||
data.setTag( TileArcaneAssembler.NBTKEY_CRAFTING_PATTERN, this.currentPattern.writeToNBT( new NBTTagCompound() ) );
|
||||
}
|
||||
|
||||
// Write the discount armors
|
||||
for( int index = 0; index < 4; index++ )
|
||||
{
|
||||
// Get the armor
|
||||
ItemStack armor = this.internalInventory.slots[TileArcaneAssembler.DISCOUNT_ARMOR_INDEX + index];
|
||||
|
||||
if( armor != null )
|
||||
{
|
||||
// Write the armor
|
||||
data.setTag( TileArcaneAssembler.NBTKEY_DISCOUNT_ARMOR + index, armor.writeToNBT( new NBTTagCompound() ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void onSendNetworkData( final ByteBuf stream ) throws IOException
|
||||
{
|
||||
@@ -1226,7 +1132,7 @@ public class TileArcaneAssembler
|
||||
this.currentPattern = (ArcaneCraftingPattern)patternDetails;
|
||||
|
||||
// Set the target item
|
||||
this.internalInventory.slots[TileArcaneAssembler.TARGET_SLOT_INDEX] = this.currentPattern.getResult().getItemStack();
|
||||
this.internalInventory.setInventorySlotContents( TARGET_SLOT_INDEX, this.currentPattern.getResult().getItemStack() );
|
||||
|
||||
// AE effects
|
||||
try
|
||||
@@ -1246,6 +1152,54 @@ public class TileArcaneAssembler
|
||||
return false;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_ArcaneAssembler( final NBTTagCompound data )
|
||||
{
|
||||
// Is there relay info?
|
||||
if( data.hasKey( TileArcaneAssembler.NBTKEY_VIS_INTERFACE ) )
|
||||
{
|
||||
this.visSourceInfo.readFromNBT( data, TileArcaneAssembler.NBTKEY_VIS_INTERFACE );
|
||||
}
|
||||
|
||||
// Read vis levels
|
||||
this.readVisLevelsFromNBT( data );
|
||||
|
||||
// Read upgrade count
|
||||
if( data.hasKey( TileArcaneAssembler.NBTKEY_UPGRADES ) )
|
||||
{
|
||||
this.upgradeCount = data.getInteger( TileArcaneAssembler.NBTKEY_UPGRADES );
|
||||
}
|
||||
|
||||
// Read upgrade inventory
|
||||
this.upgradeInventory.readFromNBT( data, TileArcaneAssembler.NBTKEY_UPGRADEINV );
|
||||
|
||||
// Read the crafting status
|
||||
if( data.hasKey( TileArcaneAssembler.NBTKEY_CRAFTING ) )
|
||||
{
|
||||
this.isCrafting = data.getBoolean( TileArcaneAssembler.NBTKEY_CRAFTING );
|
||||
}
|
||||
|
||||
// Read the pattern
|
||||
if( data.hasKey( TileArcaneAssembler.NBTKEY_CRAFTING_PATTERN ) )
|
||||
{
|
||||
this.currentPattern = new ArcaneCraftingPattern( null, data.getCompoundTag( TileArcaneAssembler.NBTKEY_CRAFTING_PATTERN ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the stored vis levels.
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void readVisLevelsFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
if( data.hasKey( TileArcaneAssembler.NBTKEY_STORED_VIS ) )
|
||||
{
|
||||
this.storedVis.readFromNBT( data, TileArcaneAssembler.NBTKEY_STORED_VIS );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the owner of this tile.
|
||||
*
|
||||
@@ -1256,22 +1210,43 @@ public class TileArcaneAssembler
|
||||
this.getProxy().setOwner( player );
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the Assembler.
|
||||
*/
|
||||
public TileArcaneAssembler setupAssemblerTile()
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_ArcaneAssembler( final NBTTagCompound data )
|
||||
{
|
||||
// Ignored on client side
|
||||
if( FMLCommonHandler.instance().getEffectiveSide().isServer() )
|
||||
{
|
||||
// Set idle power usage
|
||||
this.getProxy().setIdlePowerUsage( TileArcaneAssembler.IDLE_POWER );
|
||||
// Write the vis interface
|
||||
this.visSourceInfo.writeToNBT( data, TileArcaneAssembler.NBTKEY_VIS_INTERFACE );
|
||||
|
||||
// Set that we require a channel
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
// Write the stored vis
|
||||
this.writeVisLevelsToNBT( data );
|
||||
|
||||
// Write the number of upgrades
|
||||
data.setInteger( TileArcaneAssembler.NBTKEY_UPGRADES, this.upgradeCount );
|
||||
|
||||
// Write the upgrade inventory
|
||||
this.upgradeInventory.writeToNBT( data, TileArcaneAssembler.NBTKEY_UPGRADEINV );
|
||||
|
||||
// Write the crafting state
|
||||
data.setBoolean( TileArcaneAssembler.NBTKEY_CRAFTING, this.isCrafting );
|
||||
|
||||
// Write the current pattern
|
||||
if( this.currentPattern != null )
|
||||
{
|
||||
data.setTag( TileArcaneAssembler.NBTKEY_CRAFTING_PATTERN, this.currentPattern.writeToNBT( new NBTTagCompound() ) );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the stored vis levels.
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void writeVisLevelsToNBT( final NBTTagCompound data )
|
||||
{
|
||||
if( this.storedVis.size() > 0 )
|
||||
{
|
||||
this.storedVis.writeToNBT( data, TileArcaneAssembler.NBTKEY_STORED_VIS );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +1,14 @@
|
||||
package thaumicenergistics.common.tiles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import thaumicenergistics.api.storage.IInventoryUpdateReceiver;
|
||||
import thaumicenergistics.common.inventory.PrivateInventory;
|
||||
import thaumicenergistics.common.items.ItemCraftingAspect;
|
||||
import thaumicenergistics.common.tiles.abstraction.ThETileInventory;
|
||||
import appeng.api.AEApi;
|
||||
|
||||
public class TileDistillationEncoder
|
||||
extends TileEntity
|
||||
implements IInventoryUpdateReceiver
|
||||
extends ThETileInventory
|
||||
{
|
||||
/**
|
||||
* NBT Keys
|
||||
@@ -36,47 +32,12 @@ public class TileDistillationEncoder
|
||||
SLOT_SOURCE_ASPECTS = 3,
|
||||
SLOT_SELECTED_ASPECT = SLOT_SOURCE_ASPECTS + SLOT_SOURCE_ASPECTS_COUNT;
|
||||
|
||||
/**
|
||||
* Stores the inventory for this tile.
|
||||
*/
|
||||
private PrivateInventory internalInventory = new PrivateInventory( "distillation.inscriber", SLOT_TOTAL_COUNT, 64, this )
|
||||
{
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int slotId, final ItemStack itemStack )
|
||||
{
|
||||
// Can always clear a slot
|
||||
if( itemStack == null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Empty pattern slot?
|
||||
if( slotId == SLOT_BLANK_PATTERNS )
|
||||
{
|
||||
return AEApi.instance().definitions().materials().blankPattern().isSameAs( itemStack );
|
||||
}
|
||||
|
||||
// Encoded pattern slot?
|
||||
if( slotId == SLOT_ENCODED_PATTERN )
|
||||
{
|
||||
return AEApi.instance().definitions().items().encodedPattern().isSameAs( itemStack );
|
||||
}
|
||||
|
||||
// Aspect slot?
|
||||
if( ( slotId >= SLOT_SOURCE_ASPECTS ) && ( slotId <= SLOT_SELECTED_ASPECT ) )
|
||||
{
|
||||
return( itemStack.getItem() instanceof ItemCraftingAspect );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public TileDistillationEncoder()
|
||||
{
|
||||
super( "distillation.inscriber", SLOT_TOTAL_COUNT, 64 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,30 +48,20 @@ public class TileDistillationEncoder
|
||||
public ArrayList<ItemStack> getDrops( final ArrayList<ItemStack> drops )
|
||||
{
|
||||
// Add encoded
|
||||
if( ( this.internalInventory.slots[SLOT_ENCODED_PATTERN] != null ) )
|
||||
if( this.internalInventory.getHasStack( SLOT_ENCODED_PATTERN ) )
|
||||
{
|
||||
drops.add( this.internalInventory.slots[SLOT_ENCODED_PATTERN] );
|
||||
drops.add( this.internalInventory.getStackInSlot( SLOT_ENCODED_PATTERN ) );
|
||||
}
|
||||
|
||||
// Add blank
|
||||
if( ( this.internalInventory.slots[SLOT_BLANK_PATTERNS] != null ) )
|
||||
if( this.internalInventory.getHasStack( SLOT_BLANK_PATTERNS ) )
|
||||
{
|
||||
drops.add( this.internalInventory.slots[SLOT_BLANK_PATTERNS] );
|
||||
drops.add( this.internalInventory.getStackInSlot( SLOT_BLANK_PATTERNS ) );
|
||||
}
|
||||
|
||||
return drops;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the inscriber's inventory.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IInventory getInventory()
|
||||
{
|
||||
return this.internalInventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if there is a pattern to encode onto.
|
||||
*
|
||||
@@ -119,19 +70,39 @@ public class TileDistillationEncoder
|
||||
public boolean hasPatterns()
|
||||
{
|
||||
// Is there anything in the pattern slots?
|
||||
return( ( this.internalInventory.slots[SLOT_ENCODED_PATTERN] != null )
|
||||
|| ( this.internalInventory.slots[SLOT_BLANK_PATTERNS] != null ) );
|
||||
return this.internalInventory.getHasStack( SLOT_ENCODED_PATTERN )
|
||||
|| this.internalInventory.getHasStack( SLOT_BLANK_PATTERNS );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the internal inventory changes
|
||||
*/
|
||||
@Override
|
||||
public void onInventoryChanged( final IInventory sourceInventory )
|
||||
public boolean isItemValidForSlot( final int slotId, final ItemStack itemStack )
|
||||
{
|
||||
// Mark the tile dirty
|
||||
this.markDirty();
|
||||
// Can always clear a slot
|
||||
if( itemStack == null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Empty pattern slot?
|
||||
if( slotId == SLOT_BLANK_PATTERNS )
|
||||
{
|
||||
return AEApi.instance().definitions().materials().blankPattern().isSameAs( itemStack );
|
||||
}
|
||||
|
||||
// Encoded pattern slot?
|
||||
if( slotId == SLOT_ENCODED_PATTERN )
|
||||
{
|
||||
return AEApi.instance().definitions().items().encodedPattern().isSameAs( itemStack );
|
||||
}
|
||||
|
||||
// Aspect slot?
|
||||
if( ( slotId >= SLOT_SOURCE_ASPECTS ) && ( slotId <= SLOT_SELECTED_ASPECT ) )
|
||||
{
|
||||
return( itemStack.getItem() instanceof ItemCraftingAspect );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package thaumicenergistics.common.tiles;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import thaumicenergistics.common.inventory.HandlerKnowledgeCore;
|
||||
import thaumicenergistics.common.inventory.PrivateInventory;
|
||||
import thaumicenergistics.common.items.ItemKnowledgeCore;
|
||||
import thaumicenergistics.common.tiles.abstraction.ThETileInventory;
|
||||
|
||||
public class TileKnowledgeInscriber
|
||||
extends TileEntity
|
||||
extends ThETileInventory
|
||||
{
|
||||
public static final int KCORE_SLOT = 0;
|
||||
public static final int PATTERN_SLOT = KCORE_SLOT + 1;
|
||||
@@ -18,37 +16,9 @@ public class TileKnowledgeInscriber
|
||||
|
||||
private static final String NBTKEY_KCORE = "kcore";
|
||||
|
||||
private PrivateInventory internalInventory = new PrivateInventory( "knowledge.inscriber", 32, 64 )
|
||||
{
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int slotId, final ItemStack itemStack )
|
||||
{
|
||||
if( itemStack == null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( slotId == TileKnowledgeInscriber.KCORE_SLOT )
|
||||
{
|
||||
return( itemStack.getItem() instanceof ItemKnowledgeCore );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
public TileKnowledgeInscriber()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the inscriber's inventory.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public IInventory getInventory()
|
||||
{
|
||||
return this.internalInventory;
|
||||
super( "knowledge.inscriber", 32, 64 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +28,26 @@ public class TileKnowledgeInscriber
|
||||
*/
|
||||
public boolean hasKCore()
|
||||
{
|
||||
return( this.internalInventory.slots[TileKnowledgeInscriber.KCORE_SLOT] != null );
|
||||
return this.internalInventory.getHasStack( KCORE_SLOT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int slotIndex, final ItemStack itemStack )
|
||||
{
|
||||
// Null is always allowed
|
||||
if( itemStack == null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// KCORE slot?
|
||||
if( slotIndex == KCORE_SLOT )
|
||||
{
|
||||
// Ensure the item is a KCORE
|
||||
return( itemStack.getItem() instanceof ItemKnowledgeCore );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,11 +57,11 @@ public class TileKnowledgeInscriber
|
||||
super.readFromNBT( data );
|
||||
|
||||
// Is there a saved core?
|
||||
if( data.hasKey( TileKnowledgeInscriber.NBTKEY_KCORE ) )
|
||||
if( data.hasKey( NBTKEY_KCORE ) )
|
||||
{
|
||||
// Load the saved core
|
||||
this.internalInventory.slots[TileKnowledgeInscriber.KCORE_SLOT] = ItemStack.loadItemStackFromNBT( data
|
||||
.getCompoundTag( TileKnowledgeInscriber.NBTKEY_KCORE ) );
|
||||
this.internalInventory.setInventorySlotContents( KCORE_SLOT,
|
||||
ItemStack.loadItemStackFromNBT( data.getCompoundTag( NBTKEY_KCORE ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,11 +72,11 @@ public class TileKnowledgeInscriber
|
||||
super.writeToNBT( data );
|
||||
|
||||
// Get the kcore
|
||||
ItemStack kCore = this.internalInventory.slots[TileKnowledgeInscriber.KCORE_SLOT];
|
||||
ItemStack kCore = this.internalInventory.getStackInSlot( KCORE_SLOT );
|
||||
if( kCore != null )
|
||||
{
|
||||
// Write the kcore
|
||||
data.setTag( TileKnowledgeInscriber.NBTKEY_KCORE, kCore.writeToNBT( new NBTTagCompound() ) );
|
||||
data.setTag( NBTKEY_KCORE, kCore.writeToNBT( new NBTTagCompound() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package thaumicenergistics.common.tiles.abstraction;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import thaumicenergistics.common.inventory.TheInternalInventory;
|
||||
|
||||
/**
|
||||
* Base for tiles with inventories.
|
||||
* Note: The inventory is not automatically saved to NBT.
|
||||
* TODO: Mark dirty stuff
|
||||
*
|
||||
* @author Nividica
|
||||
*
|
||||
*/
|
||||
public abstract class ThETileInventory
|
||||
extends TileEntity
|
||||
implements IInventory
|
||||
{
|
||||
/**
|
||||
* The internal inventory of the tile.
|
||||
*/
|
||||
protected final TheInternalInventory internalInventory;
|
||||
|
||||
public ThETileInventory( final String invName, final int invSize, final int invStackLimit )
|
||||
{
|
||||
// Create the internal inventory
|
||||
this.internalInventory = new TheInternalInventory( invName, invSize, invStackLimit );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int slotIndex, final int amount )
|
||||
{
|
||||
return this.internalInventory.decrStackSize( slotIndex, amount );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
return this.internalInventory.getInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return this.internalInventory.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.internalInventory.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot( final int slotIndex )
|
||||
{
|
||||
return this.internalInventory.getStackInSlot( slotIndex );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing( final int slotIndex )
|
||||
{
|
||||
return this.internalInventory.getStackInSlotOnClosing( slotIndex );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return this.internalInventory.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer( final EntityPlayer player )
|
||||
{
|
||||
return this.internalInventory.isUseableByPlayer( player, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents( final int slotIndex, final ItemStack itemStack )
|
||||
{
|
||||
this.internalInventory.setInventorySlotContents( slotIndex, itemStack );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package thaumicenergistics.integration.tc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -100,7 +101,7 @@ public class ArcaneCraftingPattern
|
||||
* @param knowledgeCore
|
||||
* @param data
|
||||
*/
|
||||
public ArcaneCraftingPattern( final ItemStack knowledgeCore, final NBTTagCompound data )
|
||||
public ArcaneCraftingPattern( @Nullable final ItemStack knowledgeCore, final NBTTagCompound data )
|
||||
{
|
||||
// Set the host
|
||||
this.knowledgeCoreHost = knowledgeCore;
|
||||
@@ -579,6 +580,16 @@ public class ArcaneCraftingPattern
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the knowledge core.
|
||||
*
|
||||
* @param knowledgeCore
|
||||
*/
|
||||
public void setKnowledgeCore( final ItemStack knowledgeCore )
|
||||
{
|
||||
this.knowledgeCoreHost = knowledgeCore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority( final int priority )
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import thaumcraft.client.lib.ClientTickEventsFML;
|
||||
import thaumicenergistics.common.inventory.PrivateInventory;
|
||||
import thaumicenergistics.common.inventory.TheInternalInventory;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.eventhandler.EventBus;
|
||||
@@ -38,7 +38,7 @@ public class MEItemAspectBridgeContainer
|
||||
/**
|
||||
* Internal inventory that mirrors the ME items displayed by the A.C.T
|
||||
*/
|
||||
private PrivateInventory internalInventory;
|
||||
private TheInternalInventory internalInventory;
|
||||
|
||||
/**
|
||||
* Constructs a pseudo container that TC can use to 'see' the items in the
|
||||
@@ -52,7 +52,7 @@ public class MEItemAspectBridgeContainer
|
||||
public MEItemAspectBridgeContainer( final int inventorySize ) throws Exception
|
||||
{
|
||||
// Create the inventory
|
||||
this.internalInventory = new PrivateInventory( "TC Inventory Bridge", inventorySize, 1 );
|
||||
this.internalInventory = new TheInternalInventory( "TC Inventory Bridge", inventorySize, 1 );
|
||||
|
||||
// Have we hooked to TC's event handler?
|
||||
if( thaumcraftClientEvents.get() == null )
|
||||
|
||||
@@ -47,9 +47,9 @@ thaumicenergistics.item.focus.aewrench.name=Wand Focus: AE Wrench
|
||||
thaumicenergistics.item.focus.aewrench.disabled.name=Wand Focus: AE Wrench - Wrench Mode Disabled
|
||||
|
||||
#Tooltips
|
||||
thaumicenergistics.tooltip.itemstack.details=Hold §eshift§f for details.
|
||||
thaumicenergistics.tooltip.essentia.cell.bytes=%d of %d bytes used.
|
||||
thaumicenergistics.tooltip.essentia.cell.types=%d of %d essentia types stored.
|
||||
thaumicenergistics.tooltip.essentia.cell.details=Hold §eshift§f for details.
|
||||
thaumicenergistics.tooltip.button.clear.crafting=Deposit Crafting Grid
|
||||
thaumicenergistics.tooltip.button.void=Allow Void?
|
||||
thaumicenergistics.tooltip.button.void.disabled=Do not void essentia
|
||||
@@ -62,6 +62,7 @@ thaumicenergistics.tooltip.button.inscriber.save=Save Pattern To Knowledge Core
|
||||
thaumicenergistics.tooltip.button.inscriber.missing=Requires Knowledge Core
|
||||
thaumicenergistics.tooltip.button.swap.armor=Swaps your currently equipped armor with the armor stored in the terminal.
|
||||
thaumicenergistics.tooltip.button.swap.armor.title=Swap Armor
|
||||
thaumicenergistics.tooltip.arcane.assembler.hasVis=Contains Stored Vis
|
||||
|
||||
|
||||
#GUI
|
||||
|
||||
Reference in new issue
Block a user