diff --git a/ChangeLog.txt b/ChangeLog.txt
index 0683ec49..8991b122 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,4 +1,11 @@
-01/02/2016 0.10.0.0
+01/10/2016 0.10.0.0 - Beta
+ Fixed name collision with "isUseableByPlayer".
+ Fixed KnowledgeInscriber not being able to erase patterns.
+ Fixed bug where Terminals would not properly update during certain AE-network changes.
+ Fixed bug where craftable essentia was still present on the network when it should not be.
+ Added config option to force some thaumcraft blocks to be turned into facades.
+
+01/09/2016 0.10.0.0
Fixed crafting aspect item display name.
More Multiplayer gui sync fixes.
Slightly reduced size of all packets.
diff --git a/src/main/java/thaumicenergistics/api/IThEConfig.java b/src/main/java/thaumicenergistics/api/IThEConfig.java
index 83c75a1f..56098fcc 100644
--- a/src/main/java/thaumicenergistics/api/IThEConfig.java
+++ b/src/main/java/thaumicenergistics/api/IThEConfig.java
@@ -30,6 +30,14 @@ public interface IThEConfig
*/
public int conversionMultiplier();
+ /**
+ * When enabled, overwrites the AE2 facade setting for certain Thaumcraft blocks,
+ * allowing them to become facades.
+ *
+ * @return
+ */
+ public boolean forceTCFacades();
+
/**
* If true the iron and thaumium gearbox's will be rendered as a standard
* block.
diff --git a/src/main/java/thaumicenergistics/api/grid/IMEEssentiaMonitorReceiver.java b/src/main/java/thaumicenergistics/api/grid/IMEEssentiaMonitorReceiver.java
index 7da5fe76..dfb8328c 100644
--- a/src/main/java/thaumicenergistics/api/grid/IMEEssentiaMonitorReceiver.java
+++ b/src/main/java/thaumicenergistics/api/grid/IMEEssentiaMonitorReceiver.java
@@ -6,6 +6,8 @@ public interface IMEEssentiaMonitorReceiver
{
/**
* Verifies that the receiver is still valid.
+ * If returning false the receiver will be removed from the monitor
+ * and the receiver should NOT call removeListener itself.
*
* @param verificationToken
* @return False if the receiver should no longer get updates.
diff --git a/src/main/java/thaumicenergistics/client/gui/GuiEssentiaCellTerminal.java b/src/main/java/thaumicenergistics/client/gui/GuiEssentiaCellTerminal.java
index ef8e0540..2a78ec1d 100644
--- a/src/main/java/thaumicenergistics/client/gui/GuiEssentiaCellTerminal.java
+++ b/src/main/java/thaumicenergistics/client/gui/GuiEssentiaCellTerminal.java
@@ -840,11 +840,11 @@ public class GuiEssentiaCellTerminal
public void onReceiveAspectListChange( final IAspectStack change )
{
// Update the container
- if( this.baseContainer.onReceivedAspectListChange( change ) )
- {
- // Update the gui
- this.onListUpdate();
- }
+ this.baseContainer.onReceivedAspectListChange( change );
+
+ // Update the gui
+ this.onListUpdate();
+
}
/**
diff --git a/src/main/java/thaumicenergistics/common/ConfigurationHandler.java b/src/main/java/thaumicenergistics/common/ConfigurationHandler.java
index e2252c6a..be7a3f2c 100644
--- a/src/main/java/thaumicenergistics/common/ConfigurationHandler.java
+++ b/src/main/java/thaumicenergistics/common/ConfigurationHandler.java
@@ -22,7 +22,8 @@ class ConfigurationHandler
DEFAULT_INFUSIONPROVIDER = true,
DEFAULT_QUARTZ = true,
DEFAULT_GEARBOX_DISABLED = false,
- DEFAULT_EXTRACELLS_BLIST = true;
+ DEFAULT_EXTRACELLS_BLIST = true,
+ DEFAULT_FORCE_TC_FACADES = true;
/**
* Mod configuration
@@ -61,6 +62,11 @@ class ConfigurationHandler
*/
private boolean extracellsBlacklist = DEFAULT_EXTRACELLS_BLIST;
+ /**
+ * Allows specific blocks from Thaumcraft to be turned into facades.
+ */
+ private boolean forceTCFacades = DEFAULT_FORCE_TC_FACADES;
+
private ConfigurationHandler( final Configuration config )
{
this.configSettings = config;
@@ -101,24 +107,28 @@ class ConfigurationHandler
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,
- ConfigurationHandler.DEFAULT_ESSENTIAPROVIDER, "Controls if the Essentia Provider is allowed to be crafted." );
+ this.allowEssentiaProvider = this.configSettings.getBoolean( "Allow Crafting Essentia Provider", CATEGORY_CRAFTING,
+ DEFAULT_ESSENTIAPROVIDER, "Controls if the Essentia Provider is allowed to be crafted." );
// Sync essentia provider
- this.allowInfusionProvider = this.configSettings.getBoolean( "Allow Crafting Infusion Provider", ConfigurationHandler.CATEGORY_CRAFTING,
- ConfigurationHandler.DEFAULT_INFUSIONPROVIDER, "Controls if the Infusion Provider is allowed to be crafted." );
+ this.allowInfusionProvider = this.configSettings.getBoolean( "Allow Crafting Infusion Provider", CATEGORY_CRAFTING,
+ DEFAULT_INFUSIONPROVIDER, "Controls if the Infusion Provider is allowed to be crafted." );
// Sync certus dupe
- this.allowCertusDupe = this.configSettings.getBoolean( "Certus Quartz Duplication", ConfigurationHandler.CATEGORY_CRAFTING,
- ConfigurationHandler.DEFAULT_QUARTZ, "Controls if Certus Quartz can be duplicated in the crucible." );
+ this.allowCertusDupe = this.configSettings.getBoolean( "Certus Quartz Duplication", CATEGORY_CRAFTING,
+ DEFAULT_QUARTZ, "Controls if Certus Quartz can be duplicated in the crucible." );
// Gearbox model
- this.gearboxModelDisabled = this.configSettings.getBoolean( "Disable Gearbox Model", ConfigurationHandler.CATEGORY_CLIENT,
- ConfigurationHandler.DEFAULT_GEARBOX_DISABLED, "The iron and thaumium gearboxes will be rendered as a standard block." );
+ this.gearboxModelDisabled = this.configSettings.getBoolean( "Disable Gearbox Model", CATEGORY_CLIENT,
+ 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,
- ConfigurationHandler.DEFAULT_EXTRACELLS_BLIST, "Prevents extra cells from interacting with essentia gas" );
+ this.extracellsBlacklist = this.configSettings.getBoolean( "ExtraCells Blacklist", CATEGORY_INTEGRATION,
+ DEFAULT_EXTRACELLS_BLIST, "Prevents extra cells from interacting with essentia gas" );
+
+ // Thaumcraft facades
+ this.forceTCFacades = this.configSettings.getBoolean( "Force TC Facades", CATEGORY_CRAFTING, DEFAULT_FORCE_TC_FACADES,
+ "When enabled, overwrites the AE2 facade setting for certain Thaumcraft blocks, allowing them to become facades." );
// Has the config file changed?
if( this.configSettings.hasChanged() )
@@ -158,6 +168,12 @@ class ConfigurationHandler
return this.conversionMultiplier;
}
+ @Override
+ public boolean forceTCFacades()
+ {
+ return this.forceTCFacades;
+ }
+
@Override
public boolean gearboxModelDisabled()
{
diff --git a/src/main/java/thaumicenergistics/common/ThEGuiHandler.java b/src/main/java/thaumicenergistics/common/ThEGuiHandler.java
index b844005a..8696cb50 100644
--- a/src/main/java/thaumicenergistics/common/ThEGuiHandler.java
+++ b/src/main/java/thaumicenergistics/common/ThEGuiHandler.java
@@ -265,7 +265,7 @@ public class ThEGuiHandler
public static void launchGui( final ThEPartBase part, final EntityPlayer player, final World world, final int x, final int y, final int z )
{
// Ensure the player is allowed to open the gui
- if( part.isUseableByPlayer( player ) )
+ if( part.isPartUseableByPlayer( player ) )
{
player.openGui( ThaumicEnergistics.INSTANCE, part.getSide().ordinal(), world, x, y, z );
}
diff --git a/src/main/java/thaumicenergistics/common/container/ContainerEssentiaCell.java b/src/main/java/thaumicenergistics/common/container/ContainerEssentiaCell.java
index 0fc85eb0..e07e4f8d 100644
--- a/src/main/java/thaumicenergistics/common/container/ContainerEssentiaCell.java
+++ b/src/main/java/thaumicenergistics/common/container/ContainerEssentiaCell.java
@@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import thaumcraft.api.aspects.Aspect;
import thaumicenergistics.api.grid.ICraftingIssuerHost;
+import thaumicenergistics.api.grid.IMEEssentiaMonitor;
import thaumicenergistics.api.storage.IAspectStack;
import thaumicenergistics.common.ThaumicEnergistics;
import thaumicenergistics.common.grid.EssentiaMonitor;
@@ -22,6 +23,7 @@ import thaumicenergistics.integration.tc.EssentiaItemContainerHelper;
import thaumicenergistics.integration.tc.EssentiaItemContainerHelper.AspectItemType;
import appeng.api.config.Settings;
import appeng.api.config.ViewItems;
+import appeng.api.networking.IGrid;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.PlayerSource;
@@ -45,7 +47,7 @@ public class ContainerEssentiaCell
/**
* The ME chest the cell is stored in.
*/
- private TileChest hostChest;
+ private final TileChest hostChest;
/**
* Network source representing the player who is interacting with the
@@ -96,12 +98,12 @@ public class ContainerEssentiaCell
// Call the super-constructor
super( player );
+ // Get the tile entity for the chest
+ this.hostChest = (TileChest)world.getTileEntity( x, y, z );
+
// Is this server side?
if( EffectiveSide.isServerSide() )
{
- // Get the tile entity for the chest
- this.hostChest = (TileChest)world.getTileEntity( x, y, z );
-
/*
* Note: Casting the hostChest to an object is required to prevent the compiler
* from seeing the soft-dependencies of AE2, such a buildcraft, which it attempts
@@ -112,38 +114,11 @@ public class ContainerEssentiaCell
// Create the action source
this.playerSource = new PlayerSource( this.player, (IActionHost)hostObject );
-
- try
- {
- IMEInventoryHandler handler = null;
-
- // Get the chest handler
- List hostCellArray = this.hostChest.getCellArray( StorageChannel.FLUIDS );
- if( hostCellArray.size() > 0 )
- {
- handler = hostCellArray.get( 0 );
- }
-
- // Get the monitor
- if( handler != null )
- {
- // Create the essentia monitor
- this.monitor = new EssentiaMonitor( (IMEMonitor)handler, this.hostChest.getProxy().getEnergy(), this );
-
- // Attach to the monitor
- this.attachToMonitor();
- }
- }
- catch( Exception e )
- {
- e.printStackTrace();
- }
}
else
{
// Request a full update from the server
Packet_S_EssentiaCellTerminal.sendFullUpdateRequest( player );
- this.hasRequested = true;
}
// Bind our inventory
@@ -183,12 +158,54 @@ public class ContainerEssentiaCell
return this.playerSource;
}
+ @Override
+ protected IGrid getHostGrid()
+ {
+ try
+ {
+ return this.hostChest.getActionableNode().getGrid();
+ }
+ catch( Exception e )
+ {
+ return null;
+ }
+ }
+
@Override
protected Aspect getHostSelectedAspect()
{
return this.tmpSelectedAspect;
}
+ @Override
+ protected IMEEssentiaMonitor getNewMonitor()
+ {
+ try
+ {
+ IMEInventoryHandler handler = null;
+
+ // Get the chest handler
+ List hostCellArray = this.hostChest.getCellArray( StorageChannel.FLUIDS );
+ if( hostCellArray.size() > 0 )
+ {
+ handler = hostCellArray.get( 0 );
+ }
+
+ // Get the monitor
+ if( handler != null )
+ {
+ // Create the essentia monitor
+ return new EssentiaMonitor( (IMEMonitor)handler, this.hostChest.getProxy().getEnergy(), this );
+ }
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
@Override
protected void setHostSelectedAspect( final Aspect aspect )
{
@@ -246,7 +263,7 @@ public class ContainerEssentiaCell
}
// Send the list
- if( ( this.monitor != null ) && ( this.hostChest.isPowered() ) )
+ if( this.hostChest.isPowered() )
{
Packet_C_EssentiaCellTerminal.sendFullList( this.player, this.repo.getAll() );
}
@@ -303,22 +320,16 @@ public class ContainerEssentiaCell
@Override
public void onContainerClosed( final EntityPlayer player )
{
-
+ // Drop anything in the work slots.
if( EffectiveSide.isServerSide() )
{
- // Is there a monitor
- if( this.monitor != null )
- {
- // Ensure it gets detached.
- ( (EssentiaMonitor)this.monitor ).detach();
- }
-
for( int i = 0; i < 2; i++ )
{
this.player.dropPlayerItemWithRandomChoice( ( (Slot)this.inventorySlots.get( i ) ).getStack(), false );
}
}
+ // Call super
super.onContainerClosed( player );
}
}
diff --git a/src/main/java/thaumicenergistics/common/container/ContainerEssentiaCellTerminalBase.java b/src/main/java/thaumicenergistics/common/container/ContainerEssentiaCellTerminalBase.java
index 86d47786..c417429d 100644
--- a/src/main/java/thaumicenergistics/common/container/ContainerEssentiaCellTerminalBase.java
+++ b/src/main/java/thaumicenergistics/common/container/ContainerEssentiaCellTerminalBase.java
@@ -1,8 +1,6 @@
package thaumicenergistics.common.container;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
@@ -30,6 +28,7 @@ import thaumicenergistics.integration.tc.EssentiaItemContainerHelper;
import thaumicenergistics.integration.tc.EssentiaItemContainerHelper.AspectItemType;
import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
+import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.ISecurityGrid;
@@ -134,12 +133,6 @@ public abstract class ContainerEssentiaCellTerminalBase
*/
private Slot outputSlot;
- /**
- * Holds a list of changes sent to the gui before the
- * full list is sent.
- */
- private List pendingChanges = new ArrayList();
-
/**
* The aspect the user has selected.
*/
@@ -168,12 +161,7 @@ public abstract class ContainerEssentiaCellTerminalBase
/**
* Essentia network monitor
*/
- protected IMEEssentiaMonitor monitor;
-
- /**
- * Set to true once a full list request is sent to the server.
- */
- protected boolean hasRequested = false;
+ private IMEEssentiaMonitor essentiaMonitor;
/**
* Create the container and register the owner
@@ -189,15 +177,47 @@ public abstract class ContainerEssentiaCellTerminalBase
// Set the sound time
this.lastSoundPlaytime = System.currentTimeMillis();
}
- else
- {
- this.hasRequested = true;
- }
// Create the reop
this.repo = new EssentiaRepo();
}
+ /**
+ * Attach this container to the Essentia monitor
+ *
+ * @param essentiaMonitor
+ */
+ private boolean attachToMonitor( final IMEEssentiaMonitor eMonitor )
+ {
+ if( ( EffectiveSide.isServerSide() ) && ( eMonitor != null ) )
+ {
+ // Get the grid
+ IGrid grid = this.getHostGrid();
+ if( grid == null )
+ {
+ return false;
+ }
+
+ // Detach from any current monitor
+ if( this.essentiaMonitor != null )
+ {
+ this.detachFromMonitor();
+ }
+
+ // Set the monitor
+ this.essentiaMonitor = eMonitor;
+
+ // Listen
+ this.essentiaMonitor.addListener( this, grid.hashCode() );
+
+ // Update our cached list of aspects
+ this.repo.copyFrom( this.essentiaMonitor.getEssentiaList() );
+ return true;
+ }
+
+ return false;
+ }
+
/**
* Returns true if the specified stack can be merged into the output slot.
*
@@ -319,7 +339,7 @@ public abstract class ContainerEssentiaCellTerminalBase
int proposedDrainAmount = (int)containerEssentia.getStackSize();
// Do a network injection
- long rejectedAmount = this.monitor.injectEssentia( containerEssentia.getAspect(), proposedDrainAmount, mode, actionSource,
+ long rejectedAmount = this.essentiaMonitor.injectEssentia( containerEssentia.getAspect(), proposedDrainAmount, mode, actionSource,
true );
// Was any rejected?
@@ -376,7 +396,7 @@ public abstract class ContainerEssentiaCellTerminalBase
}
// Do an extraction from the network
- long extractedAmount = this.monitor.extractEssentia( withAspect, containerCapacity, mode, actionSource, true );
+ long extractedAmount = this.essentiaMonitor.extractEssentia( withAspect, containerCapacity, mode, actionSource, true );
// Was anything extracted?
if( extractedAmount <= 0 )
@@ -400,21 +420,6 @@ public abstract class ContainerEssentiaCellTerminalBase
new AspectStack( withAspect, proposedFillAmount ) );
}
- /**
- * Attach this container to the Essentia monitor
- */
- protected void attachToMonitor()
- {
- if( ( EffectiveSide.isServerSide() ) && ( this.monitor != null ) )
- {
- this.monitor.addListener( this, this.monitor.hashCode() );
-
- // Update our cached list of aspects
- this.repo.copyFrom( this.monitor.getEssentiaList() );
-
- }
- }
-
/**
* Binds the container to the specified inventory and the players inventory.
*
@@ -448,13 +453,13 @@ public abstract class ContainerEssentiaCellTerminalBase
{
if( EffectiveSide.isServerSide() )
{
- if( this.monitor != null )
+ if( this.essentiaMonitor != null )
{
// Stop listening
- this.monitor.removeListener( this );
+ this.essentiaMonitor.removeListener( this );
// Null the monitor
- this.monitor = null;
+ this.essentiaMonitor = null;
// Clear the repo
this.repo.clear();
@@ -474,6 +479,14 @@ public abstract class ContainerEssentiaCellTerminalBase
*/
protected abstract BaseActionSource getActionSource();
+ /**
+ * Gets the grid for the host.
+ *
+ * @return
+ */
+ @Nullable
+ protected abstract IGrid getHostGrid();
+
/**
* Return the selected aspect stored in the host.
*
@@ -482,6 +495,14 @@ public abstract class ContainerEssentiaCellTerminalBase
@Nullable
protected abstract Aspect getHostSelectedAspect();
+ /**
+ * Attempts to get a new essentia monitor.
+ *
+ * @return
+ */
+ @Nullable
+ protected abstract IMEEssentiaMonitor getNewMonitor();
+
/**
* Sets the hosts selected aspect.
*
@@ -503,7 +524,7 @@ public abstract class ContainerEssentiaCellTerminalBase
protected ItemStack transferEssentia( final ItemStack stack, final Aspect aspect, final BaseActionSource actionSource, final Actionable mode )
{
// Ensure the stack & monitor are not null
- if( ( stack == null ) || ( this.monitor == null ) )
+ if( ( stack == null ) || ( this.essentiaMonitor == null ) )
{
return stack;
}
@@ -666,16 +687,35 @@ public abstract class ContainerEssentiaCellTerminalBase
// Call super
super.detectAndSendChanges();
- // Inc tick tracker
- this.tickCounter += 1;
-
- if( this.tickCounter > ContainerEssentiaCellTerminalBase.WORK_TICK_RATE )
+ if( EffectiveSide.isClientSide() )
{
- // Do work
- this.doWork( this.tickCounter );
+ return;
+ }
+
+ // Is there a monitor?
+ if( this.essentiaMonitor != null )
+ {
+ // Inc tick tracker
+ this.tickCounter += 1;
+
+ if( this.tickCounter > ContainerEssentiaCellTerminalBase.WORK_TICK_RATE )
+ {
+ // Do work
+ this.doWork( this.tickCounter );
+
+ // Reset the tick counter
+ this.tickCounter = 0;
+ }
+ }
+ else
+ {
+ // Attempt to attach to a monitor
+ if( this.attachToMonitor( this.getNewMonitor() ) )
+ {
+ // Send update
+ this.onClientRequestFullUpdate();
+ }
- // Reset the tick counter
- this.tickCounter = 0;
}
// Compare selected aspects
@@ -727,23 +767,26 @@ public abstract class ContainerEssentiaCellTerminalBase
* from the AE monitor?
*/
@Override
- public boolean isValid( final Object verificationToken )
+ public final boolean isValid( final Object verificationToken )
{
- if( this.monitor == null )
+ // Get the grid
+ IGrid grid = this.getHostGrid();
+ if( grid != null )
{
- return false;
+ // Do the hash codes match?
+ if( grid.hashCode() == (Integer)verificationToken )
+ {
+ return true;
+ }
}
- // Do the hash codes match?
- if( this.monitor.hashCode() == (Integer)verificationToken )
- {
- return true;
- }
-
- // No longer valid
- this.monitor = null;
+ // No longer valid (Do not call detach, this will happen automatically)
+ this.essentiaMonitor = null;
this.repo.clear();
+ // Update the client
+ this.onClientRequestFullUpdate();
+
return false;
}
@@ -781,8 +824,10 @@ public abstract class ContainerEssentiaCellTerminalBase
@Override
public void onContainerClosed( final EntityPlayer player )
{
+ // Call super
super.onContainerClosed( player );
+ // Detach from the monitor
this.detachFromMonitor();
}
@@ -865,60 +910,29 @@ public abstract class ContainerEssentiaCellTerminalBase
{
// Set the aspect list
this.repo.copyFrom( aspectStackList );
-
- // Check pending changes
- if( ( aspectStackList != null ) && ( !this.pendingChanges.isEmpty() ) )
- {
- // Update list with pending changes
- for( int index = 0; index < this.pendingChanges.size(); index++ )
- {
- this.onReceivedAspectListChange( this.pendingChanges.get( index ) );
- }
-
- // Clear pending
- this.pendingChanges.clear();
- }
}
/**
* Called by the gui when a change arrives.
*
* @param change
- * @return True if the repo is prepared to be displayed.
*/
- public boolean onReceivedAspectListChange( final IAspectStack change )
+ public void onReceivedAspectListChange( final IAspectStack change )
{
// Ignored server side
if( EffectiveSide.isServerSide() )
{
- return false;
+ return;
}
// Ensure the change is not null
if( change == null )
{
- return false;
- }
-
- // Have we requested the full list yet?
- if( !this.hasRequested )
- {
- return false;
- }
-
- // Has the full list been received?
- if( this.repo.isEmpty() )
- {
- // Not yet received full list, add to pending
- this.pendingChanges.add( change );
- return false;
+ return;
}
// Post the change
this.repo.postChange( change );
-
- // The GUI can update if there are no pending changes
- return this.pendingChanges.isEmpty();
}
/**
diff --git a/src/main/java/thaumicenergistics/common/container/ContainerEssentiaTerminal.java b/src/main/java/thaumicenergistics/common/container/ContainerEssentiaTerminal.java
index affdaa25..0f820e7d 100644
--- a/src/main/java/thaumicenergistics/common/container/ContainerEssentiaTerminal.java
+++ b/src/main/java/thaumicenergistics/common/container/ContainerEssentiaTerminal.java
@@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import thaumcraft.api.aspects.Aspect;
import thaumicenergistics.api.grid.ICraftingIssuerHost;
+import thaumicenergistics.api.grid.IMEEssentiaMonitor;
import thaumicenergistics.common.ThEGuiHandler;
import thaumicenergistics.common.items.ItemCraftingAspect;
import thaumicenergistics.common.network.packet.client.Packet_C_EssentiaCellTerminal;
@@ -14,6 +15,7 @@ import thaumicenergistics.common.storage.AspectStackComparator.AspectStackCompar
import thaumicenergistics.common.utils.EffectiveSide;
import appeng.api.AEApi;
import appeng.api.config.ViewItems;
+import appeng.api.networking.IGrid;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.PlayerSource;
import appeng.api.storage.data.IAEItemStack;
@@ -32,13 +34,14 @@ public class ContainerEssentiaTerminal
/**
* The terminal this is associated with.
*/
- private PartEssentiaTerminal terminal = null;
+ @Nonnull
+ private final PartEssentiaTerminal terminal;
/**
* Network source representing the player who is interacting with the
* container.
*/
- private PlayerSource playerSource = null;
+ private final PlayerSource playerSource;
/**
* Creates the container
@@ -62,12 +65,6 @@ public class ContainerEssentiaTerminal
// Is this server side?
if( EffectiveSide.isServerSide() )
{
- // Get the monitor
- this.monitor = terminal.getGridBlock().getEssentiaMonitor();
-
- // Attach to the monitor
- this.attachToMonitor();
-
// Add this container to the terminal's list
terminal.addListener( this );
}
@@ -75,7 +72,6 @@ public class ContainerEssentiaTerminal
{
// Ask for a list update
Packet_S_EssentiaCellTerminal.sendFullUpdateRequest( this.player );
- this.hasRequested = true;
}
// Bind our inventory
@@ -88,12 +84,31 @@ public class ContainerEssentiaTerminal
return this.playerSource;
}
+ @Override
+ protected IGrid getHostGrid()
+ {
+ try
+ {
+ return this.terminal.getGridBlock().getGrid();
+ }
+ catch( Exception e )
+ {
+ return null;
+ }
+ }
+
@Override
protected Aspect getHostSelectedAspect()
{
return this.terminal.selectedAspect;
}
+ @Override
+ protected IMEEssentiaMonitor getNewMonitor()
+ {
+ return this.terminal.getGridBlock().getEssentiaMonitor();
+ }
+
@Override
protected void setHostSelectedAspect( final Aspect aspect )
{
@@ -103,7 +118,7 @@ public class ContainerEssentiaTerminal
@Override
public boolean canInteractWith( final EntityPlayer player )
{
- return this.terminal.isUseableByPlayer( player );
+ return this.terminal.isPartUseableByPlayer( player );
}
/**
@@ -168,10 +183,7 @@ public class ContainerEssentiaTerminal
this.onModeChanged( this.terminal.getSortingMode(), this.terminal.getViewMode() );
// Send the aspect list
- if( this.monitor != null )
- {
- Packet_C_EssentiaCellTerminal.sendFullList( this.player, this.repo.getAll() );
- }
+ Packet_C_EssentiaCellTerminal.sendFullList( this.player, this.repo.getAll() );
}
@Override
diff --git a/src/main/java/thaumicenergistics/common/container/ContainerKnowledgeInscriber.java b/src/main/java/thaumicenergistics/common/container/ContainerKnowledgeInscriber.java
index 0d928b64..c71c8645 100644
--- a/src/main/java/thaumicenergistics/common/container/ContainerKnowledgeInscriber.java
+++ b/src/main/java/thaumicenergistics/common/container/ContainerKnowledgeInscriber.java
@@ -3,6 +3,7 @@ package thaumicenergistics.common.container;
import java.util.ArrayList;
import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
@@ -72,24 +73,24 @@ public class ContainerKnowledgeInscriber
CRAFTING_SLOT_Y = 90, CRAFTING_ROWS = 3, CRAFTING_COLS = 3,
CRAFTING_SLOT_SPACING = 18, CRAFTING_RESULT_SLOT = CRAFTING_MATRIX_SLOT + ( CRAFTING_ROWS * CRAFTING_COLS );
+ /**
+ * Handles interaction with the knowledge core.
+ */
+ private final HandlerKnowledgeCore kCoreHandler;
+
/**
* Slots
*/
- private SlotRestrictive kCoreSlot;
+ private final SlotRestrictive kCoreSlot;
+ private final SlotFake resultSlot;
private SlotInaccessible[] patternSlots = new SlotInaccessible[MAXIMUM_PATTERNS];
private SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[CRAFTING_ROWS * CRAFTING_COLS];
- private SlotFake resultSlot;
/**
* Slot index ranges.
*/
private int patternSlot_first, patternSlot_last, craftingSlot_first, craftingSlot_last;
- /**
- * Handles interaction with the knowledge core.
- */
- private HandlerKnowledgeCore kCoreHandler;
-
/**
* Player using the inscriber
*/
@@ -100,11 +101,6 @@ public class ContainerKnowledgeInscriber
*/
private IArcaneRecipe activeRecipe = null;
- /**
- * Tracks changes to the core slot.
- */
- private boolean hadCoreLastCheck = false;
-
/**
* Inscriber tile entity.
*/
@@ -145,26 +141,8 @@ public class ContainerKnowledgeInscriber
this.resultSlot = new SlotFake( this.internalInventory, CRAFTING_RESULT_SLOT, 116, 108 );
this.addSlotToContainer( this.resultSlot );
- // Perform server side only setup
- if( EffectiveSide.isServerSide() )
- {
- // Check for a kcore
- if( this.kCoreSlot.getHasStack() )
- {
- // Mark the presence of the core
- this.hadCoreLastCheck = true;
-
- // Create the handler
- this.kCoreHandler = new HandlerKnowledgeCore( this.kCoreSlot.getStack() );
- }
-
- // Update the patterns
- this.updatePatternSlots();
-
- // Update the result
- this.onCraftMatrixChanged( this.internalInventory );
- }
-
+ // Create the handler
+ this.kCoreHandler = new HandlerKnowledgeCore();
}
/**
@@ -177,7 +155,7 @@ public class ContainerKnowledgeInscriber
CoreSaveState saveState;
// Is there a core handler?
- if( this.kCoreHandler == null )
+ if( !this.kCoreHandler.hasCore() )
{
saveState = CoreSaveState.Disabled_MissingCore;
}
@@ -349,7 +327,7 @@ public class ContainerKnowledgeInscriber
Iterator iterator = null;
// Get the list of stored pattern results
- if( this.kCoreHandler != null )
+ if( this.kCoreHandler.hasCore() )
{
ArrayList storedResults = this.kCoreHandler.getStoredOutputs();
iterator = storedResults.iterator();
@@ -400,45 +378,34 @@ public class ContainerKnowledgeInscriber
@Override
public void detectAndSendChanges()
{
+ if( this.player instanceof EntityPlayerMP )
+ {
+ // Has a core changed?
+ if( !this.kCoreHandler.isHandlingCore( this.kCoreSlot.getStack() ) )
+ {
+ if( this.kCoreSlot.getHasStack() )
+ {
+ // Setup the handler
+ this.kCoreHandler.open( this.kCoreSlot.getStack() );
+ }
+ else
+ {
+ // Close the handler
+ this.kCoreHandler.close();
+ }
+
+ // Update the slots
+ this.updatePatternSlots();
+ ( (EntityPlayerMP)this.player ).isChangingQuantityOnly = false;
+
+ // Update the save state
+ this.sendSaveState( false );
+ }
+ }
+
// Call super
super.detectAndSendChanges();
- // Ignore the rest of client side
- if( EffectiveSide.isClientSide() )
- {
- return;
- }
-
- // Check for a kcore
- boolean hasCore = this.kCoreSlot.getHasStack();
-
- // Has a core been placed or removed?
- if( hasCore != this.hadCoreLastCheck )
- {
- if( hasCore )
- {
- // Get the handler
- this.kCoreHandler = new HandlerKnowledgeCore( this.kCoreSlot.getStack() );
- }
- else
- {
- // Remove the handler
- this.kCoreHandler = null;
- }
-
- // Update the slots
- this.updatePatternSlots();
-
- // Update the save state
- this.sendSaveState( false );
-
- // Mark the inscriber as dirty
- this.inscriber.markDirty();
- }
-
- // Mark the cores presence
- this.hadCoreLastCheck = hasCore;
-
}
public void onClientRequestClearGrid()
@@ -601,58 +568,54 @@ public class ContainerKnowledgeInscriber
@Override
public ItemStack slotClick( final int slotID, final int buttonPressed, final int flag, final EntityPlayer player )
{
- if( EffectiveSide.isServerSide() )
+ if( EffectiveSide.isClientSide() )
{
- try
+ return null;
+ }
+
+ // Get the clicked slot
+ Slot clickedSlot = this.getSlot( slotID );
+
+ // Get the itemstack the player is holding with the mouse
+ ItemStack draggingStack = player.inventory.getItemStack();
+
+ // Was the clicked slot a crafting slot?
+ if( ( clickedSlot.slotNumber >= this.craftingSlot_first ) && ( clickedSlot.slotNumber <= this.craftingSlot_last ) )
+ {
+ // Is the player holding anything?
+ if( draggingStack != null )
{
- // Get the clicked slot
- Slot clickedSlot = this.getSlot( slotID );
+ ItemStack copiedStack = draggingStack.copy();
+ copiedStack.stackSize = 1;
- // Get the itemstack the player is holding with the mouse
- ItemStack draggingStack = player.inventory.getItemStack();
-
- // Was the clicked slot a crafting slot?
- if( ( clickedSlot.slotNumber >= this.craftingSlot_first ) && ( clickedSlot.slotNumber <= this.craftingSlot_last ) )
- {
- // Is the player holding anything?
- if( draggingStack != null )
- {
- ItemStack copiedStack = draggingStack.copy();
- copiedStack.stackSize = 1;
-
- // Place a copy of the stack into the clicked slot
- clickedSlot.putStack( copiedStack );
- }
- else
- {
- // Clear the slot
- clickedSlot.putStack( null );
- }
-
- // Update the matrix
- this.onCraftMatrixChanged( clickedSlot.inventory );
-
- return draggingStack;
- }
- // Was the clicked slot a pattern slot?
- else if( ( clickedSlot.slotNumber >= this.patternSlot_first ) && ( clickedSlot.slotNumber <= this.patternSlot_last ) )
- {
- // Does the slot correspond to a stored pattern?
- if( clickedSlot.getHasStack() )
- {
- // Load the pattern
- this.loadPattern( this.kCoreHandler.getPatternForItem( clickedSlot.getStack() ) );
-
- // Update the matrix
- this.onCraftMatrixChanged( clickedSlot.inventory );
- }
-
- return draggingStack;
- }
+ // Place a copy of the stack into the clicked slot
+ clickedSlot.putStack( copiedStack );
}
- catch( Exception e )
+ else
{
+ // Clear the slot
+ clickedSlot.putStack( null );
}
+
+ // Update the matrix
+ this.onCraftMatrixChanged( clickedSlot.inventory );
+
+ return draggingStack;
+ }
+ // Was the clicked slot a pattern slot?
+ else if( ( clickedSlot.slotNumber >= this.patternSlot_first ) && ( clickedSlot.slotNumber <= this.patternSlot_last ) )
+ {
+ // Does the slot correspond to a stored pattern?
+ if( clickedSlot.getHasStack() )
+ {
+ // Load the pattern
+ this.loadPattern( this.kCoreHandler.getPatternForItem( clickedSlot.getStack() ) );
+
+ // Update the matrix
+ this.onCraftMatrixChanged( clickedSlot.inventory );
+ }
+
+ return draggingStack;
}
// Pass to super
diff --git a/src/main/java/thaumicenergistics/common/container/ContainerPartArcaneCraftingTerminal.java b/src/main/java/thaumicenergistics/common/container/ContainerPartArcaneCraftingTerminal.java
index c02163f9..e9447e3c 100644
--- a/src/main/java/thaumicenergistics/common/container/ContainerPartArcaneCraftingTerminal.java
+++ b/src/main/java/thaumicenergistics/common/container/ContainerPartArcaneCraftingTerminal.java
@@ -35,6 +35,7 @@ import appeng.api.config.Actionable;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
+import appeng.api.networking.IGrid;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.PlayerSource;
import appeng.api.networking.storage.IBaseMonitor;
@@ -140,17 +141,17 @@ public class ContainerPartArcaneCraftingTerminal
*/
private final EntityPlayer player;
- /**
- * The AE network item monitor we are attached to.
- */
- private final IMEMonitor monitor;
-
/**
* Network source representing the player who is interacting with the
* container.
*/
private final PlayerSource playerSource;
+ /**
+ * The AE network item monitor we are attached to.
+ */
+ private IMEMonitor monitor;
+
/**
* Slot number of the first and last crafting slots.
*/
@@ -328,26 +329,51 @@ public class ContainerPartArcaneCraftingTerminal
}
- // Is this server side?
if( EffectiveSide.isServerSide() )
{
- // Register with part
+ // Register with terminal
this.registerForUpdates();
+ }
+ // Attach to the monitor
+ this.attachToMonitor();
+
+ }
+
+ /**
+ * Attempts to attach to the item monitor.
+ *
+ * @return
+ */
+ private boolean attachToMonitor()
+ {
+ // Is this server side?
+ if( EffectiveSide.isClientSide() )
+ {
+ return false;
+ }
+
+ // Clear any existing
+ if( this.monitor != null )
+ {
+ this.monitor.removeListener( this );
+ }
+
+ // Get the grid
+ IGrid grid = this.terminal.getGridBlock().getGrid();
+ if( grid != null )
+ {
// Get the AE monitor
- this.monitor = terminal.getItemInventory();
-
- // Did we get a monitor?
+ this.monitor = this.terminal.getItemInventory();
if( this.monitor != null )
{
// Register with the monitor.
- this.monitor.addListener( this, null );
+ this.monitor.addListener( this, grid.hashCode() );
+ return true;
}
}
- else
- {
- this.monitor = null;
- }
+
+ return false;
}
/**
@@ -906,6 +932,17 @@ public class ContainerPartArcaneCraftingTerminal
Packet_C_ArcaneCraftingTerminal.sendModeChange( this.player,
this.cachedSortOrder, this.cachedSortDirection, this.cachedViewMode );
}
+
+ // Is the monitor null?
+ if( this.monitor == null )
+ {
+ // Attempt to re-attach
+ if( this.attachToMonitor() )
+ {
+ // Update the client
+ this.onClientRequestFullUpdate( this.player );
+ }
+ }
}
/**
@@ -944,9 +981,36 @@ public class ContainerPartArcaneCraftingTerminal
@Override
public boolean isValid( final Object authToken )
{
- return true;
+ if( this.monitor == null )
+ {
+ return false;
+ }
+
+ // Get the grid
+ IGrid grid = this.terminal.getGridBlock().getGrid();
+ if( grid != null )
+ {
+ if( grid.hashCode() == (Integer)authToken )
+ {
+ return true;
+ }
+ }
+
+ // Monitor no longer valid
+ this.monitor = null;
+
+ // Update client
+ this.onClientRequestFullUpdate( this.player );
+
+ return false;
}
+ /**
+ * Called when a client is setting up the crafting grid via NEI
+ *
+ * @param player
+ * @param gridItems
+ */
public void onClientNEIRequestSetCraftingGrid( final EntityPlayer player, final IAEItemStack[] gridItems )
{
// Attempt to clear the crafting grid
@@ -1035,8 +1099,8 @@ public class ContainerPartArcaneCraftingTerminal
*/
public void onClientRequestDeposit( final EntityPlayer player, final int mouseButton )
{
- // Ensure there is a player
- if( player == null )
+ // Ensure there is a player & monitor
+ if( ( player == null ) || ( this.monitor == null ) )
{
return;
}
@@ -1176,8 +1240,8 @@ public class ContainerPartArcaneCraftingTerminal
*/
public void onClientRequestExtract( final EntityPlayer player, final IAEItemStack requestedStack, final int mouseButton, final boolean isShiftHeld )
{
- // Ensure there is a player
- if( player == null )
+ // Ensure there is a player and monitor
+ if( ( player == null ) || ( this.monitor == null ) )
{
return;
}
@@ -1326,6 +1390,11 @@ public class ContainerPartArcaneCraftingTerminal
// Send to the client
Packet_C_ArcaneCraftingTerminal.sendAllNetworkItems( player, fullList );
}
+ else
+ {
+ // Send empty list
+ Packet_C_ArcaneCraftingTerminal.sendAllNetworkItems( player, AEApi.instance().storage().createItemList() );
+ }
}
/**
@@ -1446,6 +1515,11 @@ public class ContainerPartArcaneCraftingTerminal
@Override
public void postChange( final IBaseMonitor monitor, final Iterable changes, final BaseActionSource actionSource )
{
+ if( this.monitor == null )
+ {
+ return;
+ }
+
for( IAEItemStack change : changes )
{
// Get the total amount of the item in the network
@@ -1484,6 +1558,11 @@ public class ContainerPartArcaneCraftingTerminal
*/
public ItemStack requestCraftingReplenishment( final ItemStack itemStack )
{
+ if( this.monitor == null )
+ {
+ return null;
+ }
+
// Create the request stack
IAEItemStack requestStack = AEApi.instance().storage().createItemStack( itemStack );
diff --git a/src/main/java/thaumicenergistics/common/container/ContainerPartEssentiaIOBus.java b/src/main/java/thaumicenergistics/common/container/ContainerPartEssentiaIOBus.java
index ce19aaac..6fbdd031 100644
--- a/src/main/java/thaumicenergistics/common/container/ContainerPartEssentiaIOBus.java
+++ b/src/main/java/thaumicenergistics/common/container/ContainerPartEssentiaIOBus.java
@@ -96,7 +96,7 @@ public class ContainerPartEssentiaIOBus
{
if( this.bus != null )
{
- return this.bus.isUseableByPlayer( player );
+ return this.bus.isPartUseableByPlayer( player );
}
return false;
}
diff --git a/src/main/java/thaumicenergistics/common/container/ContainerPartEssentiaLevelEmitter.java b/src/main/java/thaumicenergistics/common/container/ContainerPartEssentiaLevelEmitter.java
index 6abfa4cd..f514f676 100644
--- a/src/main/java/thaumicenergistics/common/container/ContainerPartEssentiaLevelEmitter.java
+++ b/src/main/java/thaumicenergistics/common/container/ContainerPartEssentiaLevelEmitter.java
@@ -79,7 +79,7 @@ public class ContainerPartEssentiaLevelEmitter
{
if( this.emitter != null )
{
- return this.emitter.isUseableByPlayer( player );
+ return this.emitter.isPartUseableByPlayer( player );
}
return false;
}
diff --git a/src/main/java/thaumicenergistics/common/container/ContainerPartEssentiaStorageBus.java b/src/main/java/thaumicenergistics/common/container/ContainerPartEssentiaStorageBus.java
index ef8784e3..41316c05 100644
--- a/src/main/java/thaumicenergistics/common/container/ContainerPartEssentiaStorageBus.java
+++ b/src/main/java/thaumicenergistics/common/container/ContainerPartEssentiaStorageBus.java
@@ -86,7 +86,7 @@ public class ContainerPartEssentiaStorageBus
{
if( this.storageBus != null )
{
- return this.storageBus.isUseableByPlayer( player );
+ return this.storageBus.isPartUseableByPlayer( player );
}
return false;
}
diff --git a/src/main/java/thaumicenergistics/common/container/ContainerPriority.java b/src/main/java/thaumicenergistics/common/container/ContainerPriority.java
index 0875a882..ad618993 100644
--- a/src/main/java/thaumicenergistics/common/container/ContainerPriority.java
+++ b/src/main/java/thaumicenergistics/common/container/ContainerPriority.java
@@ -50,7 +50,7 @@ public class ContainerPriority
}
else if( this.host instanceof ThEPartBase )
{
- return ( (ThEPartBase)this.host ).isUseableByPlayer( player );
+ return ( (ThEPartBase)this.host ).isPartUseableByPlayer( player );
}
else if( this.host instanceof TileEntity )
{
diff --git a/src/main/java/thaumicenergistics/common/container/ContainerWirelessEssentiaTerminal.java b/src/main/java/thaumicenergistics/common/container/ContainerWirelessEssentiaTerminal.java
index 3efd161f..64e1a82a 100644
--- a/src/main/java/thaumicenergistics/common/container/ContainerWirelessEssentiaTerminal.java
+++ b/src/main/java/thaumicenergistics/common/container/ContainerWirelessEssentiaTerminal.java
@@ -1,10 +1,12 @@
package thaumicenergistics.common.container;
+import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import thaumcraft.api.aspects.Aspect;
import thaumicenergistics.api.grid.ICraftingIssuerHost;
+import thaumicenergistics.api.grid.IMEEssentiaMonitor;
import thaumicenergistics.common.ThEGuiHandler;
import thaumicenergistics.common.ThaumicEnergistics;
import thaumicenergistics.common.inventory.HandlerWirelessEssentiaTerminal;
@@ -20,6 +22,7 @@ import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.Settings;
import appeng.api.config.ViewItems;
+import appeng.api.networking.IGrid;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.ContainerOpenContext;
@@ -39,6 +42,7 @@ public class ContainerWirelessEssentiaTerminal
/**
* Handler used to interact with the wireless terminal.
*/
+ @Nonnull
private final HandlerWirelessEssentiaTerminal handler;
private Aspect tmpSelectedAspect;
@@ -74,7 +78,7 @@ public class ContainerWirelessEssentiaTerminal
* @param player
* @param handler
*/
- public ContainerWirelessEssentiaTerminal( final EntityPlayer player, final HandlerWirelessEssentiaTerminal handler )
+ public ContainerWirelessEssentiaTerminal( final EntityPlayer player, final @Nonnull HandlerWirelessEssentiaTerminal handler )
{
// Call super
super( player );
@@ -88,20 +92,11 @@ public class ContainerWirelessEssentiaTerminal
// Set the handler
this.handler = handler;
- // Server side?
- if( EffectiveSide.isServerSide() )
- {
- // Set the monitor
- this.monitor = this.handler.getEssentiaMonitor();
-
- // Attach to the monitor
- this.attachToMonitor();
- }
- else
+ // Client side?
+ if( EffectiveSide.isClientSide() )
{
// Request a full update from the server
Packet_S_EssentiaCellTerminal.sendFullUpdateRequest( player );
- this.hasRequested = true;
}
}
@@ -111,12 +106,31 @@ public class ContainerWirelessEssentiaTerminal
return this.handler.getActionHost();
}
+ @Override
+ protected IGrid getHostGrid()
+ {
+ try
+ {
+ return this.handler.getActionableNode().getGrid();
+ }
+ catch( Exception e )
+ {
+ return null;
+ }
+ }
+
@Override
protected Aspect getHostSelectedAspect()
{
return this.tmpSelectedAspect;
}
+ @Override
+ protected IMEEssentiaMonitor getNewMonitor()
+ {
+ return this.handler.getEssentiaMonitor();
+ }
+
@Override
protected void setHostSelectedAspect( final Aspect aspect )
{
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureACT.java b/src/main/java/thaumicenergistics/common/features/FeatureACT.java
index dd5fd474..afaa895c 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureACT.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureACT.java
@@ -6,10 +6,7 @@ import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.research.ResearchPage;
import thaumicenergistics.api.ThEApi;
-import thaumicenergistics.common.registries.AEPartsEnum;
-import thaumicenergistics.common.registries.FeatureRegistry;
-import thaumicenergistics.common.registries.RecipeRegistry;
-import thaumicenergistics.common.registries.ResearchRegistry;
+import thaumicenergistics.common.registries.*;
import thaumicenergistics.common.registries.ResearchRegistry.ResearchTypes;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
@@ -37,11 +34,8 @@ public class FeatureACT
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
- // Common items
- CommonDependantItems cdi = FeatureRegistry.instance().getCommonItems();
-
// My items
ItemStack ArcaneCraftingTerminal = ThEApi.instance().parts().ArcaneCrafting_Terminal.getStack();
@@ -60,7 +54,8 @@ public class FeatureACT
Object[] actRecipe = new Object[] { cdi.METerminal, cdi.ArcaneWorkTable, cdi.CalculationProcessor };
// Register
- RecipeRegistry.PART_ARCANE_TERMINAL = ThaumcraftApi.addShapelessArcaneCraftingRecipe( ResearchRegistry.ResearchTypes.ARCANE_TERMINAL.getKey(),
+ RecipeRegistry.PART_ARCANE_TERMINAL = ThaumcraftApi.addShapelessArcaneCraftingRecipe(
+ ResearchRegistry.ResearchTypes.ARCANE_TERMINAL.getKey(),
ArcaneCraftingTerminal, actAspectList, actRecipe );
}
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureAutocrafting_Arcane.java b/src/main/java/thaumicenergistics/common/features/FeatureAutocrafting_Arcane.java
index ad550458..8a226b78 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureAutocrafting_Arcane.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureAutocrafting_Arcane.java
@@ -44,11 +44,8 @@ public class FeatureAutocrafting_Arcane
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
- // Common items
- CommonDependantItems cdi = FeatureRegistry.instance().getCommonItems();
-
// Thaumcraft items
ItemStack CraftingScepter = VisCraftingHelper.INSTANCE.getCraftingScepter();
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureAutocrafting_Essentia.java b/src/main/java/thaumicenergistics/common/features/FeatureAutocrafting_Essentia.java
index 07ec04de..804ea902 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureAutocrafting_Essentia.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureAutocrafting_Essentia.java
@@ -36,11 +36,8 @@ public class FeatureAutocrafting_Essentia
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
- // Common items
- CommonDependantItems cdi = FeatureRegistry.instance().getCommonItems();
-
// My items
ItemStack dpeStack = ThEApi.instance().blocks().DistillationPatternEncoder.getStack();
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureCells.java b/src/main/java/thaumicenergistics/common/features/FeatureCells.java
index 592f84d3..ae0db2bc 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureCells.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureCells.java
@@ -15,9 +15,7 @@ import thaumcraft.api.research.ResearchPage;
import thaumcraft.common.config.Config;
import thaumicenergistics.api.IThEItems;
import thaumicenergistics.api.ThEApi;
-import thaumicenergistics.common.registries.FeatureRegistry;
-import thaumicenergistics.common.registries.RecipeRegistry;
-import thaumicenergistics.common.registries.ResearchRegistry;
+import thaumicenergistics.common.registries.*;
import thaumicenergistics.common.registries.ResearchRegistry.PseudoResearchTypes;
import thaumicenergistics.common.registries.ResearchRegistry.ResearchTypes;
import appeng.core.AEConfig;
@@ -78,11 +76,8 @@ public class FeatureCells
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
- // Common items
- CommonDependantItems cdi = FeatureRegistry.instance().getCommonItems();
-
// My items
IThEItems theItems = ThEApi.instance().items();
ItemStack EssentiaStorageComponent_1k = theItems.EssentiaStorageComponent_1k.getStack();
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureConversionCores.java b/src/main/java/thaumicenergistics/common/features/FeatureConversionCores.java
index 0692d523..95c4491f 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureConversionCores.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureConversionCores.java
@@ -8,9 +8,7 @@ import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.research.ResearchPage;
import thaumicenergistics.api.ThEApi;
import thaumicenergistics.common.items.ItemMaterial;
-import thaumicenergistics.common.registries.FeatureRegistry;
-import thaumicenergistics.common.registries.RecipeRegistry;
-import thaumicenergistics.common.registries.ResearchRegistry;
+import thaumicenergistics.common.registries.*;
import thaumicenergistics.common.registries.ResearchRegistry.PseudoResearchTypes;
import thaumicenergistics.common.registries.ResearchRegistry.ResearchTypes;
@@ -31,12 +29,8 @@ public class FeatureConversionCores
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
-
- // Common items
- CommonDependantItems cdi = FeatureRegistry.instance().getCommonItems();
-
// My items
ItemStack DiffusionCore = ThEApi.instance().items().DiffusionCore.getStack();
ItemStack CoalescenceCore = ThEApi.instance().items().CoalescenceCore.getStack();
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureEssentiaIOBuses.java b/src/main/java/thaumicenergistics/common/features/FeatureEssentiaIOBuses.java
index 0cdca09c..6ed0b04d 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureEssentiaIOBuses.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureEssentiaIOBuses.java
@@ -8,10 +8,7 @@ import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.research.ResearchPage;
import thaumicenergistics.api.ThEApi;
-import thaumicenergistics.common.registries.AEPartsEnum;
-import thaumicenergistics.common.registries.FeatureRegistry;
-import thaumicenergistics.common.registries.RecipeRegistry;
-import thaumicenergistics.common.registries.ResearchRegistry;
+import thaumicenergistics.common.registries.*;
import thaumicenergistics.common.registries.ResearchRegistry.PseudoResearchTypes;
import thaumicenergistics.common.registries.ResearchRegistry.ResearchTypes;
import appeng.core.AEConfig;
@@ -39,11 +36,8 @@ public class FeatureEssentiaIOBuses
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
- // Common items
- CommonDependantItems cdi = FeatureRegistry.instance().getCommonItems();
-
// My items
ItemStack DiffusionCore = ThEApi.instance().items().DiffusionCore.getStack();
ItemStack CoalescenceCore = ThEApi.instance().items().CoalescenceCore.getStack();
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureEssentiaMonitoring.java b/src/main/java/thaumicenergistics/common/features/FeatureEssentiaMonitoring.java
index 17129f64..a74d37a5 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureEssentiaMonitoring.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureEssentiaMonitoring.java
@@ -39,11 +39,8 @@ public class FeatureEssentiaMonitoring
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
- // Common items
- CommonDependantItems cdi = FeatureRegistry.instance().getCommonItems();
-
// My items
IThEItems theItems = ThEApi.instance().items();
IThEParts theParts = ThEApi.instance().parts();
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureEssentiaProvider.java b/src/main/java/thaumicenergistics/common/features/FeatureEssentiaProvider.java
index 8d6a0e60..afcab5e3 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureEssentiaProvider.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureEssentiaProvider.java
@@ -6,10 +6,7 @@ import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.research.ResearchPage;
import thaumicenergistics.api.ThEApi;
-import thaumicenergistics.common.registries.BlockEnum;
-import thaumicenergistics.common.registries.FeatureRegistry;
-import thaumicenergistics.common.registries.RecipeRegistry;
-import thaumicenergistics.common.registries.ResearchRegistry;
+import thaumicenergistics.common.registries.*;
import thaumicenergistics.common.registries.ResearchRegistry.ResearchTypes;
public class FeatureEssentiaProvider
@@ -34,12 +31,8 @@ public class FeatureEssentiaProvider
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
-
- // Common items
- CommonDependantItems cdi = FeatureRegistry.instance().getCommonItems();
-
// My items
ItemStack DiffusionCore = ThEApi.instance().items().DiffusionCore.getStack();
ItemStack CoalescenceCore = ThEApi.instance().items().CoalescenceCore.getStack();
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureEssentiaVibrationChamber.java b/src/main/java/thaumicenergistics/common/features/FeatureEssentiaVibrationChamber.java
index 9d64710a..b47a61d9 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureEssentiaVibrationChamber.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureEssentiaVibrationChamber.java
@@ -36,11 +36,8 @@ public class FeatureEssentiaVibrationChamber
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
- // Common items
- CommonDependantItems cdi = FeatureRegistry.instance().getCommonItems();
-
// My Items
ItemStack EssVibrationChamber = ThEApi.instance().blocks().EssentiaVibrationChamber.getStack();
ItemStack DiffusionCore = ThEApi.instance().items().DiffusionCore.getStack();
@@ -54,7 +51,8 @@ public class FeatureEssentiaVibrationChamber
// Register Chamber
RecipeRegistry.BLOCK_ESSENTIA_VIBRATION_CHAMBER = ThaumcraftApi.addShapelessArcaneCraftingRecipe(
- ResearchTypes.ESSENTIA_VIBRATION_CHAMBER.getKey(), EssVibrationChamber, chamberAspects, cdi.VibrationChamber, DiffusionCore, cdi.WardedJar );
+ ResearchTypes.ESSENTIA_VIBRATION_CHAMBER.getKey(), EssVibrationChamber, chamberAspects, cdi.VibrationChamber, DiffusionCore,
+ cdi.WardedJar );
}
@Override
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureGearbox.java b/src/main/java/thaumicenergistics/common/features/FeatureGearbox.java
index 66ae47c5..212cca15 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureGearbox.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureGearbox.java
@@ -9,7 +9,6 @@ import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.research.ResearchPage;
import thaumicenergistics.api.ThEApi;
-import thaumicenergistics.common.registries.FeatureRegistry;
import thaumicenergistics.common.registries.RecipeRegistry;
import thaumicenergistics.common.registries.ResearchRegistry;
import thaumicenergistics.common.registries.ResearchRegistry.PseudoResearchTypes;
@@ -25,11 +24,8 @@ public class FeatureGearbox
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
- // Common items
- CommonDependantItems cdi = FeatureRegistry.instance().getCommonItems();
-
// Ore dictionary items
Object WoodGear = "gearWood";
String IronGear = "gearIron";
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureInfusionProvider.java b/src/main/java/thaumicenergistics/common/features/FeatureInfusionProvider.java
index 56959f96..ac3ebc09 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureInfusionProvider.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureInfusionProvider.java
@@ -8,10 +8,7 @@ import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.research.ResearchPage;
import thaumcraft.common.config.Config;
import thaumicenergistics.api.ThEApi;
-import thaumicenergistics.common.registries.BlockEnum;
-import thaumicenergistics.common.registries.FeatureRegistry;
-import thaumicenergistics.common.registries.RecipeRegistry;
-import thaumicenergistics.common.registries.ResearchRegistry;
+import thaumicenergistics.common.registries.*;
import thaumicenergistics.common.registries.ResearchRegistry.PseudoResearchTypes;
import thaumicenergistics.common.registries.ResearchRegistry.ResearchTypes;
@@ -37,11 +34,8 @@ public class FeatureInfusionProvider
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
- // Common items
- CommonDependantItems cdi = FeatureRegistry.instance().getCommonItems();
-
// My items
ItemStack CoalescenceCore = ThEApi.instance().items().CoalescenceCore.getStack();
ItemStack InfusionProvider = ThEApi.instance().blocks().InfusionProvider.getStack();
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureQuartzDupe.java b/src/main/java/thaumicenergistics/common/features/FeatureQuartzDupe.java
index 5daf6adc..538b820d 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureQuartzDupe.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureQuartzDupe.java
@@ -8,9 +8,7 @@ import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.research.ResearchPage;
import thaumicenergistics.api.ThEApi;
-import thaumicenergistics.common.registries.FeatureRegistry;
-import thaumicenergistics.common.registries.RecipeRegistry;
-import thaumicenergistics.common.registries.ResearchRegistry;
+import thaumicenergistics.common.registries.*;
import thaumicenergistics.common.registries.ResearchRegistry.PseudoResearchTypes;
import thaumicenergistics.common.registries.ResearchRegistry.ResearchTypes;
import appeng.api.AEApi;
@@ -36,7 +34,7 @@ public class FeatureQuartzDupe
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
// Certus
String Certus1 = "crystalCertusQuartz";
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureResearchSetup.java b/src/main/java/thaumicenergistics/common/features/FeatureResearchSetup.java
index 0318962d..4dd8b007 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureResearchSetup.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureResearchSetup.java
@@ -1,5 +1,6 @@
package thaumicenergistics.common.features;
+import java.util.ArrayList;
import net.minecraft.util.ResourceLocation;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.research.ResearchCategories;
@@ -58,7 +59,7 @@ public class FeatureResearchSetup
*
* @param featureList
*/
- public void finalizeRegistration( final ThEFeatureBase[] featureList )
+ public void finalizeRegistration( final ArrayList featureList )
{
if( this.hasFinalizedResearch )
{
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureThaumcraftFacades.java b/src/main/java/thaumicenergistics/common/features/FeatureThaumcraftFacades.java
new file mode 100644
index 00000000..d9831d66
--- /dev/null
+++ b/src/main/java/thaumicenergistics/common/features/FeatureThaumcraftFacades.java
@@ -0,0 +1,125 @@
+package thaumicenergistics.common.features;
+
+import java.util.regex.Pattern;
+import net.minecraft.block.Block;
+import net.minecraftforge.common.config.Property;
+import thaumcraft.common.config.Config;
+import thaumcraft.common.config.ConfigBlocks;
+import thaumicenergistics.api.ThEApi;
+import appeng.core.FacadeConfig;
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
+
+public class FeatureThaumcraftFacades
+ extends ThEDependencyFeatureBase
+{
+
+ /**
+ * Ensures the blocks name is clean
+ */
+ private final Pattern sanitizer;
+
+ public FeatureThaumcraftFacades()
+ {
+ // Set the pattern
+ this.sanitizer = Pattern.compile( "[^a-zA-Z0-9]" );
+ }
+
+ /**
+ * Forces the specified stack to have a facade if possible.
+ *
+ * @param block
+ * @param meta
+ */
+ private void forceEnabled( final Block block, final int meta )
+ {
+ // Sanity check
+ if( block == null )
+ {
+ return;
+ }
+
+ // Get the uid for the block
+ UniqueIdentifier uid = GameRegistry.findUniqueIdentifierFor( block );
+ if( uid == null )
+ {
+ return;
+ }
+
+ // Get the mod and block names
+ String modName = this.sanitizer.matcher( uid.modId ).replaceAll( "" );
+ String blockName = this.sanitizer.matcher( uid.name ).replaceAll( "" );
+
+ // Get the property
+ Property prop = FacadeConfig.instance.get( modName, blockName + ( meta == 0 ? "" : "." + meta ), true );
+
+ // Set it to true
+ prop.set( true );
+
+ }
+
+ @Override
+ protected boolean checkConfigs()
+ {
+ return ThEApi.instance().config().forceTCFacades();
+ }
+
+ @Override
+ protected Object[] getItemReqs( final CommonDependantItems cdi )
+ {
+ return null;
+ }
+
+ @Override
+ protected void registerCrafting( final CommonDependantItems cdi )
+ {
+ // Amber block
+ this.forceEnabled( ConfigBlocks.blockCosmeticOpaque, 0 );
+
+ // Amber brick
+ this.forceEnabled( ConfigBlocks.blockCosmeticOpaque, 1 );
+
+ // Warded glass
+ if( Config.allowMirrors )
+ {
+ this.forceEnabled( ConfigBlocks.blockCosmeticOpaque, 2 );
+ }
+
+ // Obsidian tile
+ this.forceEnabled( ConfigBlocks.blockCosmeticSolid, 1 );
+
+ // Thaumium block
+ this.forceEnabled( ConfigBlocks.blockCosmeticSolid, 4 );
+
+ // Tallow block
+ this.forceEnabled( ConfigBlocks.blockCosmeticSolid, 5 );
+
+ // Arcane stone block
+ this.forceEnabled( ConfigBlocks.blockCosmeticSolid, 6 );
+
+ // Arcane stone brick
+ this.forceEnabled( ConfigBlocks.blockCosmeticSolid, 7 );
+
+ // Ancient stone
+ this.forceEnabled( ConfigBlocks.blockCosmeticSolid, 11 );
+
+ // Ancient rock
+ this.forceEnabled( ConfigBlocks.blockCosmeticSolid, 12 );
+
+ // Crusted stone
+ this.forceEnabled( ConfigBlocks.blockCosmeticSolid, 14 );
+
+ // Greatwood planks
+ this.forceEnabled( ConfigBlocks.blockWoodenDevice, 6 );
+
+ // Silverwood planks
+ this.forceEnabled( ConfigBlocks.blockWoodenDevice, 7 );
+
+ // Crusted taint
+ this.forceEnabled( ConfigBlocks.blockTaint, 0 );
+
+ // Flesh block :<
+ this.forceEnabled( ConfigBlocks.blockTaint, 2 );
+ }
+
+}
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureVisRelayInterface.java b/src/main/java/thaumicenergistics/common/features/FeatureVisRelayInterface.java
index cc237e24..428060c7 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureVisRelayInterface.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureVisRelayInterface.java
@@ -7,10 +7,7 @@ import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.research.ResearchPage;
import thaumicenergistics.api.ThEApi;
-import thaumicenergistics.common.registries.AEPartsEnum;
-import thaumicenergistics.common.registries.FeatureRegistry;
-import thaumicenergistics.common.registries.RecipeRegistry;
-import thaumicenergistics.common.registries.ResearchRegistry;
+import thaumicenergistics.common.registries.*;
import thaumicenergistics.common.registries.ResearchRegistry.PseudoResearchTypes;
import thaumicenergistics.common.registries.ResearchRegistry.ResearchTypes;
import appeng.core.AEConfig;
@@ -38,11 +35,8 @@ public class FeatureVisRelayInterface
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
- // Common items
- CommonDependantItems cdi = FeatureRegistry.instance().getCommonItems();
-
// My items
ItemStack VisInterface = ThEApi.instance().parts().VisRelay_Interface.getStack();
@@ -54,7 +48,8 @@ public class FeatureVisRelayInterface
visInterfaceAspectList.add( Aspect.FIRE, 2 );
visInterfaceAspectList.add( Aspect.ORDER, 2 );
visInterfaceAspectList.add( Aspect.WATER, 2 );
- RecipeRegistry.PART_VIS_INTERFACE = ThaumcraftApi.addShapelessArcaneCraftingRecipe( ResearchRegistry.ResearchTypes.VIS_RELAY_INTERFACE.getKey(),
+ RecipeRegistry.PART_VIS_INTERFACE = ThaumcraftApi.addShapelessArcaneCraftingRecipe(
+ ResearchRegistry.ResearchTypes.VIS_RELAY_INTERFACE.getKey(),
VisInterface, visInterfaceAspectList, cdi.BallanceShard, cdi.MEP2P );
}
@@ -73,7 +68,8 @@ public class FeatureVisRelayInterface
// Set the pages
ResearchPage[] vriPages = new ResearchPage[] { new ResearchPage( ResearchTypes.VIS_RELAY_INTERFACE.getPageName( 1 ) ),
- new ResearchPage( RecipeRegistry.PART_VIS_INTERFACE ), new ResearchPage( ResearchTypes.VIS_RELAY_INTERFACE.getPageName( 2 ) ),
+ new ResearchPage( RecipeRegistry.PART_VIS_INTERFACE ),
+ new ResearchPage( ResearchTypes.VIS_RELAY_INTERFACE.getPageName( 2 ) ),
new ResearchPage( ResearchTypes.VIS_RELAY_INTERFACE.getPageName( 3 ) ) };
// Create the vis relay interface research
diff --git a/src/main/java/thaumicenergistics/common/features/FeatureWrenchFocus.java b/src/main/java/thaumicenergistics/common/features/FeatureWrenchFocus.java
index a138b966..8634a68b 100644
--- a/src/main/java/thaumicenergistics/common/features/FeatureWrenchFocus.java
+++ b/src/main/java/thaumicenergistics/common/features/FeatureWrenchFocus.java
@@ -7,7 +7,6 @@ import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.research.ResearchPage;
import thaumicenergistics.api.ThEApi;
-import thaumicenergistics.common.registries.FeatureRegistry;
import thaumicenergistics.common.registries.RecipeRegistry;
import thaumicenergistics.common.registries.ResearchRegistry;
import thaumicenergistics.common.registries.ResearchRegistry.PseudoResearchTypes;
@@ -43,11 +42,8 @@ public class FeatureWrenchFocus
}
@Override
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
- // Common items
- CommonDependantItems cdi = FeatureRegistry.instance().getCommonItems();
-
// My items
ItemStack WrenchFocus = ThEApi.instance().items().WandFocusAEWrench.getStack();
diff --git a/src/main/java/thaumicenergistics/common/features/ThEDependencyFeatureBase.java b/src/main/java/thaumicenergistics/common/features/ThEDependencyFeatureBase.java
index 66f2bbf1..71b1f005 100644
--- a/src/main/java/thaumicenergistics/common/features/ThEDependencyFeatureBase.java
+++ b/src/main/java/thaumicenergistics/common/features/ThEDependencyFeatureBase.java
@@ -1,6 +1,5 @@
package thaumicenergistics.common.features;
-import thaumicenergistics.common.registries.FeatureRegistry;
/**
* Defines a feature that depends on a configuration setting and/or specific
@@ -60,12 +59,12 @@ public abstract class ThEDependencyFeatureBase
/**
* Evaluates the dependencies of the feature and enables it if possible.
*
- * @param fr
+ * @param cdi
*/
- public final void evaluateDependencies( final FeatureRegistry fr )
+ public final void evaluateDependencies( final CommonDependantItems cdi )
{
// Ask for the features config settings and required items
- this.setAvailable( this.checkConfigs() && this.checkItemReqs( this.getItemReqs( fr.getCommonItems() ) ) );
+ this.setAvailable( this.checkConfigs() && this.checkItemReqs( this.getItemReqs( cdi ) ) );
}
}
diff --git a/src/main/java/thaumicenergistics/common/features/ThEFeatureBase.java b/src/main/java/thaumicenergistics/common/features/ThEFeatureBase.java
index 9dec9026..63902f60 100644
--- a/src/main/java/thaumicenergistics/common/features/ThEFeatureBase.java
+++ b/src/main/java/thaumicenergistics/common/features/ThEFeatureBase.java
@@ -34,8 +34,10 @@ public abstract class ThEFeatureBase
/**
* Registers the features crafting recipes, if it has any.
+ *
+ * @param cdi
*/
- protected void registerCrafting()
+ protected void registerCrafting( final CommonDependantItems cdi )
{
}
@@ -94,14 +96,16 @@ public abstract class ThEFeatureBase
/**
* Asks the feature to register itself.
+ *
+ * @param cdi
*/
- public final void registerFeature()
+ public final void registerFeature( final CommonDependantItems cdi )
{
// Is the feature enabled and has not yet been registered?
if( this.isAvailable() && !this.hasRegistered )
{
// Register crafting recipe(s)
- this.registerCrafting();
+ this.registerCrafting( cdi );
// Register Thaumcraft research.
this.registerResearch();
diff --git a/src/main/java/thaumicenergistics/common/grid/EssentiaMonitor.java b/src/main/java/thaumicenergistics/common/grid/EssentiaMonitor.java
index ffe01c86..15f7971f 100644
--- a/src/main/java/thaumicenergistics/common/grid/EssentiaMonitor.java
+++ b/src/main/java/thaumicenergistics/common/grid/EssentiaMonitor.java
@@ -276,16 +276,6 @@ public class EssentiaMonitor
@SuppressWarnings("null")
protected void updateCacheToMatchNetwork()
{
- // Get the list of fluids in the network
- IItemList fluidStackList;
-
- // Validate the list
- if( ( fluidStackList = this.fluidMonitor.getStorageList() ) == null )
- {
- // Invalid list
- return;
- }
-
// Changes made to the cache
List aspectChanges = null;
@@ -307,38 +297,46 @@ public class EssentiaMonitor
this.cache.clear();
}
- // Loop over all fluids
- for( IAEFluidStack fluidStack : fluidStackList )
+ // Is the network powerd?
+ if( this.energyGrid.isNetworkPowered() )
{
- // Ensure the fluid is an essentia gas
- if( !( fluidStack.getFluid() instanceof GaseousEssentia ) )
+
+ // Get the list of fluids in the network
+ IItemList fluidStackList = this.fluidMonitor.getStorageList();
+
+ // Loop over all fluids
+ for( IAEFluidStack fluidStack : fluidStackList )
{
- // Not an essentia gas.
- continue;
- }
-
- // Get the gas aspect
- Aspect aspect = ( (GaseousEssentia)fluidStack.getFluid() ).getAspect();
-
- // Calculate the new amount
- Long newAmount = EssentiaConversionHelper.INSTANCE.convertFluidAmountToEssentiaAmount( fluidStack.getStackSize() );
-
- // Update the cache
- IAspectStack prevStack = this.cache.setAspect( aspect, newAmount, false );
-
- // Are there any listeners?
- if( hasListeners )
- {
- // Remove from the previous mapping
- previousAspects.remove( aspect );
-
- // Calculate the difference
- long diff = ( newAmount - ( prevStack != null ? prevStack.getStackSize() : 0 ) );
-
- if( diff != 0 )
+ // Ensure the fluid is an essentia gas
+ if( !( fluidStack.getFluid() instanceof GaseousEssentia ) )
{
- // Add to the changes
- aspectChanges.add( new AspectStack( aspect, diff ) );
+ // Not an essentia gas.
+ continue;
+ }
+
+ // Get the gas aspect
+ Aspect aspect = ( (GaseousEssentia)fluidStack.getFluid() ).getAspect();
+
+ // Calculate the new amount
+ Long newAmount = EssentiaConversionHelper.INSTANCE.convertFluidAmountToEssentiaAmount( fluidStack.getStackSize() );
+
+ // Update the cache
+ IAspectStack prevStack = this.cache.setAspect( aspect, newAmount, false );
+
+ // Are there any listeners?
+ if( hasListeners )
+ {
+ // Remove from the previous mapping
+ previousAspects.remove( aspect );
+
+ // Calculate the difference
+ long diff = ( newAmount - ( prevStack != null ? prevStack.getStackSize() : 0 ) );
+
+ if( diff != 0 )
+ {
+ // Add to the changes
+ aspectChanges.add( new AspectStack( aspect, diff ) );
+ }
}
}
}
@@ -349,7 +347,7 @@ public class EssentiaMonitor
// Anything left in the previous mapping is no longer present in the network
for( Aspect aspect : previousAspects )
{
- aspectChanges.add( new AspectStack( aspect, -this.cache.remove( aspect ).getStackSize() ) );
+ aspectChanges.add( new AspectStack( aspect, -this.cache.remove( aspect ).getStackSize(), false ) );
}
// Notify listeners
diff --git a/src/main/java/thaumicenergistics/common/grid/GridEssentiaCache.java b/src/main/java/thaumicenergistics/common/grid/GridEssentiaCache.java
index a3bdb93c..ae1db571 100644
--- a/src/main/java/thaumicenergistics/common/grid/GridEssentiaCache.java
+++ b/src/main/java/thaumicenergistics/common/grid/GridEssentiaCache.java
@@ -295,6 +295,12 @@ public class GridEssentiaCache
// Call super
super.updateCacheToMatchNetwork();
+ // Is the network powered?
+ if( !this.energyGrid.isNetworkPowered() )
+ {
+ return;
+ }
+
// Get the item monitor
IStorageGrid storage = (IStorageGrid)this.internalGrid.getCache( IStorageGrid.class );
IMEMonitor itemMonitor = storage.getItemInventory();
diff --git a/src/main/java/thaumicenergistics/common/inventory/HandlerKnowledgeCore.java b/src/main/java/thaumicenergistics/common/inventory/HandlerKnowledgeCore.java
index 50bcedd2..2c66a04d 100644
--- a/src/main/java/thaumicenergistics/common/inventory/HandlerKnowledgeCore.java
+++ b/src/main/java/thaumicenergistics/common/inventory/HandlerKnowledgeCore.java
@@ -23,20 +23,29 @@ public class HandlerKnowledgeCore
/**
* Array of stored patterns.
*/
- private ArrayList patterns = new ArrayList( HandlerKnowledgeCore.MAXIMUM_STORED_PATTERNS );
+ private final ArrayList patterns = new ArrayList( MAXIMUM_STORED_PATTERNS );
/**
* Knowledge core being handled.
*/
private ItemStack kCore;
+ /**
+ * Creates a handler without a core.
+ * Use open() to set the core in the future.
+ */
+ public HandlerKnowledgeCore()
+ {
+ }
+
+ /**
+ * Creates the handler with the specified core.
+ *
+ * @param kCore
+ */
public HandlerKnowledgeCore( final ItemStack kCore )
{
- // Set the kCore
- this.kCore = kCore;
-
- // Load
- this.loadKCoreData();
+ this.open( kCore );
}
/**
@@ -66,10 +75,10 @@ public class HandlerKnowledgeCore
NBTTagCompound data = this.getOrCreateNBT();
// Are there saved patterns?
- if( data.hasKey( HandlerKnowledgeCore.NBTKEY_PATTERNS ) )
+ if( data.hasKey( NBTKEY_PATTERNS ) )
{
// Get the list
- NBTTagList plist = data.getTagList( HandlerKnowledgeCore.NBTKEY_PATTERNS, Constants.NBT.TAG_COMPOUND );
+ NBTTagList plist = data.getTagList( NBTKEY_PATTERNS, Constants.NBT.TAG_COMPOUND );
// Read in each pattern
for( int index = 0; index < plist.tagCount(); index++ )
@@ -122,7 +131,7 @@ public class HandlerKnowledgeCore
// Write the list to the data
if( plist.tagCount() > 0 )
{
- data.setTag( HandlerKnowledgeCore.NBTKEY_PATTERNS, plist );
+ data.setTag( NBTKEY_PATTERNS, plist );
}
}
@@ -226,6 +235,16 @@ public class HandlerKnowledgeCore
return results;
}
+ /**
+ * Returns true if the handler has a core.
+ *
+ * @return
+ */
+ public boolean hasCore()
+ {
+ return this.kCore != null;
+ }
+
/**
* Returns true if there is a pattern stored that produces the specified
* result.
@@ -280,6 +299,23 @@ public class HandlerKnowledgeCore
return( ItemStack.areItemStacksEqual( kCore, this.kCore ) && ( ItemStack.areItemStackTagsEqual( kCore, this.kCore ) ) );
}
+ /**
+ * Closes the previous core, and opens the new core.
+ *
+ * @param kCore
+ */
+ public void open( final ItemStack kCore )
+ {
+ // Close any existing core
+ this.close();
+
+ // Set the kCore
+ this.kCore = kCore;
+
+ // Load
+ this.loadKCoreData();
+ }
+
/**
* Removes the specified pattern from the core.
*
diff --git a/src/main/java/thaumicenergistics/common/parts/PartArcaneCraftingTerminal.java b/src/main/java/thaumicenergistics/common/parts/PartArcaneCraftingTerminal.java
index 4654e3a4..9bc553f3 100644
--- a/src/main/java/thaumicenergistics/common/parts/PartArcaneCraftingTerminal.java
+++ b/src/main/java/thaumicenergistics/common/parts/PartArcaneCraftingTerminal.java
@@ -531,6 +531,12 @@ public class PartArcaneCraftingTerminal
return false;
}
+ @Override
+ public boolean isUseableByPlayer( final EntityPlayer player )
+ {
+ return this.isPartUseableByPlayer( player );
+ }
+
@Override
public void launchGUI( final EntityPlayer player )
{
diff --git a/src/main/java/thaumicenergistics/common/parts/ThEPartBase.java b/src/main/java/thaumicenergistics/common/parts/ThEPartBase.java
index 96d801ab..bcb010da 100644
--- a/src/main/java/thaumicenergistics/common/parts/ThEPartBase.java
+++ b/src/main/java/thaumicenergistics/common/parts/ThEPartBase.java
@@ -448,6 +448,56 @@ public abstract class ThEPartBase
return false;
}
+ /**
+ * Called the player interact with this part?
+ *
+ * @param player
+ * @return
+ */
+ public final boolean isPartUseableByPlayer( final EntityPlayer player )
+ {
+ // Null check host
+ if( ( this.hostTile == null ) || ( this.host == null ) )
+ {
+ return false;
+ }
+
+ // Does the host still exist in the world and the player in range of it?
+ if( !ThEUtils.canPlayerInteractWith( player, this.hostTile ) )
+ {
+ return false;
+ }
+
+ // Is the part still attached?
+ if( this.host.getPart( this.cableSide ) != this )
+ {
+ return false;
+ }
+
+ // Are there any permissions to check?
+ if( this.interactionPermissions != null )
+ {
+ // Get the security grid
+ ISecurityGrid sGrid = this.gridBlock.getSecurityGrid();
+ if( sGrid == null )
+ {
+ // Security grid was unaccessible.
+ return false;
+ }
+
+ // Check each permission
+ for( SecurityPermissions perm : this.interactionPermissions )
+ {
+ if( !sGrid.hasPermission( player, perm ) )
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
@Override
public boolean isPowered()
{
@@ -497,56 +547,6 @@ public abstract class ThEPartBase
return false;
}
- /**
- * Called the player interact with this part?
- *
- * @param player
- * @return
- */
- public final boolean isUseableByPlayer( final EntityPlayer player )
- {
- // Null check host
- if( ( this.hostTile == null ) || ( this.host == null ) )
- {
- return false;
- }
-
- // Does the host still exist in the world and the player in range of it?
- if( !ThEUtils.canPlayerInteractWith( player, this.hostTile ) )
- {
- return false;
- }
-
- // Is the part still attached?
- if( this.host.getPart( this.cableSide ) != this )
- {
- return false;
- }
-
- // Are there any permissions to check?
- if( this.interactionPermissions != null )
- {
- // Get the security grid
- ISecurityGrid sGrid = this.gridBlock.getSecurityGrid();
- if( sGrid == null )
- {
- // Security grid was unaccessible.
- return false;
- }
-
- // Check each permission
- for( SecurityPermissions perm : this.interactionPermissions )
- {
- if( !sGrid.hasPermission( player, perm ) )
- {
- return false;
- }
- }
- }
-
- return true;
- }
-
/**
* Marks that the host tile needs to be saved to disk.
*/
diff --git a/src/main/java/thaumicenergistics/common/registries/FeatureRegistry.java b/src/main/java/thaumicenergistics/common/registries/FeatureRegistry.java
index 1a7ef5c7..cb8f49f4 100644
--- a/src/main/java/thaumicenergistics/common/registries/FeatureRegistry.java
+++ b/src/main/java/thaumicenergistics/common/registries/FeatureRegistry.java
@@ -1,5 +1,6 @@
package thaumicenergistics.common.registries;
+import java.util.ArrayList;
import thaumicenergistics.common.features.*;
/**
@@ -23,9 +24,9 @@ public class FeatureRegistry
private final CommonDependantItems commonItems;
/**
- * All features in a nice compact array.
+ * All features.
*/
- private final ThEFeatureBase[] featuresList;
+ private final ArrayList featuresList = new ArrayList( 20 );
/**
* Set to true when registerFeatures() is called.
@@ -107,6 +108,11 @@ public class FeatureRegistry
*/
public final FeatureAutocrafting_Essentia featureAutocrafting_Essentia;
+ /**
+ * Thaumcraft facades.
+ */
+ public final FeatureThaumcraftFacades featureTCFacades;
+
/**
* Private constructor
*/
@@ -119,52 +125,49 @@ public class FeatureRegistry
this.featureResearchSetup = new FeatureResearchSetup();
// Build autocrafting
- this.featureAutoCrafting_Arcane = new FeatureAutocrafting_Arcane();
+ this.featuresList.add( this.featureAutoCrafting_Arcane = new FeatureAutocrafting_Arcane() );
// Build cells
- this.featureCells = new FeatureCells();
+ this.featuresList.add( this.featureCells = new FeatureCells() );
// Build ACT
- this.featureACT = new FeatureACT();
+ this.featuresList.add( this.featureACT = new FeatureACT() );
// Build VRI
- this.featureVRI = new FeatureVisRelayInterface();
+ this.featuresList.add( this.featureVRI = new FeatureVisRelayInterface() );
// Build IO buses
- this.featureEssentiaIOBuses = new FeatureEssentiaIOBuses();
+ this.featuresList.add( this.featureEssentiaIOBuses = new FeatureEssentiaIOBuses() );
// Build infusion provider
- this.featureInfusionProvider = new FeatureInfusionProvider();
+ this.featuresList.add( this.featureInfusionProvider = new FeatureInfusionProvider() );
// Build essentia provider
- this.featureEssentiaProvider = new FeatureEssentiaProvider();
+ this.featuresList.add( this.featureEssentiaProvider = new FeatureEssentiaProvider() );
// Build monitoring
- this.featureEssentiaMonitoring = new FeatureEssentiaMonitoring();
+ this.featuresList.add( this.featureEssentiaMonitoring = new FeatureEssentiaMonitoring() );
// Build conversion cores
- this.featureConversionCores = new FeatureConversionCores();
+ this.featuresList.add( this.featureConversionCores = new FeatureConversionCores() );
// Build gearboxes
- this.featureGearbox = new FeatureGearbox();
+ this.featuresList.add( this.featureGearbox = new FeatureGearbox() );
// Build wrench focus
- this.featureWrenchFocus = new FeatureWrenchFocus();
+ this.featuresList.add( this.featureWrenchFocus = new FeatureWrenchFocus() );
// Build quartz dupe
- this.featureQuartzDupe = new FeatureQuartzDupe();
+ this.featuresList.add( this.featureQuartzDupe = new FeatureQuartzDupe() );
// Build essentia vibration chamber
- this.featureEssentiaVibrationChamber = new FeatureEssentiaVibrationChamber();
+ this.featuresList.add( this.featureEssentiaVibrationChamber = new FeatureEssentiaVibrationChamber() );
// Build distillation pattern encoder
- this.featureAutocrafting_Essentia = new FeatureAutocrafting_Essentia();
+ this.featuresList.add( this.featureAutocrafting_Essentia = new FeatureAutocrafting_Essentia() );
- // Build array of features
- this.featuresList = new ThEFeatureBase[] { this.featureAutoCrafting_Arcane, this.featureCells, this.featureACT, this.featureVRI,
- this.featureEssentiaIOBuses, this.featureInfusionProvider, this.featureEssentiaProvider, this.featureEssentiaMonitoring,
- this.featureConversionCores, this.featureGearbox, this.featureWrenchFocus, this.featureQuartzDupe,
- this.featureEssentiaVibrationChamber, this.featureAutocrafting_Essentia };
+ // Build TC facades
+ this.featuresList.add( this.featureTCFacades = new FeatureThaumcraftFacades() );
}
/**
@@ -214,18 +217,18 @@ public class FeatureRegistry
if( feature instanceof ThEDependencyFeatureBase )
{
// Evaluate the dependencies
- ( (ThEDependencyFeatureBase)feature ).evaluateDependencies( this );
+ ( (ThEDependencyFeatureBase)feature ).evaluateDependencies( this.commonItems );
}
}
// Start with the setup
- this.featureResearchSetup.registerFeature();
+ this.featureResearchSetup.registerFeature( this.commonItems );
// Register each feature
for( ThEFeatureBase feature : this.featuresList )
{
// Attempt to register the feature
- feature.registerFeature();
+ feature.registerFeature( this.commonItems );
}
// Finish the registration
diff --git a/src/main/java/thaumicenergistics/common/tiles/TileKnowledgeInscriber.java b/src/main/java/thaumicenergistics/common/tiles/TileKnowledgeInscriber.java
index acf9e6b6..6c71155a 100644
--- a/src/main/java/thaumicenergistics/common/tiles/TileKnowledgeInscriber.java
+++ b/src/main/java/thaumicenergistics/common/tiles/TileKnowledgeInscriber.java
@@ -9,11 +9,6 @@ public class TileKnowledgeInscriber
extends ThETileInventory
{
public static final int KCORE_SLOT = 0;
- /*
- public static final int PATTERN_SLOT = KCORE_SLOT + 1;
- public static final int CRAFTING_MATRIX_SLOT = HandlerKnowledgeCore.MAXIMUM_STORED_PATTERNS + PATTERN_SLOT;
- public static final int CRAFTING_RESULT_SLOT = CRAFTING_MATRIX_SLOT + 9;
- */
private static final String NBTKEY_KCORE = "kcore";