mirror of
https://github.com/GTNewHorizons/ThaumicEnergistics.git
synced 2026-10-25 20:32:27 +00:00
Cleanup + ACT power loss
Fixes #264 - ACT clears all items on network power loss. Cleaned up the NBT save code for parts. Multiplayer gui sync fixes. Fixed crafting aspect item display name. Slightly reduced size of all packets.
This commit is contained in:
1 parent
e3e4a213a7
commit
fe304cb626
66 files changed
+1643
-1390
No files matched your search
+12
-1
@@ -1,7 +1,18 @@
|
||||
01/05/2016 0.10.0.0 - Beta
|
||||
01/02/2016 0.10.0.0
|
||||
Fixed crafting aspect item display name.
|
||||
More Multiplayer gui sync fixes.
|
||||
Slightly reduced size of all packets.
|
||||
|
||||
01/08/2016 0.10.0.0
|
||||
More Multiplayer gui sync fixes.
|
||||
|
||||
01/06/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.
|
||||
Cleaned up the NBT save code for parts.
|
||||
Fixes #264 - ACT clears all items on network power loss.
|
||||
Multiplayer gui sync fixes.
|
||||
|
||||
01/05/2016 0.10.0.0 - Beta
|
||||
Added recipe and Thaumonomicon entry for DPE.
|
||||
|
||||
@@ -129,7 +129,7 @@ public interface IAspectStack
|
||||
|
||||
/**
|
||||
* Sets the values of this stack to match the passed stack.
|
||||
* Unchanged if stack is null.
|
||||
* If the stack is null, all values are reset.
|
||||
*
|
||||
* @param stack
|
||||
*/
|
||||
|
||||
@@ -1113,7 +1113,7 @@ public class GuiArcaneCraftingTerminal
|
||||
// Create the clear grid button
|
||||
this.buttonList.add( new GuiButtonClearCraftingGrid( GuiConstants_ACT.BUTTON_CLEAR_GRID_ID, this.guiLeft +
|
||||
GuiConstants_ACT.BUTTON_CLEAR_GRID_POS_X, this.guiTop + GuiConstants_ACT.BUTTON_CLEAR_GRID_POS_Y +
|
||||
this.lowerTerminalYOffset, 8, 8 ) );
|
||||
this.lowerTerminalYOffset, 8, 8, true ) );
|
||||
|
||||
// Add sort order button
|
||||
this.buttonList.add( this.btnSortingMode = new GuiButtonSortingMode( GuiConstants_ACT.BUTTON_SORT_MODE_ID, this.guiLeft +
|
||||
@@ -1188,6 +1188,9 @@ public class GuiArcaneCraftingTerminal
|
||||
*/
|
||||
public void onReceiveFullList( final IItemList<IAEItemStack> itemList )
|
||||
{
|
||||
// Clear the repo
|
||||
this.repo.clear();
|
||||
|
||||
// Update the repository
|
||||
for( IAEItemStack stack : itemList )
|
||||
{
|
||||
|
||||
+24
-49
@@ -18,7 +18,7 @@ import thaumicenergistics.client.gui.abstraction.ThEBaseGui;
|
||||
import thaumicenergistics.client.gui.buttons.GuiButtonEncodePattern;
|
||||
import thaumicenergistics.client.textures.AEStateIconsEnum;
|
||||
import thaumicenergistics.client.textures.GuiTextureManager;
|
||||
import thaumicenergistics.common.container.ContainerDistillationEncoder;
|
||||
import thaumicenergistics.common.container.ContainerDistillationPatternEncoder;
|
||||
import thaumicenergistics.common.items.ItemCraftingAspect;
|
||||
import thaumicenergistics.common.network.packet.server.Packet_S_DistillationEncoder;
|
||||
import thaumicenergistics.common.registries.ThEStrings;
|
||||
@@ -27,7 +27,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiDistillationEncoder
|
||||
public class GuiDistillationPatternEncoder
|
||||
extends ThEBaseGui
|
||||
implements IInventoryUpdateReceiver
|
||||
{
|
||||
@@ -64,7 +64,7 @@ public class GuiDistillationEncoder
|
||||
/**
|
||||
* The GUI's container.
|
||||
*/
|
||||
private final ContainerDistillationEncoder deContainer;
|
||||
private final ContainerDistillationPatternEncoder deContainer;
|
||||
|
||||
/**
|
||||
* Thaumcraft's thaumometer
|
||||
@@ -81,25 +81,15 @@ public class GuiDistillationEncoder
|
||||
*/
|
||||
private GuiButtonEncodePattern buttonEncode;
|
||||
|
||||
/**
|
||||
* Hash code of the last itemstack.
|
||||
*/
|
||||
private int lastSourceItemHash = 0;
|
||||
|
||||
/**
|
||||
* Set true when the source item may have been changed.
|
||||
*/
|
||||
private boolean sourceItemDirty = false;
|
||||
|
||||
/**
|
||||
* Set false the first time the GUI is drawn.
|
||||
*/
|
||||
private boolean firstDraw = true;
|
||||
|
||||
public GuiDistillationEncoder( final EntityPlayer player, final World world, final int x, final int y, final int z )
|
||||
public GuiDistillationPatternEncoder( final EntityPlayer player, final World world, final int x, final int y, final int z )
|
||||
{
|
||||
// Call super
|
||||
super( new ContainerDistillationEncoder( player, world, x, y, z ) );
|
||||
super( new ContainerDistillationPatternEncoder( player, world, x, y, z ) );
|
||||
|
||||
// Set the title
|
||||
this.title = ThEStrings.Block_DistillationEncoder.getLocalized();
|
||||
@@ -109,7 +99,7 @@ public class GuiDistillationEncoder
|
||||
this.ySize = GUI_HEIGHT;
|
||||
|
||||
// Set the container
|
||||
this.deContainer = (ContainerDistillationEncoder)this.inventorySlots;
|
||||
this.deContainer = (ContainerDistillationPatternEncoder)this.inventorySlots;
|
||||
this.deContainer.slotUpdateReceiver = this;
|
||||
|
||||
}
|
||||
@@ -122,29 +112,16 @@ public class GuiDistillationEncoder
|
||||
// Clear the dirty bit
|
||||
this.sourceItemDirty = false;
|
||||
|
||||
// Get the source item
|
||||
ItemStack sourceItem = this.deContainer.slotSourceItem.getDisplayStack();
|
||||
|
||||
// Is there a stack?
|
||||
if( sourceItem == null )
|
||||
{
|
||||
// Reset hash
|
||||
this.lastSourceItemHash = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// Compare to last hash
|
||||
int hash = sourceItem.hashCode();
|
||||
if( hash == this.lastSourceItemHash )
|
||||
{
|
||||
// Same item
|
||||
return;
|
||||
}
|
||||
this.lastSourceItemHash = hash;
|
||||
|
||||
// Clear any existing particles
|
||||
this.particles.clear();
|
||||
|
||||
// Is there a source item to check?
|
||||
if( !this.deContainer.slotSourceItem.getHasStack() )
|
||||
{
|
||||
// Done
|
||||
return;
|
||||
}
|
||||
|
||||
// Check each slot
|
||||
boolean isItemScanned = false;
|
||||
for( Slot slot : this.deContainer.slotSourceAspects )
|
||||
@@ -213,9 +190,9 @@ public class GuiDistillationEncoder
|
||||
this.drawTexturedModalRect( this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize );
|
||||
|
||||
// Calculate the position and rotation of the thaumometer
|
||||
float th_PosX = this.guiLeft + ContainerDistillationEncoder.SLOT_SOURCE_ITEM_POS_X + ITEM_HALF_SIZE;
|
||||
float th_PosY = this.guiTop + ContainerDistillationEncoder.SLOT_SOURCE_ITEM_POS_Y - 0.25f + ITEM_HALF_SIZE;
|
||||
float th_Rotation = ( ( System.currentTimeMillis() % 36000 ) * 0.02f );
|
||||
float th_PosX = this.guiLeft + ContainerDistillationPatternEncoder.SLOT_SOURCE_ITEM_POS_X + ITEM_HALF_SIZE;
|
||||
float th_PosY = this.guiTop + ( ContainerDistillationPatternEncoder.SLOT_SOURCE_ITEM_POS_Y - 0.25f ) + ITEM_HALF_SIZE;
|
||||
float th_Rotation = ( System.currentTimeMillis() % 36000 ) * 0.02f;
|
||||
float th_ScaleOffset = (float)Math.sin( th_Rotation * 0.15f ) * 0.1f;
|
||||
|
||||
// Disable depth testing and push the matrix
|
||||
@@ -250,7 +227,7 @@ public class GuiDistillationEncoder
|
||||
this.fontRendererObj.drawString( this.title, TITLE_POS_X, TITLE_POS_Y, 0 );
|
||||
|
||||
// Check the source item
|
||||
if( this.sourceItemDirty && !this.firstDraw )
|
||||
if( this.sourceItemDirty )
|
||||
{
|
||||
this.checkSourceItem();
|
||||
}
|
||||
@@ -275,8 +252,6 @@ public class GuiDistillationEncoder
|
||||
EnumGuiParticles.finishDraw();
|
||||
}
|
||||
|
||||
this.firstDraw = false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -303,10 +278,11 @@ public class GuiDistillationEncoder
|
||||
@Override
|
||||
protected void onButtonClicked( final GuiButton button, final int mouseButton )
|
||||
{
|
||||
// Encode button?
|
||||
if( button == this.buttonEncode )
|
||||
{
|
||||
Packet_S_DistillationEncoder.sendEncodePattern(
|
||||
( (ContainerDistillationEncoder)this.inventorySlots ).getPlayer() );
|
||||
// Ask server to encode
|
||||
Packet_S_DistillationEncoder.sendEncodePattern( this.deContainer.getPlayer() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,15 +300,14 @@ public class GuiDistillationEncoder
|
||||
|
||||
// Reset flags
|
||||
this.sourceItemDirty = false;
|
||||
this.firstDraw = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the container when the source item has changed.
|
||||
*/
|
||||
@Override
|
||||
public void onInventoryChanged( final IInventory sourceInventory )
|
||||
{
|
||||
if( !this.sourceItemDirty && ( sourceInventory == this.deContainer.slotSourceItem.inventory ) )
|
||||
{
|
||||
this.sourceItemDirty = true;
|
||||
}
|
||||
this.sourceItemDirty = true;
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,8 @@ import thaumicenergistics.client.gui.buttons.GuiButtonViewType;
|
||||
import thaumicenergistics.client.gui.widget.ThEWidget;
|
||||
import thaumicenergistics.client.gui.widget.WidgetAspectSelector;
|
||||
import thaumicenergistics.client.textures.GuiTextureManager;
|
||||
import thaumicenergistics.common.container.ContainerEssentiaCellTerminalBase;
|
||||
import thaumicenergistics.common.container.ContainerEssentiaCell;
|
||||
import thaumicenergistics.common.container.ContainerEssentiaCellTerminalBase;
|
||||
import thaumicenergistics.common.container.ContainerEssentiaTerminal;
|
||||
import thaumicenergistics.common.container.ContainerWirelessEssentiaTerminal;
|
||||
import thaumicenergistics.common.inventory.HandlerWirelessEssentiaTerminal;
|
||||
@@ -298,6 +298,24 @@ public class GuiEssentiaCellTerminal
|
||||
mouseX, mouseY, this.guiLeft, this.guiTop );
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes our aspect list to match that of the container.
|
||||
*/
|
||||
private void onListUpdate()
|
||||
{
|
||||
// Update the scrollbar
|
||||
this.updateScrollMaximum();
|
||||
|
||||
// Update the search results
|
||||
this.updateView();
|
||||
|
||||
// Update the selected aspect
|
||||
this.updateSelectedAspect();
|
||||
|
||||
// Mark for widget update
|
||||
this.flagWidgetsNeedUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the scroll bar's range.
|
||||
*/
|
||||
@@ -322,6 +340,30 @@ public class GuiEssentiaCellTerminal
|
||||
this.flagWidgetsNeedUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes our selected aspect to match that of the container.
|
||||
*/
|
||||
private void updateSelectedAspect()
|
||||
{
|
||||
// No selection by default
|
||||
this.selectedAspectStack = null;
|
||||
|
||||
// Check all aspects
|
||||
for( IAspectStack aspectStack : this.baseContainer.getAspectStackList() )
|
||||
{
|
||||
// Does this match?
|
||||
if( aspectStack.getAspect() == this.baseContainer.getSelectedAspect() )
|
||||
{
|
||||
// Set our selection
|
||||
this.selectedAspectStack = aspectStack;
|
||||
|
||||
// Done
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the matching widgets based on the viewing conditions.
|
||||
*/
|
||||
@@ -655,16 +697,16 @@ public class GuiEssentiaCellTerminal
|
||||
*/
|
||||
public void drawWidgets( final int mouseX, final int mouseY )
|
||||
{
|
||||
// Do the widgets need to be updated?
|
||||
if( this.flagWidgetsNeedUpdate )
|
||||
{
|
||||
// Update first
|
||||
this.updateWidgets();
|
||||
}
|
||||
|
||||
// Anything to draw?
|
||||
if( !this.matchingSearchStacks.isEmpty() )
|
||||
{
|
||||
// Do the widgets need to be updated?
|
||||
if( this.flagWidgetsNeedUpdate )
|
||||
{
|
||||
// Update first
|
||||
this.updateWidgets();
|
||||
}
|
||||
|
||||
for( int widgetIndex = 0; widgetIndex < this.aspectWidgets.length; ++widgetIndex )
|
||||
{
|
||||
// Get the widget
|
||||
@@ -728,7 +770,7 @@ public class GuiEssentiaCellTerminal
|
||||
Keyboard.enableRepeatEvents( true );
|
||||
|
||||
// Get the aspect list
|
||||
this.updateAspects();
|
||||
this.onListUpdate();
|
||||
|
||||
// Set up the search bar
|
||||
this.searchBar = new GuiTextField( this.fontRendererObj,
|
||||
@@ -787,7 +829,7 @@ public class GuiEssentiaCellTerminal
|
||||
this.baseContainer.onReceivedAspectList( aspectStackList );
|
||||
|
||||
// Update the gui
|
||||
this.updateAspects();
|
||||
this.onListUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -801,7 +843,7 @@ public class GuiEssentiaCellTerminal
|
||||
if( this.baseContainer.onReceivedAspectListChange( change ) )
|
||||
{
|
||||
// Update the gui
|
||||
this.updateAspects();
|
||||
this.onListUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -853,46 +895,4 @@ public class GuiEssentiaCellTerminal
|
||||
this.flagWidgetsNeedUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes our aspect list to match that of the container.
|
||||
*/
|
||||
public void updateAspects()
|
||||
{
|
||||
// Update the scrollbar
|
||||
this.updateScrollMaximum();
|
||||
|
||||
// Update the search results
|
||||
this.updateView();
|
||||
|
||||
// Update the selected aspect
|
||||
this.updateSelectedAspect();
|
||||
|
||||
// Mark for widget update
|
||||
this.flagWidgetsNeedUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes our selected aspect to match that of the container.
|
||||
*/
|
||||
public void updateSelectedAspect()
|
||||
{
|
||||
// No selection by default
|
||||
this.selectedAspectStack = null;
|
||||
|
||||
// Check all aspects
|
||||
for( IAspectStack aspectStack : this.baseContainer.getAspectStackList() )
|
||||
{
|
||||
// Does this match?
|
||||
if( aspectStack.getAspect() == this.baseContainer.getSelectedAspect() )
|
||||
{
|
||||
// Set our selection
|
||||
this.selectedAspectStack = aspectStack;
|
||||
|
||||
// Done
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -375,7 +375,7 @@ public class GuiEssentiaIO
|
||||
}
|
||||
|
||||
// Request a full update from the server
|
||||
Packet_S_EssentiaIOBus.sendFullUpdateRequest( this.player, this.part );
|
||||
Packet_S_EssentiaIOBus.sendRequestFilterList( this.player, this.part );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
@@ -414,9 +413,6 @@ public class GuiEssentiaLevelEmitter
|
||||
this.buttonList.add( new GuiButtonRedstoneModes( GuiEssentiaLevelEmitter.REDSTONE_MODE_BUTTON_INDEX, this.guiLeft +
|
||||
GuiEssentiaLevelEmitter.REDSTONE_BUTTON_POS_X, this.guiTop + GuiEssentiaLevelEmitter.REDSTONE_BUTTON_POS_Y,
|
||||
GuiEssentiaLevelEmitter.REDSTONE_BUTTON_SIZE, GuiEssentiaLevelEmitter.REDSTONE_BUTTON_SIZE, RedstoneMode.LOW_SIGNAL, true ) );
|
||||
|
||||
// Request an update from the server
|
||||
Packet_S_EssentiaEmitter.sendUpdateRequest( this.part, this.player );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -434,7 +430,7 @@ public class GuiEssentiaLevelEmitter
|
||||
*
|
||||
* @param mode
|
||||
*/
|
||||
public void onServerUpdateRedstoneMode( final RedstoneMode mode )
|
||||
public void onReceiveRedstoneMode( final RedstoneMode mode )
|
||||
{
|
||||
( (GuiButtonRedstoneModes)this.buttonList.get( GuiEssentiaLevelEmitter.REDSTONE_MODE_BUTTON_INDEX ) ).setRedstoneMode( mode );
|
||||
}
|
||||
@@ -444,31 +440,11 @@ public class GuiEssentiaLevelEmitter
|
||||
*
|
||||
* @param amount
|
||||
*/
|
||||
public void onServerUpdateWantedAmount( final long amount )
|
||||
public void onReceiveThresholdValue( final long amount )
|
||||
{
|
||||
this.amountField.setText( Long.toString( amount ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tracked aspect based on the specified item.
|
||||
*
|
||||
* @param itemStack
|
||||
* @return
|
||||
*/
|
||||
public boolean setFilteredAspectFromItemstack( final ItemStack itemStack )
|
||||
{
|
||||
Aspect itemAspect = EssentiaItemContainerHelper.INSTANCE.getFilterAspectFromItem( itemStack );
|
||||
|
||||
if( itemAspect != null )
|
||||
{
|
||||
this.aspectFilterSlot.setAspect( itemAspect, 1, false );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the filtered aspect
|
||||
*/
|
||||
|
||||
@@ -41,12 +41,12 @@ public class GuiEssentiaStorageBus
|
||||
/**
|
||||
* The number of columns in the gui.
|
||||
*/
|
||||
private static final int COLUMNS = 3;
|
||||
private static final int WIDGET_COLUMNS = 3;
|
||||
|
||||
/**
|
||||
* The number of rows in the gui.
|
||||
*/
|
||||
private static final int ROWS = 3;
|
||||
private static final int WIDGET_ROWS = 3;
|
||||
|
||||
/**
|
||||
* The starting X position of the widgets.
|
||||
@@ -159,8 +159,8 @@ public class GuiEssentiaStorageBus
|
||||
this.hasNetworkTool = ( (ContainerPartEssentiaStorageBus)this.inventorySlots ).hasNetworkTool();
|
||||
|
||||
// Set the width and height
|
||||
this.xSize = ( this.hasNetworkTool ? GuiEssentiaStorageBus.GUI_WIDTH_NETWORK_TOOL : GuiEssentiaStorageBus.GUI_WIDTH_NO_TOOL );
|
||||
this.ySize = GuiEssentiaStorageBus.GUI_HEIGHT;
|
||||
this.xSize = ( this.hasNetworkTool ? GUI_WIDTH_NETWORK_TOOL : GUI_WIDTH_NO_TOOL );
|
||||
this.ySize = GUI_HEIGHT;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,7 +198,7 @@ public class GuiEssentiaStorageBus
|
||||
super.drawGuiContainerForegroundLayer( mouseX, mouseY );
|
||||
|
||||
// Draw the title
|
||||
this.fontRendererObj.drawString( this.guiTitle, GuiEssentiaStorageBus.TITLE_X_POS, GuiEssentiaStorageBus.TITLE_Y_POS, 0x000000 );
|
||||
this.fontRendererObj.drawString( this.guiTitle, TITLE_X_POS, TITLE_Y_POS, 0x000000 );
|
||||
|
||||
WidgetAspectSlot slotUnderMouse = null;
|
||||
|
||||
@@ -265,7 +265,7 @@ public class GuiEssentiaStorageBus
|
||||
protected void onButtonClicked( final GuiButton button, final int mouseButton )
|
||||
{
|
||||
// Was the priority button clicked?
|
||||
if( button.id == GuiEssentiaStorageBus.BUTTON_PRIORITY_ID )
|
||||
if( button.id == BUTTON_PRIORITY_ID )
|
||||
{
|
||||
// Get the storage buses host
|
||||
TileEntity host = this.storageBus.getHostTile();
|
||||
@@ -278,13 +278,13 @@ public class GuiEssentiaStorageBus
|
||||
host.getWorldObj(), host.xCoord, host.yCoord, host.zCoord );
|
||||
|
||||
}
|
||||
else if( button.id == GuiEssentiaStorageBus.BUTTON_ALLOW_VOID_ID )
|
||||
else if( button.id == BUTTON_ALLOW_VOID_ID )
|
||||
{
|
||||
// Toggle the mode
|
||||
this.isVoidAllowed = !this.isVoidAllowed;
|
||||
|
||||
// Update the button
|
||||
( (GuiButtonAllowVoid)this.buttonList.get( GuiEssentiaStorageBus.BUTTON_ALLOW_VOID_ID ) ).isVoidAllowed = this.isVoidAllowed;
|
||||
( (GuiButtonAllowVoid)this.buttonList.get( BUTTON_ALLOW_VOID_ID ) ).isVoidAllowed = this.isVoidAllowed;
|
||||
|
||||
// Update the server
|
||||
Packet_S_EssentiaStorageBus.setVoidAllowed( this.player, this.storageBus, this.isVoidAllowed );
|
||||
@@ -298,27 +298,24 @@ public class GuiEssentiaStorageBus
|
||||
super.initGui();
|
||||
|
||||
// Create the widgets
|
||||
for( int row = 0; row < GuiEssentiaStorageBus.ROWS; row++ )
|
||||
for( int row = 0; row < WIDGET_ROWS; row++ )
|
||||
{
|
||||
for( int column = 0; column < GuiEssentiaStorageBus.COLUMNS; column++ )
|
||||
for( int column = 0; column < WIDGET_COLUMNS; column++ )
|
||||
{
|
||||
this.aspectWidgetList.add( new WidgetAspectSlot( this, this.player, this.storageBus,
|
||||
( row * GuiEssentiaStorageBus.COLUMNS ) + column, GuiEssentiaStorageBus.WIDGET_X_POS +
|
||||
( ThEWidget.WIDGET_SIZE * column ), GuiEssentiaStorageBus.WIDGET_Y_POS +
|
||||
( ThEWidget.WIDGET_SIZE * row ) ) );
|
||||
( row * WIDGET_COLUMNS ) + column,
|
||||
WIDGET_X_POS + ( ThEWidget.WIDGET_SIZE * column ),
|
||||
WIDGET_Y_POS + ( ThEWidget.WIDGET_SIZE * row ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Create the priority tab button
|
||||
this.buttonList.add( new GuiButtonAETab( GuiEssentiaStorageBus.BUTTON_PRIORITY_ID, this.guiLeft +
|
||||
GuiEssentiaStorageBus.BUTTON_PRIORITY_X_POSITION, this.guiTop, AEStateIconsEnum.WRENCH, "gui.appliedenergistics2.Priority" ) );
|
||||
this.buttonList.add( new GuiButtonAETab( BUTTON_PRIORITY_ID, this.guiLeft +
|
||||
BUTTON_PRIORITY_X_POSITION, this.guiTop, AEStateIconsEnum.WRENCH, "gui.appliedenergistics2.Priority" ) );
|
||||
|
||||
// Create the allow void button
|
||||
this.buttonList.add( new GuiButtonAllowVoid( GuiEssentiaStorageBus.BUTTON_ALLOW_VOID_ID, this.guiLeft +
|
||||
GuiEssentiaStorageBus.BUTTON_ALLOW_VOID_X_POS, this.guiTop + GuiEssentiaStorageBus.BUTTON_ALLOW_VOID_Y_POS ) );
|
||||
|
||||
// Request an update
|
||||
Packet_S_EssentiaStorageBus.sendFullUpdateRequest( this.player, this.storageBus );
|
||||
this.buttonList.add( new GuiButtonAllowVoid( BUTTON_ALLOW_VOID_ID, this.guiLeft +
|
||||
BUTTON_ALLOW_VOID_X_POS, this.guiTop + BUTTON_ALLOW_VOID_Y_POS ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,7 +329,7 @@ public class GuiEssentiaStorageBus
|
||||
this.isVoidAllowed = isVoidAllowed;
|
||||
|
||||
// Update the button
|
||||
( (GuiButtonAllowVoid)this.buttonList.get( GuiEssentiaStorageBus.BUTTON_ALLOW_VOID_ID ) ).isVoidAllowed = this.isVoidAllowed;
|
||||
( (GuiButtonAllowVoid)this.buttonList.get( BUTTON_ALLOW_VOID_ID ) ).isVoidAllowed = this.isVoidAllowed;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import thaumicenergistics.client.gui.abstraction.ThEBaseGui;
|
||||
import thaumicenergistics.client.gui.buttons.GuiButtonClearCraftingGrid;
|
||||
import thaumicenergistics.client.gui.buttons.GuiButtonSaveDelete;
|
||||
import thaumicenergistics.client.textures.GuiTextureManager;
|
||||
import thaumicenergistics.common.ThaumicEnergistics;
|
||||
@@ -108,9 +109,14 @@ public class GuiKnowledgeInscriber
|
||||
private static final int GUI_WIDTH = 210, GUI_HEIGHT = 244;
|
||||
|
||||
/**
|
||||
* Save/Delete button.
|
||||
* Save/Delete button position.
|
||||
*/
|
||||
private static final int BUTTON_SAVE_ID = 0, BUTTON_SAVE_POS_X = 141, BUTTON_SAVE_POS_Y = 109;
|
||||
private static final int BUTTON_SAVE_POS_X = 141, BUTTON_SAVE_POS_Y = 109;
|
||||
|
||||
/**
|
||||
* Clear button position.
|
||||
*/
|
||||
private static final int BUTTON_CLEAR_POS_X = 80, BUTTON_CLEAR_POS_Y = 89;
|
||||
|
||||
/**
|
||||
* Position of the title string.
|
||||
@@ -120,7 +126,12 @@ public class GuiKnowledgeInscriber
|
||||
/**
|
||||
* Save / Delete button.
|
||||
*/
|
||||
private GuiButtonSaveDelete saveButton;
|
||||
private GuiButtonSaveDelete buttonSave;
|
||||
|
||||
/**
|
||||
* Clear grid button.
|
||||
*/
|
||||
private GuiButtonClearCraftingGrid buttonClear;
|
||||
|
||||
/**
|
||||
* GUI Title
|
||||
@@ -250,11 +261,16 @@ public class GuiKnowledgeInscriber
|
||||
protected void onButtonClicked( final GuiButton button, final int mouseButton )
|
||||
{
|
||||
// Was the clicked button the save button?
|
||||
if( button == this.saveButton )
|
||||
if( button == this.buttonSave )
|
||||
{
|
||||
// Send the request to the server
|
||||
Packet_S_KnowledgeInscriber.sendSaveDelete( this.player );
|
||||
}
|
||||
else if( button == this.buttonClear )
|
||||
{
|
||||
// Send the request to the server
|
||||
Packet_S_KnowledgeInscriber.sendClearGrid( this.player );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -266,9 +282,14 @@ public class GuiKnowledgeInscriber
|
||||
this.buttonList.clear();
|
||||
|
||||
// Create the save/delete button
|
||||
this.saveButton = new GuiButtonSaveDelete( GuiKnowledgeInscriber.BUTTON_SAVE_ID, this.guiLeft + GuiKnowledgeInscriber.BUTTON_SAVE_POS_X,
|
||||
this.guiTop + GuiKnowledgeInscriber.BUTTON_SAVE_POS_Y, this.saveState );
|
||||
this.buttonList.add( this.saveButton );
|
||||
this.buttonSave = new GuiButtonSaveDelete( 0, this.guiLeft + BUTTON_SAVE_POS_X,
|
||||
this.guiTop + BUTTON_SAVE_POS_Y, this.saveState );
|
||||
this.buttonList.add( this.buttonSave );
|
||||
|
||||
// Create the clear grid button
|
||||
this.buttonClear = new GuiButtonClearCraftingGrid( 1, this.guiLeft + BUTTON_CLEAR_POS_X,
|
||||
this.guiTop + BUTTON_CLEAR_POS_Y, 8, 8, false );
|
||||
this.buttonList.add( this.buttonClear );
|
||||
|
||||
// Request full update
|
||||
Packet_S_KnowledgeInscriber.sendFullUpdateRequest( this.player );
|
||||
@@ -287,9 +308,9 @@ public class GuiKnowledgeInscriber
|
||||
this.saveState = saveState;
|
||||
|
||||
// Update the button
|
||||
if( this.saveButton != null )
|
||||
if( this.buttonSave != null )
|
||||
{
|
||||
this.saveButton.setSaveState( saveState );
|
||||
this.buttonSave.setSaveState( saveState );
|
||||
}
|
||||
|
||||
// Was a pattern just saved?
|
||||
|
||||
+15
-4
@@ -1,8 +1,9 @@
|
||||
package thaumicenergistics.client.gui.buttons;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import thaumicenergistics.client.textures.AEStateIconsEnum;
|
||||
import thaumicenergistics.common.registries.ThEStrings;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -15,6 +16,8 @@ public class GuiButtonClearCraftingGrid
|
||||
*/
|
||||
private static final AEStateIconsEnum CLEAR_ICON = AEStateIconsEnum.CLEAR_GRID;
|
||||
|
||||
private final boolean showTooltip;
|
||||
|
||||
/**
|
||||
* Creates the button
|
||||
*
|
||||
@@ -24,16 +27,24 @@ public class GuiButtonClearCraftingGrid
|
||||
* @param width
|
||||
* @param height
|
||||
*/
|
||||
public GuiButtonClearCraftingGrid( final int ID, final int xPosition, final int yPosition, final int width, final int height )
|
||||
public GuiButtonClearCraftingGrid( final int ID, final int xPosition, final int yPosition, final int width, final int height,
|
||||
final boolean showTooltip )
|
||||
{
|
||||
// Call super
|
||||
super( ID, xPosition, yPosition, width, height, GuiButtonClearCraftingGrid.CLEAR_ICON, 0, 0, AEStateIconsEnum.REGULAR_BUTTON );
|
||||
|
||||
// Set if the tooltip is shown or not
|
||||
this.showTooltip = showTooltip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip( final List<String> tooltip )
|
||||
{
|
||||
// Add the tooltip text
|
||||
tooltip.add( ThEStrings.TooltipButton_DepositCraftingGrid.getLocalized() );
|
||||
if( this.showTooltip )
|
||||
{
|
||||
this.addAboutToTooltip( tooltip, ButtonToolTips.Stash.getLocal(),
|
||||
EnumChatFormatting.GRAY.toString() + ButtonToolTips.StashDesc.getLocal() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public abstract class AspectWidgetBase
|
||||
|
||||
/**
|
||||
* Cached footnote of the aspect.
|
||||
* NOTE: One day I hope to put the mod the aspect is from here,
|
||||
* NOTE: One day I hope to put what mod the aspect is from here,
|
||||
* not just its primallity.
|
||||
*/
|
||||
protected String aspectFootnote = "";
|
||||
|
||||
@@ -218,25 +218,6 @@ public class ThEGuiHandler
|
||||
return ID + side.ordinal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches an AE part gui
|
||||
*
|
||||
* @param part
|
||||
* @param player
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
*/
|
||||
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.doesPlayerHavePermissionToOpenGui( player ) )
|
||||
{
|
||||
player.openGui( ThaumicEnergistics.INSTANCE, part.getSide().ordinal(), world, x, y, z );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches a non AE part gui.
|
||||
*
|
||||
@@ -271,6 +252,25 @@ public class ThEGuiHandler
|
||||
ThEGuiHandler.extraData = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches an AE part gui
|
||||
*
|
||||
* @param part
|
||||
* @param player
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
*/
|
||||
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 ) )
|
||||
{
|
||||
player.openGui( ThaumicEnergistics.INSTANCE, part.getSide().ordinal(), world, x, y, z );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement( int ID, final EntityPlayer player, final World world, final int x, final int y, final int z )
|
||||
{
|
||||
@@ -316,7 +316,7 @@ public class ThEGuiHandler
|
||||
|
||||
// Distillation encoder?
|
||||
case ThEGuiHandler.DISTILLATION_ENCODER:
|
||||
return new GuiDistillationEncoder( player, world, x, y, z );
|
||||
return new GuiDistillationPatternEncoder( player, world, x, y, z );
|
||||
|
||||
// AE2 Autocrafting Amount?
|
||||
case ThEGuiHandler.AUTO_CRAFTING_AMOUNT:
|
||||
@@ -404,7 +404,7 @@ public class ThEGuiHandler
|
||||
|
||||
// Distillation encoder?
|
||||
case ThEGuiHandler.DISTILLATION_ENCODER:
|
||||
return new ContainerDistillationEncoder( player, world, x, y, z );
|
||||
return new ContainerDistillationPatternEncoder( player, world, x, y, z );
|
||||
|
||||
// AE2 Autocrafting Amount?
|
||||
case ThEGuiHandler.AUTO_CRAFTING_AMOUNT:
|
||||
|
||||
@@ -17,7 +17,7 @@ import thaumicenergistics.client.textures.BlockTextureManager;
|
||||
import thaumicenergistics.common.ThEGuiHandler;
|
||||
import thaumicenergistics.common.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.registries.BlockEnum;
|
||||
import thaumicenergistics.common.tiles.TileDistillationEncoder;
|
||||
import thaumicenergistics.common.tiles.TileDistillationPatternEncoder;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -61,10 +61,10 @@ public class BlockDistillationEncoder
|
||||
// Get the tile
|
||||
TileEntity tile = world.getTileEntity( x, y, z );
|
||||
|
||||
if( tile instanceof TileDistillationEncoder )
|
||||
if( tile instanceof TileDistillationPatternEncoder )
|
||||
{
|
||||
// Cast
|
||||
TileDistillationEncoder tileDE = (TileDistillationEncoder)tile;
|
||||
TileDistillationPatternEncoder tileDE = (TileDistillationPatternEncoder)tile;
|
||||
|
||||
// Does it have patterns?
|
||||
if( tileDE.hasPatterns() )
|
||||
@@ -90,7 +90,7 @@ public class BlockDistillationEncoder
|
||||
@Override
|
||||
public TileEntity createNewTileEntity( final World world, final int metaData )
|
||||
{
|
||||
return new TileDistillationEncoder();
|
||||
return new TileDistillationPatternEncoder();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+288
-231
@@ -1,11 +1,12 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
@@ -13,15 +14,16 @@ import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.lib.research.ScanManager;
|
||||
import thaumicenergistics.api.storage.IInventoryUpdateReceiver;
|
||||
import thaumicenergistics.common.container.slot.SlotRestrictive;
|
||||
import thaumicenergistics.common.inventory.TheInternalInventory;
|
||||
import thaumicenergistics.common.items.ItemCraftingAspect;
|
||||
import thaumicenergistics.common.registries.ItemEnum;
|
||||
import thaumicenergistics.common.tiles.TileDistillationEncoder;
|
||||
import thaumicenergistics.common.tiles.TileDistillationPatternEncoder;
|
||||
import thaumicenergistics.common.utils.DistillationPatternHelper;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.container.slot.SlotFake;
|
||||
|
||||
public class ContainerDistillationEncoder
|
||||
public class ContainerDistillationPatternEncoder
|
||||
extends ContainerWithPlayerInventory
|
||||
{
|
||||
/**
|
||||
@@ -37,7 +39,7 @@ public class ContainerDistillationEncoder
|
||||
/**
|
||||
* Starting position of the source aspect slots
|
||||
*/
|
||||
private static final int SLOT_SOURCE_ASPECTS_POS_X = 65, SLOT_SOURCE_ASPECTS_POS_Y = 24;
|
||||
private static final int SLOT_SOURCE_ASPECTS_POS_X = 65, SLOT_SOURCE_ASPECTS_POS_Y = 24, SLOT_SOURCE_ASPECTS_COUNT = 6;
|
||||
|
||||
/**
|
||||
* Position of the save aspect.
|
||||
@@ -57,12 +59,37 @@ public class ContainerDistillationEncoder
|
||||
/**
|
||||
* Player who opened the GUI.
|
||||
*/
|
||||
protected EntityPlayer player;
|
||||
private final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Host encoder.
|
||||
*/
|
||||
protected TileDistillationEncoder encoder;
|
||||
private final TileDistillationPatternEncoder encoder;
|
||||
|
||||
/**
|
||||
* Slot holding the selected aspect.
|
||||
*/
|
||||
private final SlotFake slotSelectedAspect;
|
||||
|
||||
/**
|
||||
* Blank patterns slot.
|
||||
*/
|
||||
private final SlotRestrictive slotPatternsBlank;
|
||||
|
||||
/**
|
||||
* Encoded pattern slot.
|
||||
*/
|
||||
private final SlotRestrictive slotPatternEncoded;
|
||||
|
||||
/**
|
||||
* Pattern helper
|
||||
*/
|
||||
private final DistillationPatternHelper patternHelper;
|
||||
|
||||
/**
|
||||
* Stores the aspects for the source item.
|
||||
*/
|
||||
private final TheInternalInventory internalInventory;
|
||||
|
||||
/**
|
||||
* Slot holding the source item.
|
||||
@@ -72,27 +99,7 @@ public class ContainerDistillationEncoder
|
||||
/**
|
||||
* Slots holding the source item's aspects.
|
||||
*/
|
||||
public final SlotFake[] slotSourceAspects = new SlotFake[TileDistillationEncoder.SLOT_SOURCE_ASPECTS_COUNT];
|
||||
|
||||
/**
|
||||
* Slot holding the selected aspect.
|
||||
*/
|
||||
protected SlotFake slotSelectedAspect;
|
||||
|
||||
/**
|
||||
* Blank patterns slot.
|
||||
*/
|
||||
protected SlotRestrictive slotPatternsBlank;
|
||||
|
||||
/**
|
||||
* Encoded pattern slot.
|
||||
*/
|
||||
protected SlotRestrictive slotPatternEncoded;
|
||||
|
||||
/**
|
||||
* Pattern helper
|
||||
*/
|
||||
protected DistillationPatternHelper patternHelper;
|
||||
public final SlotFake[] slotSourceAspects = new SlotFake[SLOT_SOURCE_ASPECTS_COUNT];
|
||||
|
||||
/**
|
||||
* Gui to send updates to when slots change.
|
||||
@@ -108,45 +115,52 @@ public class ContainerDistillationEncoder
|
||||
* @param y
|
||||
* @param z
|
||||
*/
|
||||
public ContainerDistillationEncoder( final EntityPlayer player, final World world, final int x, final int y, final int z )
|
||||
public ContainerDistillationPatternEncoder( final EntityPlayer player, final World world, final int x, final int y, final int z )
|
||||
{
|
||||
// Set the player
|
||||
this.player = player;
|
||||
|
||||
// Get the encoder
|
||||
this.encoder = (TileDistillationEncoder)world.getTileEntity( x, y, z );
|
||||
this.encoder = (TileDistillationPatternEncoder)world.getTileEntity( x, y, z );
|
||||
|
||||
// Add the source item slot
|
||||
this.slotSourceItem = new SlotFake( this.encoder, TileDistillationEncoder.SLOT_SOURCE_ITEM, SLOT_SOURCE_ITEM_POS_X, SLOT_SOURCE_ITEM_POS_Y );
|
||||
this.addSlotToContainer( this.slotSourceItem );
|
||||
// Create the internal inventory
|
||||
this.internalInventory = new TheInternalInventory( "dpeAspects", 7, 64 )
|
||||
{
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int slotIndex, final ItemStack itemStack )
|
||||
{
|
||||
return( ( itemStack == null ) || ( itemStack.getItem() instanceof ItemCraftingAspect ) );
|
||||
}
|
||||
};
|
||||
|
||||
// Add the source aspect slots
|
||||
for( int index = 0; index < this.slotSourceAspects.length; ++index )
|
||||
for( int index = 0; index < SLOT_SOURCE_ASPECTS_COUNT; ++index )
|
||||
{
|
||||
// Calculate Y
|
||||
int posY = SLOT_SOURCE_ASPECTS_POS_Y + ( index * 18 );
|
||||
|
||||
// Create the slot
|
||||
this.slotSourceAspects[index] = new SlotFake( this.encoder, TileDistillationEncoder.SLOT_SOURCE_ASPECTS + index,
|
||||
SLOT_SOURCE_ASPECTS_POS_X,
|
||||
posY );
|
||||
|
||||
// Add it
|
||||
this.slotSourceAspects[index] = new SlotFake( this.internalInventory, index, SLOT_SOURCE_ASPECTS_POS_X, posY );
|
||||
this.addSlotToContainer( this.slotSourceAspects[index] );
|
||||
}
|
||||
|
||||
// Add the selected aspect slot
|
||||
this.slotSelectedAspect = new SlotFake( this.encoder, TileDistillationEncoder.SLOT_SELECTED_ASPECT, SLOT_SELECTED_ASPECT_POS_X,
|
||||
this.slotSelectedAspect = new SlotFake( this.internalInventory, SLOT_SOURCE_ASPECTS_COUNT, SLOT_SELECTED_ASPECT_POS_X,
|
||||
SLOT_SELECTED_ASPECT_POS_Y );
|
||||
this.addSlotToContainer( this.slotSelectedAspect );
|
||||
|
||||
// Add the source item slot
|
||||
this.slotSourceItem = new SlotFake( this.encoder, TileDistillationPatternEncoder.SLOT_SOURCE_ITEM, SLOT_SOURCE_ITEM_POS_X,
|
||||
SLOT_SOURCE_ITEM_POS_Y );
|
||||
this.addSlotToContainer( this.slotSourceItem );
|
||||
|
||||
// Add blank pattern slot
|
||||
this.slotPatternsBlank = new SlotRestrictive( this.encoder, TileDistillationEncoder.SLOT_BLANK_PATTERNS,
|
||||
this.slotPatternsBlank = new SlotRestrictive( this.encoder, TileDistillationPatternEncoder.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( this.encoder, TileDistillationEncoder.SLOT_ENCODED_PATTERN,
|
||||
this.slotPatternEncoded = new SlotRestrictive( this.encoder, TileDistillationPatternEncoder.SLOT_ENCODED_PATTERN,
|
||||
SLOT_PATTERN_ENCODED_POS_X, SLOT_PATTERN_ENCODED_POS_Y );
|
||||
this.addSlotToContainer( this.slotPatternEncoded );
|
||||
|
||||
@@ -159,84 +173,124 @@ public class ContainerDistillationEncoder
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a pattern is loaded from the encoded pattern slot.
|
||||
* Clears all aspect slots.
|
||||
*/
|
||||
protected void onLoadedPattern()
|
||||
private void clearAspectSlots()
|
||||
{
|
||||
// Set the source item
|
||||
this.setSourceItem( this.patternHelper.getInput() );
|
||||
|
||||
// Set the selected aspect
|
||||
this.setSelectedAspect( this.patternHelper.getOutput() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set's the selected aspect stack.
|
||||
*
|
||||
* @param aspectStack
|
||||
*/
|
||||
protected void setSelectedAspect( final ItemStack aspectStack )
|
||||
{
|
||||
// Clear the stack
|
||||
this.slotSelectedAspect.clearStack();
|
||||
|
||||
// Is there anything to put?
|
||||
if( aspectStack == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Does the stack have an aspect?
|
||||
Aspect aspect = ItemCraftingAspect.getAspect( aspectStack );
|
||||
if( aspect == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Has the player discovered this aspect?
|
||||
if( !ItemCraftingAspect.canPlayerSeeAspect( this.player, aspect ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the aspect
|
||||
this.slotSelectedAspect.putStack( aspectStack.copy() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source item and updates aspects.
|
||||
*/
|
||||
protected void setSourceItem( final ItemStack sourceStack )
|
||||
{
|
||||
// Ignored on client side
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear slots
|
||||
this.slotSourceItem.clearStack();
|
||||
this.slotSelectedAspect.clearStack();
|
||||
for( int index = 0; index < this.slotSourceAspects.length; ++index )
|
||||
{
|
||||
this.slotSourceAspects[index].clearStack();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the slot needs to be sync'd
|
||||
*
|
||||
* @param slot
|
||||
* @return
|
||||
*/
|
||||
private boolean doesSlotNeedSync( final Slot slot )
|
||||
{
|
||||
ItemStack slotStack = slot.getStack();
|
||||
ItemStack invStack = (ItemStack)this.inventoryItemStacks.get( slot.slotNumber );
|
||||
|
||||
return !ItemStack.areItemStacksEqual( invStack, slotStack );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the transfer was handled.
|
||||
* Assumes that clickedslot has an itemstack.
|
||||
*
|
||||
* @param clickedSlot
|
||||
* @return
|
||||
*/
|
||||
private boolean handleSlotTransfer( @Nonnull final Slot clickedSlot )
|
||||
{
|
||||
// Get the stack
|
||||
ItemStack slotStack = clickedSlot.getStack();
|
||||
|
||||
// Is the slot in the player inventory?
|
||||
if( clickedSlot.inventory == this.player.inventory )
|
||||
{
|
||||
// Will the blank pattern slot take this?
|
||||
if( this.slotPatternsBlank.isItemValid( slotStack ) )
|
||||
{
|
||||
return this.mergeItemStack( slotStack, this.slotPatternsBlank.slotNumber, this.slotPatternsBlank.slotNumber + 1, false );
|
||||
}
|
||||
|
||||
// Will the encoded pattern take this?
|
||||
if( this.slotPatternEncoded.isItemValid( slotStack ) )
|
||||
{
|
||||
return this.mergeItemStack( slotStack, this.slotPatternEncoded.slotNumber, this.slotPatternEncoded.slotNumber + 1, false );
|
||||
}
|
||||
// Set the source slot
|
||||
this.slotSourceItem.putStack( slotStack );
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// Pattern slot?
|
||||
if( ( ( this.slotPatternsBlank == clickedSlot ) || ( this.slotPatternEncoded == clickedSlot ) ) )
|
||||
{
|
||||
// Merge with the hotbar?
|
||||
if( !this.mergeSlotWithHotbarInventory( slotStack ) )
|
||||
{
|
||||
// Merge with the player inventory
|
||||
return this.mergeSlotWithPlayerInventory( slotStack );
|
||||
}
|
||||
// Merged with hotbar
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to load a pattern in the encoded slot.
|
||||
*/
|
||||
private void loadPattern()
|
||||
{
|
||||
// Read the pattern
|
||||
this.patternHelper.readPattern( this.slotPatternEncoded.getStack() );
|
||||
|
||||
// Is the pattern valid?
|
||||
if( this.patternHelper.isValid() )
|
||||
{
|
||||
// Set the source item
|
||||
this.slotSourceItem.putStack( this.patternHelper.getInput() );
|
||||
this.scanSourceItem( false );
|
||||
|
||||
// Set the selected aspect
|
||||
this.setSelectedAspect( this.patternHelper.getOutput() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the source item has changed.
|
||||
*
|
||||
* @param setSelectedAspect
|
||||
*/
|
||||
private void scanSourceItem( final boolean setSelectedAspect )
|
||||
{
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
// Ignored client side
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear aspect slots
|
||||
this.clearAspectSlots();
|
||||
|
||||
// Null?
|
||||
if( sourceStack == null )
|
||||
if( !this.slotSourceItem.getHasStack() )
|
||||
{
|
||||
// Done
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy the itemstack
|
||||
ItemStack sourceItem = sourceStack.copy();
|
||||
|
||||
// Set size to 1
|
||||
sourceItem.stackSize = 1;
|
||||
|
||||
// Set the source item
|
||||
this.slotSourceItem.putStack( sourceItem );
|
||||
// Get the itemstack
|
||||
ItemStack sourceItem = this.slotSourceItem.getDisplayStack();
|
||||
|
||||
// Get the aspects
|
||||
AspectList itemAspects = ThaumcraftApiHelper.getObjectAspects( sourceItem );
|
||||
@@ -292,22 +346,82 @@ public class ContainerDistillationEncoder
|
||||
this.slotSourceAspects[i].putStack( aspectItem );
|
||||
|
||||
// Selected aspect empty?
|
||||
if( playerScanned && ( !this.slotSelectedAspect.getHasStack() ) )
|
||||
if( setSelectedAspect && playerScanned && !this.slotSelectedAspect.getHasStack() )
|
||||
{
|
||||
// Attempt to place into selected
|
||||
// Set selected
|
||||
this.setSelectedAspect( aspectItem );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Can interact with any real player.
|
||||
* Set's the selected aspect stack.
|
||||
*
|
||||
* @param aspectStack
|
||||
*/
|
||||
protected void setSelectedAspect( final ItemStack aspectStack )
|
||||
{
|
||||
// Clear the stack
|
||||
this.slotSelectedAspect.clearStack();
|
||||
|
||||
// Is there anything to put?
|
||||
if( aspectStack == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Does the stack have an aspect?
|
||||
Aspect aspect = ItemCraftingAspect.getAspect( aspectStack );
|
||||
if( aspect == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Has the player discovered this aspect?
|
||||
if( ItemCraftingAspect.canPlayerSeeAspect( this.player, aspect ) )
|
||||
{
|
||||
// Set the selected aspect to unknown
|
||||
this.slotSelectedAspect.putStack( ItemEnum.CRAFTING_ASPECT.getStack() );
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the aspect
|
||||
this.slotSelectedAspect.putStack( aspectStack.copy() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
return !( player instanceof FakePlayer );
|
||||
if( this.encoder != null )
|
||||
{
|
||||
return this.encoder.isUseableByPlayer( player );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if( this.player instanceof EntityPlayerMP )
|
||||
{
|
||||
// Does the pattern slot need to be sync'd?
|
||||
if( this.doesSlotNeedSync( this.slotPatternEncoded ) )
|
||||
{
|
||||
// Load the pattern
|
||||
this.loadPattern();
|
||||
( (EntityPlayerMP)this.player ).isChangingQuantityOnly = false;
|
||||
}
|
||||
// Does the source item need to be sync'd?
|
||||
else if( this.doesSlotNeedSync( this.slotSourceItem ) )
|
||||
{
|
||||
// Scan the source item
|
||||
this.scanSourceItem( true );
|
||||
( (EntityPlayerMP)this.player ).isChangingQuantityOnly = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Lastly call super
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,9 +485,6 @@ public class ContainerDistillationEncoder
|
||||
// Decrement the blank patterns
|
||||
this.slotPatternsBlank.decrStackSize( 1 );
|
||||
}
|
||||
|
||||
// Update
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -382,80 +493,16 @@ public class ContainerDistillationEncoder
|
||||
// Call super
|
||||
super.putStackInSlot( slotNumber, stack );
|
||||
|
||||
// Call receiver
|
||||
if( EffectiveSide.isClientSide() && ( this.slotUpdateReceiver != null ) )
|
||||
// Source item changed?
|
||||
if( ( this.slotUpdateReceiver != null ) && ( this.slotSourceItem.slotNumber == slotNumber ) )
|
||||
{
|
||||
this.slotUpdateReceiver.onInventoryChanged( this.getSlot( slotNumber ).inventory );
|
||||
this.slotUpdateReceiver.onInventoryChanged( this.slotSourceItem.inventory );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick( final int slotNumber, final int buttonPressed, final int flag, final EntityPlayer player )
|
||||
{
|
||||
// Source item slot?
|
||||
if( this.slotSourceItem.slotNumber == slotNumber )
|
||||
{
|
||||
// Get the item the player is dragging
|
||||
ItemStack heldItem = player.inventory.getItemStack();
|
||||
|
||||
// Set the source slot
|
||||
this.setSourceItem( heldItem );
|
||||
|
||||
// Update
|
||||
this.detectAndSendChanges();
|
||||
|
||||
// Done
|
||||
return null;
|
||||
}
|
||||
|
||||
// One of the source aspect slots?
|
||||
for( int index = 0; index < this.slotSourceAspects.length; ++index )
|
||||
{
|
||||
if( this.slotSourceAspects[index].slotNumber == slotNumber )
|
||||
{
|
||||
if( this.slotSourceAspects[index].getHasStack() )
|
||||
{
|
||||
// Place it into the selected
|
||||
this.setSelectedAspect( this.slotSourceAspects[index].getStack() );
|
||||
|
||||
// Update
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
// Done
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Encoded pattern slot?
|
||||
if( this.slotPatternEncoded.slotNumber == slotNumber )
|
||||
{
|
||||
// Is the slot empty?
|
||||
if( !this.slotPatternEncoded.getHasStack() )
|
||||
{
|
||||
// Get the item the player is dragging
|
||||
ItemStack heldItem = player.inventory.getItemStack();
|
||||
|
||||
// Attempt to load it
|
||||
this.patternHelper.readPattern( heldItem );
|
||||
|
||||
// Valid pattern?
|
||||
if( this.patternHelper.isValid() )
|
||||
{
|
||||
// Load the pattern
|
||||
this.onLoadedPattern();
|
||||
|
||||
// Update
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Don't allow this pattern
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Selected aspect?
|
||||
if( this.slotSelectedAspect.slotNumber == slotNumber )
|
||||
{
|
||||
@@ -463,13 +510,63 @@ public class ContainerDistillationEncoder
|
||||
return null;
|
||||
}
|
||||
|
||||
// If true detect will be called, and null returned.
|
||||
boolean handled = false;
|
||||
|
||||
// Source item slot?
|
||||
if( this.slotSourceItem.slotNumber == slotNumber )
|
||||
{
|
||||
// Get the item the player is dragging
|
||||
ItemStack heldItem = player.inventory.getItemStack();
|
||||
|
||||
// Set the source slot
|
||||
this.slotSourceItem.putStack( heldItem );
|
||||
|
||||
handled = true;
|
||||
}
|
||||
|
||||
// One of the source aspect slots?
|
||||
if( !handled )
|
||||
{
|
||||
for( int index = 0; index < this.slotSourceAspects.length; ++index )
|
||||
{
|
||||
if( this.slotSourceAspects[index].slotNumber == slotNumber )
|
||||
{
|
||||
if( this.slotSourceAspects[index].getHasStack() )
|
||||
{
|
||||
// Place it into the selected
|
||||
this.setSelectedAspect( this.slotSourceAspects[index].getStack() );
|
||||
}
|
||||
|
||||
// Done
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Was the click handled?
|
||||
if( handled )
|
||||
{
|
||||
// Detect any changes
|
||||
this.detectAndSendChanges();
|
||||
|
||||
// Done
|
||||
return null;
|
||||
}
|
||||
|
||||
// Call super
|
||||
return super.slotClick( slotNumber, buttonPressed, flag, player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot( final EntityPlayer player, final int slotNumber )
|
||||
{
|
||||
boolean handled = false;
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
// Ignored client side
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the slot
|
||||
Slot clickedSlot = this.getSlot( slotNumber );
|
||||
@@ -481,65 +578,25 @@ public class ContainerDistillationEncoder
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the stack
|
||||
ItemStack slotStack = clickedSlot.getStack();
|
||||
|
||||
// Is the slot in the player inventory?
|
||||
if( clickedSlot.inventory == this.player.inventory )
|
||||
{
|
||||
// Will the blank pattern slot take this?
|
||||
if( this.slotPatternsBlank.isItemValid( slotStack ) )
|
||||
{
|
||||
handled = this.mergeItemStack( slotStack, this.slotPatternsBlank.slotNumber, this.slotPatternsBlank.slotNumber + 1, false );
|
||||
}
|
||||
|
||||
// Will the encoded pattern take this?
|
||||
if( !handled && this.slotPatternEncoded.isItemValid( slotStack ) )
|
||||
{
|
||||
// Attempt to load the pattern
|
||||
this.patternHelper.readPattern( slotStack );
|
||||
if( this.patternHelper.isValid() )
|
||||
{
|
||||
handled = this.mergeItemStack( slotStack, this.slotPatternEncoded.slotNumber, this.slotPatternEncoded.slotNumber + 1, false );
|
||||
if( handled )
|
||||
{
|
||||
this.onLoadedPattern();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !handled )
|
||||
{
|
||||
// Set the source slot
|
||||
this.setSourceItem( slotStack );
|
||||
|
||||
handled = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Pattern slot?
|
||||
if( ( !handled ) && ( ( this.slotPatternsBlank.slotNumber == slotNumber ) || ( this.slotPatternEncoded.slotNumber == slotNumber ) ) )
|
||||
{
|
||||
handled = this.mergeSlotWithHotbarInventory( slotStack );
|
||||
|
||||
if( !handled )
|
||||
{
|
||||
handled = this.mergeSlotWithPlayerInventory( slotStack );
|
||||
}
|
||||
}
|
||||
|
||||
// Was this handled?
|
||||
if( handled )
|
||||
if( this.handleSlotTransfer( clickedSlot ) )
|
||||
{
|
||||
if( slotStack.stackSize <= 0 )
|
||||
// Was the itemstack in the slot drained?
|
||||
if( clickedSlot.getHasStack() && ( clickedSlot.getStack().stackSize <= 0 ) )
|
||||
{
|
||||
// Set to null
|
||||
clickedSlot.putStack( null );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Let the slot know it has changed.
|
||||
clickedSlot.onSlotChanged();
|
||||
}
|
||||
|
||||
// Update
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,8 @@ public class ContainerEssentiaCell
|
||||
*/
|
||||
private ISaveProvider chestSaveProvider;
|
||||
|
||||
private Aspect tmpSelectedAspect;
|
||||
|
||||
/**
|
||||
* Import and export inventory slots.
|
||||
*/
|
||||
@@ -181,6 +183,28 @@ public class ContainerEssentiaCell
|
||||
return this.playerSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Aspect getHostSelectedAspect()
|
||||
{
|
||||
return this.tmpSelectedAspect;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setHostSelectedAspect( final Aspect aspect )
|
||||
{
|
||||
this.tmpSelectedAspect = aspect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
if( this.hostChest != null )
|
||||
{
|
||||
return this.hostChest.isUseableByPlayer( player );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfers essentia.
|
||||
*/
|
||||
|
||||
+60
-39
@@ -100,46 +100,51 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
private static int OUTPUT_INV_INDEX = 1, INPUT_INV_INDEX = 0;
|
||||
|
||||
/**
|
||||
* Essentia network monitor
|
||||
* Location of the splash sound
|
||||
*/
|
||||
protected IMEEssentiaMonitor monitor;
|
||||
private final String soundLocation_Splash = "game.neutral.swim";
|
||||
|
||||
/**
|
||||
* List of aspects on the network
|
||||
* Location of the paper sound
|
||||
*/
|
||||
protected final IEssentiaRepo repo;
|
||||
|
||||
/**
|
||||
* The aspect the user has selected.
|
||||
*/
|
||||
protected Aspect selectedAspect;
|
||||
|
||||
/**
|
||||
* The player that owns this container.
|
||||
*/
|
||||
protected EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Import and export inventory
|
||||
*/
|
||||
protected IInventory inventory;
|
||||
private final String soundLocation_Paper = "thaumcraft:page";
|
||||
|
||||
/**
|
||||
* The last known stack size stored in the export slot
|
||||
*/
|
||||
private int audioStackSizeTracker = 0;
|
||||
|
||||
/**
|
||||
* Work slots
|
||||
*/
|
||||
private Slot inputSlot;
|
||||
|
||||
/**
|
||||
* Import and export inventory
|
||||
*/
|
||||
private IInventory inventory;
|
||||
|
||||
/**
|
||||
* The last time, in ms, the transfer sound played
|
||||
*/
|
||||
private long lastSoundPlaytime = 0;
|
||||
|
||||
/**
|
||||
* Work slots
|
||||
*/
|
||||
private Slot outputSlot;
|
||||
|
||||
/**
|
||||
* Holds a list of changes sent to the gui before the
|
||||
* full list is sent.
|
||||
*/
|
||||
private List<IAspectStack> pendingChanges = new ArrayList<IAspectStack>();
|
||||
|
||||
/**
|
||||
* The aspect the user has selected.
|
||||
*/
|
||||
private Aspect selectedAspect;
|
||||
|
||||
/**
|
||||
* Tracks the number of ticks
|
||||
*/
|
||||
@@ -151,19 +156,19 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
private int workCounter = 0;
|
||||
|
||||
/**
|
||||
* Work slots
|
||||
* List of aspects on the network
|
||||
*/
|
||||
private Slot inputSlot, outputSlot;
|
||||
protected final IEssentiaRepo repo;
|
||||
|
||||
/**
|
||||
* Location of the splash sound
|
||||
* The player that owns this container.
|
||||
*/
|
||||
private final String soundLocation_Splash = "game.neutral.swim";
|
||||
protected final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Location of the paper sound
|
||||
* Essentia network monitor
|
||||
*/
|
||||
private final String soundLocation_Paper = "thaumcraft:page";
|
||||
protected IMEEssentiaMonitor monitor;
|
||||
|
||||
/**
|
||||
* Set to true once a full list request is sent to the server.
|
||||
@@ -469,6 +474,21 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
*/
|
||||
protected abstract BaseActionSource getActionSource();
|
||||
|
||||
/**
|
||||
* Return the selected aspect stored in the host.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract Aspect getHostSelectedAspect();
|
||||
|
||||
/**
|
||||
* Sets the hosts selected aspect.
|
||||
*
|
||||
* @param aspect
|
||||
*/
|
||||
protected abstract void setHostSelectedAspect( @Nullable Aspect aspect );
|
||||
|
||||
/**
|
||||
* Fills, drains, or sets label aspect.
|
||||
*
|
||||
@@ -636,15 +656,6 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
while( this.workCounter < ESSENTIA_TRANSFER_PER_WORK_CYCLE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Who can interact with the container?
|
||||
*/
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is any work to perform.
|
||||
* If there is it does so.
|
||||
@@ -666,6 +677,16 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
// Reset the tick counter
|
||||
this.tickCounter = 0;
|
||||
}
|
||||
|
||||
// Compare selected aspects
|
||||
if( this.getHostSelectedAspect() != this.selectedAspect )
|
||||
{
|
||||
// Update the selected aspect
|
||||
this.selectedAspect = this.getHostSelectedAspect();
|
||||
|
||||
// Send the change back to the client
|
||||
Packet_C_EssentiaCellTerminal.setSelectedAspect( this.player, this.selectedAspect );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -907,14 +928,14 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
*/
|
||||
public void onReceivedSelectedAspect( final Aspect selectedAspect )
|
||||
{
|
||||
// Set the selected aspect
|
||||
this.selectedAspect = selectedAspect;
|
||||
|
||||
// Is this server side?
|
||||
if( EffectiveSide.isServerSide() )
|
||||
{
|
||||
// Send the change back to the client
|
||||
Packet_C_EssentiaCellTerminal.setSelectedAspect( this.player, this.selectedAspect );
|
||||
this.setHostSelectedAspect( selectedAspect );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.selectedAspect = selectedAspect;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-8
@@ -1,11 +1,13 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.common.container.slot.SlotRestrictive;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_AspectSlot;
|
||||
import thaumicenergistics.common.tiles.TileEssentiaCellWorkbench;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import thaumicenergistics.integration.tc.EssentiaItemContainerHelper;
|
||||
@@ -65,23 +67,27 @@ public class ContainerEssentiaCellWorkbench
|
||||
// Register with the workbench
|
||||
if( EffectiveSide.isServerSide() )
|
||||
{
|
||||
this.workbench.registerContainer( this );
|
||||
this.workbench.registerListener( this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
if( this.workbench != null )
|
||||
{
|
||||
return this.workbench.isUseableByPlayer( player );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the cell in the workbench changes.
|
||||
* Called when a client has requested the full list.
|
||||
*/
|
||||
public void onCellChanged()
|
||||
public void onClientRequestPartitionList()
|
||||
{
|
||||
// Update the client.
|
||||
this.workbench.onClientRequestPartitionList( this.player );
|
||||
this.onPartitionChanged( this.workbench.getPartitionList() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,7 +98,7 @@ public class ContainerEssentiaCellWorkbench
|
||||
|
||||
if( EffectiveSide.isServerSide() )
|
||||
{
|
||||
this.workbench.removeContainer( this );
|
||||
this.workbench.removeListener( this );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +111,15 @@ public class ContainerEssentiaCellWorkbench
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the partition list changes.
|
||||
*/
|
||||
public void onPartitionChanged( final ArrayList<Aspect> partitionList )
|
||||
{
|
||||
// Send to client
|
||||
Packet_C_AspectSlot.setFilterList( partitionList, this.player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot( final EntityPlayer player, final int slotNumber )
|
||||
{
|
||||
@@ -163,7 +178,7 @@ public class ContainerEssentiaCellWorkbench
|
||||
if( slotAspect != null )
|
||||
{
|
||||
// Attempt to add the aspect to the cell partition list
|
||||
didMerge = this.workbench.onClientRequestAddAspectToPartitionList( player, slotAspect );
|
||||
didMerge = this.workbench.addAspectToPartition( slotAspect );
|
||||
}
|
||||
|
||||
// Did we merge?
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
@@ -47,14 +48,11 @@ public class ContainerEssentiaTerminal
|
||||
* @param player
|
||||
* Player that owns this container.
|
||||
*/
|
||||
public ContainerEssentiaTerminal( final PartEssentiaTerminal terminal, final EntityPlayer player )
|
||||
public ContainerEssentiaTerminal( @Nonnull final PartEssentiaTerminal terminal, final EntityPlayer player )
|
||||
{
|
||||
// Call the super
|
||||
super( player );
|
||||
|
||||
// Set the player
|
||||
this.player = player;
|
||||
|
||||
// Set the terminal
|
||||
this.terminal = terminal;
|
||||
|
||||
@@ -90,6 +88,24 @@ public class ContainerEssentiaTerminal
|
||||
return this.playerSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Aspect getHostSelectedAspect()
|
||||
{
|
||||
return this.terminal.selectedAspect;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setHostSelectedAspect( final Aspect aspect )
|
||||
{
|
||||
this.terminal.selectedAspect = aspect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
return this.terminal.isUseableByPlayer( player );
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfers essentia.
|
||||
*/
|
||||
@@ -178,7 +194,7 @@ public class ContainerEssentiaTerminal
|
||||
{
|
||||
super.onContainerClosed( player );
|
||||
|
||||
if( EffectiveSide.isServerSide() && ( this.terminal != null ) )
|
||||
if( EffectiveSide.isServerSide() )
|
||||
{
|
||||
this.terminal.removeListener( this );
|
||||
}
|
||||
|
||||
+6
-2
@@ -4,12 +4,12 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_EssentiaVibrationChamber;
|
||||
import thaumicenergistics.common.tiles.TileEssentiaVibrationChamber;
|
||||
import thaumicenergistics.common.tiles.abstraction.TileEVCBase;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
|
||||
public class ContainerEssentiaVibrationChamber
|
||||
extends Container
|
||||
@@ -68,7 +68,11 @@ public class ContainerEssentiaVibrationChamber
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
return !( player instanceof FakePlayer );
|
||||
if( this.chamber != null )
|
||||
{
|
||||
return ThEUtils.canPlayerInteractWith( player, this.chamber );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+71
-37
@@ -14,6 +14,7 @@ import thaumcraft.api.crafting.ShapedArcaneRecipe;
|
||||
import thaumcraft.api.crafting.ShapelessArcaneRecipe;
|
||||
import thaumicenergistics.common.container.slot.SlotRestrictive;
|
||||
import thaumicenergistics.common.inventory.HandlerKnowledgeCore;
|
||||
import thaumicenergistics.common.inventory.TheInternalInventory;
|
||||
import thaumicenergistics.common.items.ItemKnowledgeCore;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_KnowledgeInscriber;
|
||||
import thaumicenergistics.common.tiles.TileKnowledgeInscriber;
|
||||
@@ -43,6 +44,11 @@ public class ContainerKnowledgeInscriber
|
||||
Enabled_Delete
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum number of patterns.
|
||||
*/
|
||||
private static final int MAXIMUM_PATTERNS = HandlerKnowledgeCore.MAXIMUM_STORED_PATTERNS;
|
||||
|
||||
/**
|
||||
* Y position for the player and hotbar inventory.
|
||||
*/
|
||||
@@ -56,25 +62,22 @@ public class ContainerKnowledgeInscriber
|
||||
/**
|
||||
* Pattern slots.
|
||||
*/
|
||||
private static final int PATTERN_SLOT_X = 26, PATTERN_SLOT_Y = 18, PATTERN_ROWS = 3, PATTERN_COLS = 7, PATTERN_SLOT_SPACING = 18;
|
||||
private static final int PATTERN_SLOT = 0, PATTERN_SLOT_X = 26, PATTERN_SLOT_Y = 18,
|
||||
PATTERN_ROWS = 3, PATTERN_COLS = 7, PATTERN_SLOT_SPACING = 18;
|
||||
|
||||
/**
|
||||
* Crafting slots
|
||||
*/
|
||||
public static final int CRAFTING_SLOT_X = 26, CRAFTING_SLOT_Y = 90, CRAFTING_ROWS = 3, CRAFTING_COLS = 3, CRAFTING_SLOT_SPACING = 18;
|
||||
|
||||
/**
|
||||
* Maximum number of patterns.
|
||||
*/
|
||||
private static final int MAXIMUM_PATTERNS = HandlerKnowledgeCore.MAXIMUM_STORED_PATTERNS;
|
||||
public static final int CRAFTING_MATRIX_SLOT = MAXIMUM_PATTERNS + PATTERN_SLOT, CRAFTING_SLOT_X = 26,
|
||||
CRAFTING_SLOT_Y = 90, CRAFTING_ROWS = 3, CRAFTING_COLS = 3,
|
||||
CRAFTING_SLOT_SPACING = 18, CRAFTING_RESULT_SLOT = CRAFTING_MATRIX_SLOT + ( CRAFTING_ROWS * CRAFTING_COLS );
|
||||
|
||||
/**
|
||||
* Slots
|
||||
*/
|
||||
private SlotRestrictive kCoreSlot;
|
||||
private SlotInaccessible[] patternSlots = new SlotInaccessible[ContainerKnowledgeInscriber.MAXIMUM_PATTERNS];
|
||||
private SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[ContainerKnowledgeInscriber.CRAFTING_ROWS *
|
||||
ContainerKnowledgeInscriber.CRAFTING_COLS];
|
||||
private SlotInaccessible[] patternSlots = new SlotInaccessible[MAXIMUM_PATTERNS];
|
||||
private SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[CRAFTING_ROWS * CRAFTING_COLS];
|
||||
private SlotFake resultSlot;
|
||||
|
||||
/**
|
||||
@@ -107,6 +110,11 @@ public class ContainerKnowledgeInscriber
|
||||
*/
|
||||
private TileKnowledgeInscriber inscriber;
|
||||
|
||||
/**
|
||||
* Inventory for the patterns and crafting matrix
|
||||
*/
|
||||
private final TheInternalInventory internalInventory;
|
||||
|
||||
public ContainerKnowledgeInscriber( final EntityPlayer player, final World world, final int x, final int y, final int z )
|
||||
{
|
||||
// Set the player
|
||||
@@ -124,6 +132,9 @@ public class ContainerKnowledgeInscriber
|
||||
ContainerKnowledgeInscriber.KCORE_SLOT_Y );
|
||||
this.addSlotToContainer( this.kCoreSlot );
|
||||
|
||||
// Setup the internal inventory
|
||||
this.internalInventory = new TheInternalInventory( "cki", CRAFTING_RESULT_SLOT + 1, 64 );
|
||||
|
||||
// Create pattern slots
|
||||
this.initPatternSlots();
|
||||
|
||||
@@ -131,7 +142,7 @@ public class ContainerKnowledgeInscriber
|
||||
this.initCraftingSlots();
|
||||
|
||||
// Create the result slot
|
||||
this.resultSlot = new SlotFake( this.inscriber, TileKnowledgeInscriber.CRAFTING_RESULT_SLOT, 116, 108 );
|
||||
this.resultSlot = new SlotFake( this.internalInventory, CRAFTING_RESULT_SLOT, 116, 108 );
|
||||
this.addSlotToContainer( this.resultSlot );
|
||||
|
||||
// Perform server side only setup
|
||||
@@ -151,7 +162,7 @@ public class ContainerKnowledgeInscriber
|
||||
this.updatePatternSlots();
|
||||
|
||||
// Update the result
|
||||
this.onCraftMatrixChanged( this.inscriber );
|
||||
this.onCraftMatrixChanged( this.internalInventory );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -178,8 +189,8 @@ public class ContainerKnowledgeInscriber
|
||||
else
|
||||
{
|
||||
// Get the recipe output
|
||||
ItemStack recipeOutput = ArcaneRecipeHelper.INSTANCE.getRecipeOutput( this.inscriber,
|
||||
TileKnowledgeInscriber.CRAFTING_MATRIX_SLOT, 9, this.activeRecipe );
|
||||
ItemStack recipeOutput = ArcaneRecipeHelper.INSTANCE.getRecipeOutput( this.internalInventory,
|
||||
CRAFTING_MATRIX_SLOT, 9, this.activeRecipe );
|
||||
|
||||
// Ensure there is an output
|
||||
if( recipeOutput == null )
|
||||
@@ -221,7 +232,7 @@ public class ContainerKnowledgeInscriber
|
||||
{
|
||||
int slotIndex;
|
||||
// Create the crafting slots
|
||||
slotIndex = TileKnowledgeInscriber.CRAFTING_MATRIX_SLOT;
|
||||
slotIndex = CRAFTING_MATRIX_SLOT;
|
||||
for( int row = 0; row < ContainerKnowledgeInscriber.CRAFTING_ROWS; row++ )
|
||||
{
|
||||
for( int column = 0; column < ContainerKnowledgeInscriber.CRAFTING_COLS; column++ )
|
||||
@@ -234,7 +245,7 @@ public class ContainerKnowledgeInscriber
|
||||
int posY = ContainerKnowledgeInscriber.CRAFTING_SLOT_Y + ( ContainerKnowledgeInscriber.CRAFTING_SLOT_SPACING * row );
|
||||
|
||||
// Add to the array
|
||||
this.craftingSlots[index] = new SlotFakeCraftingMatrix( this.inscriber, slotIndex++ , posX, posY );
|
||||
this.craftingSlots[index] = new SlotFakeCraftingMatrix( this.internalInventory, slotIndex++ , posX, posY );
|
||||
|
||||
// Add the slot
|
||||
this.addSlotToContainer( this.craftingSlots[index] );
|
||||
@@ -249,7 +260,7 @@ public class ContainerKnowledgeInscriber
|
||||
{
|
||||
int slotIndex;
|
||||
// Create the pattern slots
|
||||
slotIndex = TileKnowledgeInscriber.PATTERN_SLOT;
|
||||
slotIndex = PATTERN_SLOT;
|
||||
for( int row = 0; row < ContainerKnowledgeInscriber.PATTERN_ROWS; row++ )
|
||||
{
|
||||
for( int column = 0; column < ContainerKnowledgeInscriber.PATTERN_COLS; column++ )
|
||||
@@ -262,7 +273,7 @@ public class ContainerKnowledgeInscriber
|
||||
int posY = ContainerKnowledgeInscriber.PATTERN_SLOT_Y + ( ContainerKnowledgeInscriber.PATTERN_SLOT_SPACING * row );
|
||||
|
||||
// Add to the array
|
||||
this.patternSlots[index] = new SlotInaccessible( this.inscriber, slotIndex++ , posX, posY );
|
||||
this.patternSlots[index] = new SlotInaccessible( this.internalInventory, slotIndex++ , posX, posY );
|
||||
|
||||
// Add the slot
|
||||
this.addSlotToContainer( this.patternSlots[index] );
|
||||
@@ -378,7 +389,7 @@ public class ContainerKnowledgeInscriber
|
||||
{
|
||||
if( this.inscriber != null )
|
||||
{
|
||||
return true;
|
||||
return this.inscriber.isUseableByPlayer( player );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -418,8 +429,8 @@ public class ContainerKnowledgeInscriber
|
||||
// Update the slots
|
||||
this.updatePatternSlots();
|
||||
|
||||
// Update the client
|
||||
this.onClientRequestFullUpdate( this.player, false );
|
||||
// Update the save state
|
||||
this.sendSaveState( false );
|
||||
|
||||
// Mark the inscriber as dirty
|
||||
this.inscriber.markDirty();
|
||||
@@ -430,13 +441,16 @@ public class ContainerKnowledgeInscriber
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the save-state to the client.
|
||||
*/
|
||||
public void onClientRequestFullUpdate( final EntityPlayer player, final boolean justSaved )
|
||||
public void onClientRequestClearGrid()
|
||||
{
|
||||
// Update the client
|
||||
Packet_C_KnowledgeInscriber.sendSaveState( player, this.getSaveState(), justSaved );
|
||||
// Clear the grid
|
||||
for( int index = 0; index < ( CRAFTING_COLS * CRAFTING_ROWS ); ++index )
|
||||
{
|
||||
this.internalInventory.setInventorySlotContents( index + CRAFTING_MATRIX_SLOT, null );
|
||||
}
|
||||
|
||||
// Update the matrix
|
||||
this.onCraftMatrixChanged( this.internalInventory );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,8 +496,8 @@ public class ContainerKnowledgeInscriber
|
||||
}
|
||||
|
||||
// Get the aspect cost
|
||||
AspectList recipeAspects = ArcaneRecipeHelper.INSTANCE.getRecipeAspectCost( this.inscriber,
|
||||
TileKnowledgeInscriber.CRAFTING_MATRIX_SLOT, 9, this.activeRecipe );
|
||||
AspectList recipeAspects = ArcaneRecipeHelper.INSTANCE.getRecipeAspectCost( this.internalInventory,
|
||||
CRAFTING_MATRIX_SLOT, 9, this.activeRecipe );
|
||||
|
||||
// Create the pattern
|
||||
ArcaneCraftingPattern pattern = new ArcaneCraftingPattern( this.kCoreSlot.getStack(), recipeAspects, this.resultSlot.getStack(), inputs );
|
||||
@@ -495,8 +509,8 @@ public class ContainerKnowledgeInscriber
|
||||
this.updatePatternSlots();
|
||||
this.loadPattern( pattern );
|
||||
|
||||
// Update the client
|
||||
this.onClientRequestFullUpdate( player, true );
|
||||
// Update the save state
|
||||
this.sendSaveState( true );
|
||||
|
||||
// Mark the inscriber as dirty
|
||||
this.inscriber.markDirty();
|
||||
@@ -515,8 +529,8 @@ public class ContainerKnowledgeInscriber
|
||||
// Update the slots
|
||||
this.updatePatternSlots();
|
||||
|
||||
// Update the client
|
||||
this.onClientRequestFullUpdate( player, false );
|
||||
// Update the save state
|
||||
this.sendSaveState( false );
|
||||
|
||||
// Mark the inscriber as dirty
|
||||
this.inscriber.markDirty();
|
||||
@@ -524,6 +538,18 @@ public class ContainerKnowledgeInscriber
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A client has requested the save state.
|
||||
*
|
||||
* @param player
|
||||
* @param justSaved
|
||||
*/
|
||||
public void onClientRequestSaveState()
|
||||
{
|
||||
// Update the client
|
||||
this.sendSaveState( false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the arcane recipe.
|
||||
*
|
||||
@@ -533,28 +559,36 @@ public class ContainerKnowledgeInscriber
|
||||
public void onCraftMatrixChanged( final IInventory inv )
|
||||
{
|
||||
// Set the active recipe
|
||||
this.activeRecipe = ArcaneRecipeHelper.INSTANCE.findMatchingArcaneResult( inv, TileKnowledgeInscriber.CRAFTING_MATRIX_SLOT, 9, this.player );
|
||||
this.activeRecipe = ArcaneRecipeHelper.INSTANCE.findMatchingArcaneResult( inv, CRAFTING_MATRIX_SLOT, 9, this.player );
|
||||
|
||||
ItemStack craftResult = null;
|
||||
|
||||
// Set the result slot
|
||||
if( this.activeRecipe != null )
|
||||
{
|
||||
craftResult = ArcaneRecipeHelper.INSTANCE.getRecipeOutput( inv, TileKnowledgeInscriber.CRAFTING_MATRIX_SLOT, 9, this.activeRecipe );
|
||||
craftResult = ArcaneRecipeHelper.INSTANCE.getRecipeOutput( inv, CRAFTING_MATRIX_SLOT, 9, this.activeRecipe );
|
||||
}
|
||||
|
||||
this.resultSlot.putStack( craftResult );
|
||||
|
||||
// Update the client
|
||||
// Update the save state
|
||||
if( EffectiveSide.isServerSide() )
|
||||
{
|
||||
this.onClientRequestFullUpdate( this.player, false );
|
||||
this.sendSaveState( false );
|
||||
}
|
||||
|
||||
// Sync
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the save-state to the client.
|
||||
*/
|
||||
public void sendSaveState( final boolean justSaved )
|
||||
{
|
||||
Packet_C_KnowledgeInscriber.sendSaveState( this.player, this.getSaveState(), justSaved );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates 'ghost' items when a crafting slot is clicked.
|
||||
*
|
||||
|
||||
+32
-26
@@ -133,7 +133,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
/**
|
||||
* The arcane crafting terminal associated with the container.
|
||||
*/
|
||||
private PartArcaneCraftingTerminal arcaneCraftingTerminalPart;
|
||||
private PartArcaneCraftingTerminal terminal;
|
||||
|
||||
/**
|
||||
* The player associated with this container.
|
||||
@@ -195,7 +195,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
public ContainerPartArcaneCraftingTerminal( final PartArcaneCraftingTerminal terminal, final EntityPlayer player )
|
||||
{
|
||||
// Set the part
|
||||
this.arcaneCraftingTerminalPart = terminal;
|
||||
this.terminal = terminal;
|
||||
|
||||
// Set the player
|
||||
this.player = player;
|
||||
@@ -522,7 +522,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
ItemStack arcaneResult = null;
|
||||
|
||||
// Is there a matching recipe?
|
||||
IArcaneRecipe matchingRecipe = ArcaneRecipeHelper.INSTANCE.findMatchingArcaneResult( this.arcaneCraftingTerminalPart, 0,
|
||||
IArcaneRecipe matchingRecipe = ArcaneRecipeHelper.INSTANCE.findMatchingArcaneResult( this.terminal, 0,
|
||||
ContainerPartArcaneCraftingTerminal.CRAFTING_GRID_TOTAL_SIZE, this.player );
|
||||
|
||||
if( matchingRecipe != null )
|
||||
@@ -550,11 +550,11 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
for( int slotIndex = 0; slotIndex < ( ContainerPartArcaneCraftingTerminal.CRAFTING_GRID_TOTAL_SIZE ); slotIndex++ )
|
||||
{
|
||||
// Set the slot
|
||||
craftingInventory.setInventorySlotContents( slotIndex, this.arcaneCraftingTerminalPart.getStackInSlot( slotIndex ) );
|
||||
craftingInventory.setInventorySlotContents( slotIndex, this.terminal.getStackInSlot( slotIndex ) );
|
||||
}
|
||||
|
||||
// Return the result
|
||||
return CRAFT_MANAGER.findMatchingRecipe( craftingInventory, this.arcaneCraftingTerminalPart.getWorldObj() );
|
||||
return CRAFT_MANAGER.findMatchingRecipe( craftingInventory, this.terminal.getWorldObj() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -664,7 +664,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
private boolean mergeWithViewCells( final ItemStack itemStack )
|
||||
{
|
||||
// Ensure the item a view cell
|
||||
if( !this.arcaneCraftingTerminalPart.isItemValidForSlot( PartArcaneCraftingTerminal.VIEW_SLOT_MIN, itemStack ) )
|
||||
if( !this.terminal.isItemValidForSlot( PartArcaneCraftingTerminal.VIEW_SLOT_MIN, itemStack ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -732,7 +732,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
ItemWandCasting wandItem = null;
|
||||
|
||||
// Get the cost
|
||||
this.requiredAspects = ArcaneRecipeHelper.INSTANCE.getRecipeAspectCost( this.arcaneCraftingTerminalPart, 0,
|
||||
this.requiredAspects = ArcaneRecipeHelper.INSTANCE.getRecipeAspectCost( this.terminal, 0,
|
||||
ContainerPartArcaneCraftingTerminal.CRAFTING_GRID_TOTAL_SIZE, forRecipe );
|
||||
|
||||
// Ensure there is a cost
|
||||
@@ -790,7 +790,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
if( hasAll )
|
||||
{
|
||||
// Get the result of the recipe.
|
||||
return ArcaneRecipeHelper.INSTANCE.getRecipeOutput( this.arcaneCraftingTerminalPart, 0,
|
||||
return ArcaneRecipeHelper.INSTANCE.getRecipeOutput( this.terminal, 0,
|
||||
ContainerPartArcaneCraftingTerminal.CRAFTING_GRID_TOTAL_SIZE, forRecipe );
|
||||
}
|
||||
|
||||
@@ -809,13 +809,14 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
return ( slotNumber >= this.firstCraftingSlotNumber ) && ( slotNumber <= this.lastCraftingSlotNumber );
|
||||
}
|
||||
|
||||
/**
|
||||
* Who can interact with this?
|
||||
*/
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
if( this.terminal != null )
|
||||
{
|
||||
return this.terminal.isUseableByPlayer( player );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -869,7 +870,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
@Override
|
||||
public ICraftingIssuerHost getCraftingHost()
|
||||
{
|
||||
return this.arcaneCraftingTerminalPart;
|
||||
return this.terminal;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -927,7 +928,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
public void onClientRequestAutoCraft( final EntityPlayer player, final IAEItemStack result )
|
||||
{
|
||||
// Get the host tile
|
||||
TileEntity te = this.arcaneCraftingTerminalPart.getHostTile();
|
||||
TileEntity te = this.terminal.getHostTile();
|
||||
|
||||
// Launch the GUI
|
||||
ThEGuiHandler.launchGui( ThEGuiHandler.AUTO_CRAFTING_AMOUNT, player, te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord );
|
||||
@@ -944,7 +945,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
cca.getOpenContext().setX( te.xCoord );
|
||||
cca.getOpenContext().setY( te.yCoord );
|
||||
cca.getOpenContext().setZ( te.zCoord );
|
||||
cca.getOpenContext().setSide( this.arcaneCraftingTerminalPart.getSide() );
|
||||
cca.getOpenContext().setSide( this.terminal.getSide() );
|
||||
|
||||
// Set the item
|
||||
cca.getCraftingItem().putStack( result.getItemStack() );
|
||||
@@ -1252,11 +1253,11 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
public void onClientRequestFullUpdate( final EntityPlayer player )
|
||||
{
|
||||
// Send the sorting info
|
||||
Packet_C_ArcaneCraftingTerminal.sendModeChange( player, this.arcaneCraftingTerminalPart.getSortingOrder(),
|
||||
this.arcaneCraftingTerminalPart.getSortingDirection(), this.arcaneCraftingTerminalPart.getViewMode() );
|
||||
Packet_C_ArcaneCraftingTerminal.sendModeChange( player, this.terminal.getSortingOrder(),
|
||||
this.terminal.getSortingDirection(), this.terminal.getViewMode() );
|
||||
|
||||
// Ensure we have a monitor
|
||||
if( this.monitor != null )
|
||||
// Ensure we have a monitor & the terminal is active
|
||||
if( ( this.monitor != null ) && ( this.terminal.isActive() ) )
|
||||
{
|
||||
// Get the full list
|
||||
IItemList<IAEItemStack> fullList = this.monitor.getStorageList();
|
||||
@@ -1275,7 +1276,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
public void onClientRequestSetSort( final SortOrder order, final SortDir dir, final ViewItems viewMode )
|
||||
{
|
||||
// Inform the terminal
|
||||
this.arcaneCraftingTerminalPart.setSorts( order, dir, viewMode );
|
||||
this.terminal.setSorts( order, dir, viewMode );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1286,7 +1287,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
*/
|
||||
public void onClientRequestSwapArmor( final EntityPlayer player )
|
||||
{
|
||||
this.arcaneCraftingTerminalPart.swapStoredArmor( player );
|
||||
this.terminal.swapStoredArmor( player );
|
||||
this.detectAndSendChanges();
|
||||
Packet_C_ArcaneCraftingTerminal.updateAspectCost( player );
|
||||
}
|
||||
@@ -1300,9 +1301,9 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
// Pass to super
|
||||
super.onContainerClosed( player );
|
||||
|
||||
if( this.arcaneCraftingTerminalPart != null )
|
||||
if( this.terminal != null )
|
||||
{
|
||||
this.arcaneCraftingTerminalPart.removeListener( this );
|
||||
this.terminal.removeListener( this );
|
||||
}
|
||||
|
||||
// Is this server side?
|
||||
@@ -1346,7 +1347,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
resultSlot.setWand( this.wand );
|
||||
|
||||
// Set the result
|
||||
this.arcaneCraftingTerminalPart.setInventorySlotContentsWithoutNotify( PartArcaneCraftingTerminal.RESULT_SLOT_INDEX, craftResult );
|
||||
this.terminal.setInventorySlotContentsWithoutNotify( PartArcaneCraftingTerminal.RESULT_SLOT_INDEX, craftResult );
|
||||
|
||||
}
|
||||
|
||||
@@ -1357,7 +1358,12 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
@Override
|
||||
public void onListUpdate()
|
||||
{
|
||||
// Ignored
|
||||
// Is the terminal no longer active?
|
||||
if( !this.terminal.isActive() )
|
||||
{
|
||||
// Send empty list to client
|
||||
Packet_C_ArcaneCraftingTerminal.sendAllNetworkItems( this.player, AEApi.instance().storage().createItemList() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1405,7 +1411,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
public void registerForUpdates()
|
||||
{
|
||||
// Register the container with terminal
|
||||
this.arcaneCraftingTerminalPart.registerListener( this );
|
||||
this.terminal.registerListener( this );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_AspectSlot;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_EssentiaIOBus;
|
||||
import thaumicenergistics.common.parts.ThEPartEssentiaIOBus_Base;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
|
||||
/**
|
||||
@@ -47,12 +48,17 @@ public class ContainerPartEssentiaIOBus
|
||||
/**
|
||||
* The part associated with this container
|
||||
*/
|
||||
private ThEPartEssentiaIOBus_Base part;
|
||||
private final ThEPartEssentiaIOBus_Base bus;
|
||||
|
||||
/**
|
||||
* Player associated with the container
|
||||
*/
|
||||
private EntityPlayer player;
|
||||
private final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Cached isVoidAllowed
|
||||
*/
|
||||
private boolean isVoidAllowed;
|
||||
|
||||
/**
|
||||
* Creates the container.
|
||||
@@ -65,7 +71,7 @@ public class ContainerPartEssentiaIOBus
|
||||
public ContainerPartEssentiaIOBus( final ThEPartEssentiaIOBus_Base part, final EntityPlayer player )
|
||||
{
|
||||
// Set the part
|
||||
this.part = part;
|
||||
this.bus = part;
|
||||
|
||||
// Set the player
|
||||
this.player = player;
|
||||
@@ -82,30 +88,45 @@ public class ContainerPartEssentiaIOBus
|
||||
this.bindToNetworkTool( player.inventory, part.getHost().getLocation(), 0, 0 );
|
||||
|
||||
// Register as a listener on the part
|
||||
this.part.addListener( this );
|
||||
this.bus.addListener( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void retrySlotClick( final int par1, final int par2, final boolean par3, final EntityPlayer player )
|
||||
{
|
||||
// Ignored
|
||||
}
|
||||
|
||||
/**
|
||||
* Who can interact with the container?
|
||||
*/
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
if( this.bus != null )
|
||||
{
|
||||
return this.bus.isUseableByPlayer( player );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
// Call super
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Has the void mode changed?
|
||||
if( this.isVoidAllowed != this.bus.isVoidAllowed() )
|
||||
{
|
||||
// Update
|
||||
this.isVoidAllowed = this.bus.isVoidAllowed();
|
||||
Packet_C_EssentiaIOBus.sendVoidMode( this.player, this.isVoidAllowed );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed( final EntityPlayer player )
|
||||
{
|
||||
if( this.part != null )
|
||||
if( this.bus != null )
|
||||
{
|
||||
this.part.removeListener( this );
|
||||
this.bus.removeListener( this );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +163,7 @@ public class ContainerPartEssentiaIOBus
|
||||
if( ( slot != null ) && ( slot.getHasStack() ) )
|
||||
{
|
||||
// Can this aspect be added to the filter list?
|
||||
if( ( this.part != null ) && ( this.part.addFilteredAspectFromItemstack( player, slot.getStack() ) ) )
|
||||
if( ( this.bus != null ) && ( this.bus.addFilteredAspectFromItemstack( player, slot.getStack() ) ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
+68
-7
@@ -1,9 +1,15 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_AspectSlot;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_EssentiaEmitter;
|
||||
import thaumicenergistics.common.parts.PartEssentiaLevelEmitter;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
|
||||
/**
|
||||
* Inventory container for essentia emitter.
|
||||
@@ -27,7 +33,27 @@ public class ContainerPartEssentiaLevelEmitter
|
||||
/**
|
||||
* The AE part associated with this container.
|
||||
*/
|
||||
private PartEssentiaLevelEmitter part;
|
||||
private PartEssentiaLevelEmitter emitter;
|
||||
|
||||
/**
|
||||
* The redstone mode the emitter is in.
|
||||
*/
|
||||
private RedstoneMode redstoneMode = null;
|
||||
|
||||
/**
|
||||
* The threshold value.
|
||||
*/
|
||||
private long thresholdLevel = -1;
|
||||
|
||||
/**
|
||||
* The tracked aspect.
|
||||
*/
|
||||
private Aspect trackedAspect = null;
|
||||
|
||||
/**
|
||||
* The associated player
|
||||
*/
|
||||
private final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Create the container.
|
||||
@@ -38,20 +64,55 @@ public class ContainerPartEssentiaLevelEmitter
|
||||
public ContainerPartEssentiaLevelEmitter( final PartEssentiaLevelEmitter part, final EntityPlayer player )
|
||||
{
|
||||
// Set the part
|
||||
this.part = part;
|
||||
this.emitter = part;
|
||||
|
||||
// Set the player
|
||||
this.player = player;
|
||||
|
||||
// Get the players inventory and bind it to the container.
|
||||
this.bindPlayerInventory( player.inventory, ContainerPartEssentiaLevelEmitter.PLAYER_INV_POSITION_Y,
|
||||
ContainerPartEssentiaLevelEmitter.HOTBAR_INV_POSITION_Y );
|
||||
}
|
||||
|
||||
/**
|
||||
* Who can interact with the container?
|
||||
*/
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
if( this.emitter != null )
|
||||
{
|
||||
return this.emitter.isUseableByPlayer( player );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
// Call super
|
||||
super.detectAndSendChanges();
|
||||
|
||||
// Threshold
|
||||
if( this.thresholdLevel != this.emitter.getThresholdLevel() )
|
||||
{
|
||||
this.thresholdLevel = this.emitter.getThresholdLevel();
|
||||
Packet_C_EssentiaEmitter.sendThresholdValue( this.thresholdLevel, this.player );
|
||||
}
|
||||
|
||||
// Redstone mode
|
||||
if( this.redstoneMode != this.emitter.getRedstoneMode() )
|
||||
{
|
||||
this.redstoneMode = this.emitter.getRedstoneMode();
|
||||
Packet_C_EssentiaEmitter.sendRedstoneMode( this.redstoneMode, this.player );
|
||||
}
|
||||
|
||||
// Tracked aspect
|
||||
if( this.trackedAspect != this.emitter.getTrackedAspect() )
|
||||
{
|
||||
this.trackedAspect = this.emitter.getTrackedAspect();
|
||||
|
||||
List<Aspect> filter = new ArrayList<Aspect>();
|
||||
filter.add( this.trackedAspect );
|
||||
Packet_C_AspectSlot.setFilterList( filter, this.player );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,7 +124,7 @@ public class ContainerPartEssentiaLevelEmitter
|
||||
if( ( slot != null ) && ( slot.getHasStack() ) )
|
||||
{
|
||||
// Can we set the filter based on this item?
|
||||
if( ( this.part != null ) && this.part.setFilteredAspectFromItemstack( player, slot.getStack() ) )
|
||||
if( ( this.emitter != null ) && this.emitter.setFilteredAspectFromItemstack( player, slot.getStack() ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
+65
-14
@@ -1,12 +1,15 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_AspectSlot;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_EssentiaStorageBus;
|
||||
import thaumicenergistics.common.parts.PartEssentiaStorageBus;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
|
||||
public class ContainerPartEssentiaStorageBus
|
||||
extends ContainerWithNetworkTool
|
||||
@@ -31,9 +34,25 @@ public class ContainerPartEssentiaStorageBus
|
||||
*/
|
||||
private static int HOTBAR_INV_POSITION_Y = 160;
|
||||
|
||||
private PartEssentiaStorageBus part;
|
||||
/**
|
||||
* The essentia storage bus.
|
||||
*/
|
||||
private final PartEssentiaStorageBus storageBus;
|
||||
|
||||
private EntityPlayer player;
|
||||
/**
|
||||
* The associated player.
|
||||
*/
|
||||
private final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Cache of filteredAspects.
|
||||
*/
|
||||
private final ArrayList<Aspect> filteredAspects = new ArrayList<Aspect>( PartEssentiaStorageBus.FILTER_SIZE );
|
||||
|
||||
/**
|
||||
* Cache of isVoidAllowed.
|
||||
*/
|
||||
private boolean isVoidAllowed = false;
|
||||
|
||||
public ContainerPartEssentiaStorageBus( final PartEssentiaStorageBus part, final EntityPlayer player )
|
||||
{
|
||||
@@ -41,7 +60,13 @@ public class ContainerPartEssentiaStorageBus
|
||||
this.player = player;
|
||||
|
||||
// Set the part
|
||||
this.part = part;
|
||||
this.storageBus = part;
|
||||
|
||||
// Setup the filtered aspects
|
||||
for( int i = 0; i < PartEssentiaStorageBus.FILTER_SIZE; ++i )
|
||||
{
|
||||
this.filteredAspects.add( null );
|
||||
}
|
||||
|
||||
// Add the upgrade slot
|
||||
this.addUpgradeSlots( part.getUpgradeInventory(), 1, ContainerPartEssentiaStorageBus.UPGRADE_SLOT_X,
|
||||
@@ -54,26 +79,52 @@ public class ContainerPartEssentiaStorageBus
|
||||
// Bind to the network tool
|
||||
this.bindToNetworkTool( player.inventory, part.getHost().getLocation(), 0, 0 );
|
||||
|
||||
// Register as a listener
|
||||
this.part.addListener( this );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Who can interact with the container?
|
||||
*/
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
if( this.storageBus != null )
|
||||
{
|
||||
return this.storageBus.isUseableByPlayer( player );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed( final EntityPlayer player )
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if( this.part != null )
|
||||
// Call super
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
this.part.removeListener( this );
|
||||
return;
|
||||
}
|
||||
|
||||
// Has the filtered list changed?
|
||||
boolean updateFilters = false;
|
||||
for( int filterIndex = 0; filterIndex < PartEssentiaStorageBus.FILTER_SIZE; ++filterIndex )
|
||||
{
|
||||
if( this.filteredAspects.get( filterIndex ) != this.storageBus.getFilteredAspect( filterIndex ) )
|
||||
{
|
||||
// Found mismatch
|
||||
this.filteredAspects.set( filterIndex, this.storageBus.getFilteredAspect( filterIndex ) );
|
||||
updateFilters = true;
|
||||
}
|
||||
}
|
||||
if( updateFilters )
|
||||
{
|
||||
// Update the client
|
||||
Packet_C_AspectSlot.setFilterList( this.filteredAspects, this.player );
|
||||
}
|
||||
|
||||
// Has the void mode changed?
|
||||
if( this.isVoidAllowed != this.storageBus.isVoidAllowed() )
|
||||
{
|
||||
// Update
|
||||
this.isVoidAllowed = this.storageBus.isVoidAllowed();
|
||||
Packet_C_EssentiaStorageBus.sendIsVoidAllowed( this.player, this.isVoidAllowed );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +143,7 @@ public class ContainerPartEssentiaStorageBus
|
||||
if( ( slot != null ) && ( slot.getHasStack() ) )
|
||||
{
|
||||
// Can this aspect be added to the filter list?
|
||||
if( ( this.part != null ) && ( this.part.addFilteredAspectFromItemstack( player, slot.getStack() ) ) )
|
||||
if( ( this.storageBus != null ) && ( this.storageBus.addFilteredAspectFromItemstack( player, slot.getStack() ) ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,11 @@ package thaumicenergistics.common.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_Priority;
|
||||
import thaumicenergistics.common.parts.ThEPartBase;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
|
||||
public class ContainerPriority
|
||||
@@ -37,13 +41,22 @@ public class ContainerPriority
|
||||
Packet_C_Priority.sendPriority( this.host.getPriority(), this.player );
|
||||
}
|
||||
|
||||
/**
|
||||
* Who can interact with this?
|
||||
*/
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
if( this.host instanceof IInventory )
|
||||
{
|
||||
return ( (IInventory)this.host ).isUseableByPlayer( player );
|
||||
}
|
||||
else if( this.host instanceof ThEPartBase )
|
||||
{
|
||||
return ( (ThEPartBase)this.host ).isUseableByPlayer( player );
|
||||
}
|
||||
else if( this.host instanceof TileEntity )
|
||||
{
|
||||
return ThEUtils.canPlayerInteractWith( player, (TileEntity)this.host );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+24
-54
@@ -41,6 +41,8 @@ public class ContainerWirelessEssentiaTerminal
|
||||
*/
|
||||
private final HandlerWirelessEssentiaTerminal handler;
|
||||
|
||||
private Aspect tmpSelectedAspect;
|
||||
|
||||
/**
|
||||
* Import and export inventory slots.
|
||||
*/
|
||||
@@ -57,11 +59,6 @@ public class ContainerWirelessEssentiaTerminal
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Tracks if the terminal was connected last tick.
|
||||
*/
|
||||
private boolean wasConnected = true;
|
||||
|
||||
/**
|
||||
* Tracks the number of ticks elapsed.
|
||||
*/
|
||||
@@ -108,58 +105,34 @@ public class ContainerWirelessEssentiaTerminal
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the terminal is in range of the AP, and updates the network
|
||||
* monitor accordingly.
|
||||
*/
|
||||
private void updateConnectivity()
|
||||
{
|
||||
// Is the terminal connected?
|
||||
if( this.handler.isConnected() )
|
||||
{
|
||||
// Terminal is in range and powered
|
||||
|
||||
// Was the terminal disconnected last tick?
|
||||
if( !this.wasConnected )
|
||||
{
|
||||
// Re-acquire the monitor
|
||||
this.monitor = this.handler.getEssentiaMonitor();
|
||||
|
||||
// Re-attach
|
||||
this.attachToMonitor();
|
||||
|
||||
// Send the list
|
||||
this.onClientRequestFullUpdate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Terminal is out of power, or out of range.
|
||||
|
||||
// Was the terminal connected last tick?
|
||||
if( this.wasConnected )
|
||||
{
|
||||
// Disconnect from the monitor
|
||||
this.detachFromMonitor();
|
||||
|
||||
// Send the empty list
|
||||
this.onClientRequestFullUpdate();
|
||||
|
||||
// Close the gui.
|
||||
this.player.closeScreen();
|
||||
}
|
||||
|
||||
// Set as no longer connected
|
||||
this.wasConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseActionSource getActionSource()
|
||||
{
|
||||
return this.handler.getActionHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Aspect getHostSelectedAspect()
|
||||
{
|
||||
return this.tmpSelectedAspect;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setHostSelectedAspect( final Aspect aspect )
|
||||
{
|
||||
this.tmpSelectedAspect = aspect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer p_75145_1_ )
|
||||
{
|
||||
if( this.handler != null )
|
||||
{
|
||||
return this.handler.isConnected();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfers essentia, checks the network connectivity, and drains power.
|
||||
*/
|
||||
@@ -178,9 +151,6 @@ public class ContainerWirelessEssentiaTerminal
|
||||
|
||||
if( this.powerTickCounter > ContainerWirelessEssentiaTerminal.EXTRACT_POWER_ON_TICK )
|
||||
{
|
||||
// Check the network connectivity
|
||||
this.updateConnectivity();
|
||||
|
||||
// Adjust the power multiplier
|
||||
this.handler.updatePowerMultiplier();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package thaumicenergistics.common.inventory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -103,7 +102,7 @@ public class HandlerItemEssentiaCell
|
||||
/**
|
||||
* List of aspects this cell can only accept.
|
||||
*/
|
||||
protected final List<Aspect> partitionAspects = new ArrayList<Aspect>();
|
||||
protected final ArrayList<Aspect> partitionAspects = new ArrayList<Aspect>();
|
||||
|
||||
public HandlerItemEssentiaCell( final ItemStack storageStack, final ISaveProvider saveProvider )
|
||||
{
|
||||
@@ -610,9 +609,9 @@ public class HandlerItemEssentiaCell
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Aspect> getPartitionAspects()
|
||||
public ArrayList<Aspect> getPartitionAspects()
|
||||
{
|
||||
return Collections.unmodifiableList( this.partitionAspects );
|
||||
return this.partitionAspects;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+7
-7
@@ -196,12 +196,12 @@ public class HandlerWirelessEssentiaTerminal
|
||||
/**
|
||||
* Cached value of the range of the access point, squared.
|
||||
*/
|
||||
private double rangeOfAccessPoint;
|
||||
private double apTransmitRange;
|
||||
|
||||
/**
|
||||
* Where in the world is the access point.
|
||||
*/
|
||||
private DimensionalCoord locationOfAccessPoint;
|
||||
private DimensionalCoord apLocation;
|
||||
|
||||
/**
|
||||
* Player who is using the wireless terminal.
|
||||
@@ -308,8 +308,8 @@ public class HandlerWirelessEssentiaTerminal
|
||||
{
|
||||
if( this.accessPoint != null )
|
||||
{
|
||||
return( ( this.accessPoint.isActive() ) && ( HandlerWirelessEssentiaTerminal.isAPInRangeOfPlayer( this.locationOfAccessPoint,
|
||||
this.rangeOfAccessPoint, this.player ) ) );
|
||||
return( ( this.accessPoint.isActive() ) && ( HandlerWirelessEssentiaTerminal.isAPInRangeOfPlayer( this.apLocation,
|
||||
this.apTransmitRange, this.player ) ) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -330,10 +330,10 @@ public class HandlerWirelessEssentiaTerminal
|
||||
}
|
||||
|
||||
// Get the range of the access point
|
||||
this.rangeOfAccessPoint = this.accessPoint.getRange();
|
||||
this.apTransmitRange = this.accessPoint.getRange();
|
||||
|
||||
// Get the location of the access point
|
||||
this.locationOfAccessPoint = this.accessPoint.getLocation();
|
||||
this.apLocation = this.accessPoint.getLocation();
|
||||
|
||||
// Create the action source
|
||||
if( this.player != null )
|
||||
@@ -673,7 +673,7 @@ public class HandlerWirelessEssentiaTerminal
|
||||
public void updatePowerMultiplier()
|
||||
{
|
||||
// Get the squared distance
|
||||
double distance = HandlerWirelessEssentiaTerminal.getSquaredPlayerDistanceFromAP( this.locationOfAccessPoint, this.player );
|
||||
double distance = HandlerWirelessEssentiaTerminal.getSquaredPlayerDistanceFromAP( this.apLocation, this.player );
|
||||
|
||||
// Calculate the distance
|
||||
distance = Math.sqrt( distance );
|
||||
|
||||
@@ -7,8 +7,7 @@ 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;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
|
||||
public class TheInternalInventory
|
||||
implements IInventory
|
||||
@@ -18,11 +17,6 @@ public class TheInternalInventory
|
||||
*/
|
||||
private static final String NBT_KEY_SLOT = "Slot";
|
||||
|
||||
/**
|
||||
* The squared reach distance.
|
||||
*/
|
||||
private static final double SQUARED_REACH = 64.0D;
|
||||
|
||||
/**
|
||||
* Stack size limit.
|
||||
*/
|
||||
@@ -52,16 +46,6 @@ public class TheInternalInventory
|
||||
this.stackLimit = stackLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the specified slot.
|
||||
*
|
||||
* @param slotIndex
|
||||
*/
|
||||
public void clearSlot( final int slotIndex )
|
||||
{
|
||||
this.slots[slotIndex] = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
@@ -233,38 +217,9 @@ public class TheInternalInventory
|
||||
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 );
|
||||
return ThEUtils.canPlayerInteractWith( player, tile );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -196,23 +196,21 @@ public class ItemCraftingAspect
|
||||
Aspect aspect = ItemCraftingAspect.getAspect( stack );
|
||||
|
||||
// Null check
|
||||
if( ( stack == null ) || ( aspect == null ) )
|
||||
if( aspect != null )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
// Get the player
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
// Get the player
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
// Has the player discovered the aspect?
|
||||
if( ( player != null ) && ItemCraftingAspect.canPlayerSeeAspect( player, aspect ) )
|
||||
{
|
||||
// Show name
|
||||
return aspect.getName();
|
||||
// Has the player discovered the aspect?
|
||||
if( ItemCraftingAspect.canPlayerSeeAspect( player, aspect ) )
|
||||
{
|
||||
// Show name
|
||||
return aspect.getName();
|
||||
}
|
||||
}
|
||||
|
||||
// Show unknown
|
||||
return StatCollector.translateToLocal( "tc.aspect.unknown" );
|
||||
return "tc.aspect.unknown";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ItemFocusAEWrench
|
||||
// Spawn beam
|
||||
Packet_R_ParticleFX.createWrenchFX(
|
||||
player.worldObj, player.posX, player.posY, player.posZ,
|
||||
beamX, beamY, beamZ, Aspect.ENERGY, 20 );
|
||||
beamX, beamY, beamZ, Aspect.ENERGY, 20.0f );
|
||||
}
|
||||
|
||||
private static ItemStack getWrench()
|
||||
|
||||
@@ -20,17 +20,17 @@ public class NetworkHandler
|
||||
/**
|
||||
* Next packet ID.
|
||||
*/
|
||||
private static int nextID = 0;
|
||||
private static short nextID = 0;
|
||||
|
||||
/**
|
||||
* Maps a class to a unique id.
|
||||
*/
|
||||
private static HashMap<Class, Integer> ClassToID = new HashMap<Class, Integer>();
|
||||
private static HashMap<Class, Short> ClassToID = new HashMap<Class, Short>();
|
||||
|
||||
/**
|
||||
* Maps a unique id to a class.
|
||||
*/
|
||||
private static HashMap<Integer, Class> IDToClass = new HashMap<Integer, Class>();
|
||||
private static HashMap<Short, Class> IDToClass = new HashMap<Short, Class>();
|
||||
|
||||
/**
|
||||
* Registers a packet.
|
||||
@@ -50,7 +50,7 @@ public class NetworkHandler
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static Class getPacketClassFromID( final Integer id )
|
||||
public static Class getPacketClassFromID( final Short id )
|
||||
{
|
||||
return NetworkHandler.IDToClass.getOrDefault( id, null );
|
||||
}
|
||||
@@ -61,9 +61,9 @@ public class NetworkHandler
|
||||
* @param packet
|
||||
* @return
|
||||
*/
|
||||
public static int getPacketID( final ThEBasePacket packet )
|
||||
public static short getPacketID( final ThEBasePacket packet )
|
||||
{
|
||||
return NetworkHandler.ClassToID.getOrDefault( packet.getClass(), -1 );
|
||||
return NetworkHandler.ClassToID.getOrDefault( packet.getClass(), (short) -1 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ public class NetworkHandler
|
||||
registerPacket( Packet_C_Sync.class );
|
||||
}
|
||||
|
||||
public static void sendAreaPacketToClients( final ThEAreaPacket areaPacket, final int range )
|
||||
public static void sendAreaPacketToClients( final ThEAreaPacket areaPacket, final float range )
|
||||
{
|
||||
// Create the wrapper packet
|
||||
WrapperPacket wrapper = new WrapperPacket_C( areaPacket );
|
||||
|
||||
@@ -16,11 +16,19 @@ public abstract class WrapperPacket
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the wrapper, wrapping the specified packet.
|
||||
*
|
||||
* @param packet
|
||||
*/
|
||||
public WrapperPacket( final ThEBasePacket packet )
|
||||
{
|
||||
this.embeddedPacket = packet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the packet.
|
||||
*/
|
||||
public void execute()
|
||||
{
|
||||
if( this.embeddedPacket != null )
|
||||
@@ -33,7 +41,7 @@ public abstract class WrapperPacket
|
||||
public void fromBytes( final ByteBuf stream )
|
||||
{
|
||||
// Read the id
|
||||
int id = stream.readInt();
|
||||
short id = stream.readShort();
|
||||
if( id == -1 )
|
||||
{
|
||||
// Invalid packet
|
||||
@@ -69,8 +77,8 @@ public abstract class WrapperPacket
|
||||
if( this.embeddedPacket != null )
|
||||
{
|
||||
// Write the id
|
||||
int id = NetworkHandler.getPacketID( this.embeddedPacket );
|
||||
stream.writeInt( id );
|
||||
short id = NetworkHandler.getPacketID( this.embeddedPacket );
|
||||
stream.writeShort( id );
|
||||
|
||||
// Call embedded
|
||||
this.embeddedPacket.toBytes( stream );
|
||||
@@ -78,7 +86,7 @@ public abstract class WrapperPacket
|
||||
else
|
||||
{
|
||||
// Write -1
|
||||
stream.writeInt( -1 );
|
||||
stream.writeShort( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-58
@@ -14,15 +14,14 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
public class Packet_C_EssentiaEmitter
|
||||
extends ThEClientPacket
|
||||
{
|
||||
private static final byte MODE_FULL_UPDATE = 0;
|
||||
|
||||
private static final byte MODE_UPDATE_WANTED = 1;
|
||||
|
||||
private static final byte MODE_UPDATE_REDSTONE = 2;
|
||||
/**
|
||||
* Packet modes.
|
||||
*/
|
||||
private static final byte MODE_UPDATE_WANTED = 1,
|
||||
MODE_UPDATE_REDSTONE = 2;
|
||||
|
||||
private RedstoneMode redstoneMode;
|
||||
|
||||
private long wantedAmount;
|
||||
private long threshold;
|
||||
|
||||
/**
|
||||
* Creates the packet
|
||||
@@ -43,28 +42,6 @@ public class Packet_C_EssentiaEmitter
|
||||
return packet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a packet containing the emitter state.
|
||||
*
|
||||
* @param redstoneMode
|
||||
* @param wantedAmount
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public static void sendEmitterState( final RedstoneMode redstoneMode, final long wantedAmount, final EntityPlayer player )
|
||||
{
|
||||
Packet_C_EssentiaEmitter packet = newPacket( player, MODE_FULL_UPDATE );
|
||||
|
||||
// Set the redstone mode
|
||||
packet.redstoneMode = redstoneMode;
|
||||
|
||||
// Set the wanted amount
|
||||
packet.wantedAmount = wantedAmount;
|
||||
|
||||
// Send it
|
||||
NetworkHandler.sendPacketToClient( packet );
|
||||
}
|
||||
|
||||
public static void sendRedstoneMode( final RedstoneMode redstoneMode, final EntityPlayer player )
|
||||
{
|
||||
Packet_C_EssentiaEmitter packet = newPacket( player, MODE_UPDATE_REDSTONE );
|
||||
@@ -79,16 +56,16 @@ public class Packet_C_EssentiaEmitter
|
||||
/**
|
||||
* Create a packet to update a client with a new wanted amount.
|
||||
*
|
||||
* @param wantedAmount
|
||||
* @param threshold
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public static void setWantedAmount( final long wantedAmount, final EntityPlayer player )
|
||||
public static void sendThresholdValue( final long threshold, final EntityPlayer player )
|
||||
{
|
||||
Packet_C_EssentiaEmitter packet = newPacket( player, MODE_UPDATE_WANTED );
|
||||
|
||||
// Set the wanted amount
|
||||
packet.wantedAmount = wantedAmount;
|
||||
packet.threshold = threshold;
|
||||
|
||||
// Send it
|
||||
NetworkHandler.sendPacketToClient( packet );
|
||||
@@ -107,20 +84,14 @@ public class Packet_C_EssentiaEmitter
|
||||
|
||||
switch ( this.mode )
|
||||
{
|
||||
case Packet_C_EssentiaEmitter.MODE_FULL_UPDATE:
|
||||
// Full update
|
||||
( (GuiEssentiaLevelEmitter)gui ).onServerUpdateWantedAmount( this.wantedAmount );
|
||||
( (GuiEssentiaLevelEmitter)gui ).onServerUpdateRedstoneMode( this.redstoneMode );
|
||||
break;
|
||||
|
||||
case Packet_C_EssentiaEmitter.MODE_UPDATE_WANTED:
|
||||
// Update wanted amount
|
||||
( (GuiEssentiaLevelEmitter)gui ).onServerUpdateWantedAmount( this.wantedAmount );
|
||||
( (GuiEssentiaLevelEmitter)gui ).onReceiveThresholdValue( this.threshold );
|
||||
break;
|
||||
|
||||
case Packet_C_EssentiaEmitter.MODE_UPDATE_REDSTONE:
|
||||
// Update redstone mode
|
||||
( (GuiEssentiaLevelEmitter)gui ).onServerUpdateRedstoneMode( this.redstoneMode );
|
||||
( (GuiEssentiaLevelEmitter)gui ).onReceiveRedstoneMode( this.redstoneMode );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -131,17 +102,9 @@ public class Packet_C_EssentiaEmitter
|
||||
{
|
||||
switch ( this.mode )
|
||||
{
|
||||
case Packet_C_EssentiaEmitter.MODE_FULL_UPDATE:
|
||||
// Read the redstone mode ordinal
|
||||
this.redstoneMode = EnumCache.AE_REDSTONE_MODES[stream.readInt()];
|
||||
|
||||
// Read the wanted amount
|
||||
this.wantedAmount = stream.readLong();
|
||||
break;
|
||||
|
||||
case Packet_C_EssentiaEmitter.MODE_UPDATE_WANTED:
|
||||
// Read the wanted amount
|
||||
this.wantedAmount = stream.readLong();
|
||||
this.threshold = stream.readLong();
|
||||
break;
|
||||
|
||||
case Packet_C_EssentiaEmitter.MODE_UPDATE_REDSTONE:
|
||||
@@ -156,17 +119,9 @@ public class Packet_C_EssentiaEmitter
|
||||
{
|
||||
switch ( this.mode )
|
||||
{
|
||||
case Packet_C_EssentiaEmitter.MODE_FULL_UPDATE:
|
||||
// Write the redstone mode ordinal
|
||||
stream.writeInt( this.redstoneMode.ordinal() );
|
||||
|
||||
// Write the wanted amount
|
||||
stream.writeLong( this.wantedAmount );
|
||||
break;
|
||||
|
||||
case Packet_C_EssentiaEmitter.MODE_UPDATE_WANTED:
|
||||
// Write the wanted amount
|
||||
stream.writeLong( this.wantedAmount );
|
||||
stream.writeLong( this.threshold );
|
||||
break;
|
||||
|
||||
case Packet_C_EssentiaEmitter.MODE_UPDATE_REDSTONE:
|
||||
|
||||
+7
-1
@@ -14,7 +14,13 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
public class Packet_C_EssentiaIOBus
|
||||
extends ThEClientPacket
|
||||
{
|
||||
private static final byte MODE_SET_REDSTONE_CONTROLLED = 0, MODE_SET_REDSTONE_MODE = 1, MODE_SET_FILTER_SIZE = 2, MODE_SEND_FULL_UPDATE = 3,
|
||||
/**
|
||||
* Packet modes.
|
||||
*/
|
||||
private static final byte MODE_SET_REDSTONE_CONTROLLED = 0,
|
||||
MODE_SET_REDSTONE_MODE = 1,
|
||||
MODE_SET_FILTER_SIZE = 2,
|
||||
MODE_SEND_FULL_UPDATE = 3,
|
||||
MODE_SEND_VOID_MODE = 4;
|
||||
|
||||
private RedstoneMode redstoneMode;
|
||||
|
||||
+4
-1
@@ -12,7 +12,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
public class Packet_C_EssentiaStorageBus
|
||||
extends ThEClientPacket
|
||||
{
|
||||
private static final byte MODE_SET_VOID = 0;
|
||||
/**
|
||||
* Packet modes.
|
||||
*/
|
||||
private static final byte MODE_SET_VOID = 1;
|
||||
|
||||
private boolean isVoidAllowed;
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class Packet_R_ParticleFX
|
||||
*/
|
||||
public static void createWrenchFX( final World world, final double sourceX, final double sourceY, final double sourceZ,
|
||||
final double destinationX, final double destinationY, final double destinationZ,
|
||||
final Aspect aspectColor, final int range )
|
||||
final Aspect aspectColor, final float range )
|
||||
{
|
||||
Packet_R_ParticleFX packet = new Packet_R_ParticleFX();
|
||||
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package thaumicenergistics.common.network.packet.server;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import thaumicenergistics.common.container.ContainerDistillationEncoder;
|
||||
import thaumicenergistics.common.container.ContainerDistillationPatternEncoder;
|
||||
import thaumicenergistics.common.network.NetworkHandler;
|
||||
|
||||
public class Packet_S_DistillationEncoder
|
||||
@@ -45,10 +45,10 @@ public class Packet_S_DistillationEncoder
|
||||
}
|
||||
|
||||
// Get the players open container
|
||||
if( this.player.openContainer instanceof ContainerDistillationEncoder )
|
||||
if( this.player.openContainer instanceof ContainerDistillationPatternEncoder )
|
||||
{
|
||||
// Send the encode
|
||||
( (ContainerDistillationEncoder)this.player.openContainer ).onEncodePattern();
|
||||
( (ContainerDistillationPatternEncoder)this.player.openContainer ).onEncodePattern();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-6
@@ -3,6 +3,7 @@ package thaumicenergistics.common.network.packet.server;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.common.container.ContainerEssentiaCellWorkbench;
|
||||
import thaumicenergistics.common.network.NetworkHandler;
|
||||
import thaumicenergistics.common.network.ThEBasePacket;
|
||||
import thaumicenergistics.common.tiles.TileEssentiaCellWorkbench;
|
||||
@@ -170,35 +171,44 @@ public class Packet_S_EssentiaCellWorkbench
|
||||
@Override
|
||||
public void execute()
|
||||
{
|
||||
// Sanity check
|
||||
if( this.workbench == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( this.mode )
|
||||
{
|
||||
case Packet_S_EssentiaCellWorkbench.MODE_REQUEST_ADD_ASPECT:
|
||||
// Request the aspect be added
|
||||
this.workbench.onClientRequestAddAspectToPartitionList( this.player, this.arAspect );
|
||||
this.workbench.addAspectToPartition( this.arAspect );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaCellWorkbench.MODE_REQUEST_REMOVE_ASPECT:
|
||||
// Request the aspect be removed
|
||||
this.workbench.onClientRequestRemoveAspectFromPartitionList( this.player, this.arAspect );
|
||||
this.workbench.removeAspectFromPartition( this.arAspect );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaCellWorkbench.MODE_REQUEST_REPLACE_ASPECT:
|
||||
// Request the aspect be replaced
|
||||
this.workbench.onClientRequestReplaceAspectFromPartitionList( this.player, this.arAspect, this.replaceAspect );
|
||||
this.workbench.swapPartitionedAspect( this.arAspect, this.replaceAspect );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaCellWorkbench.MODE_REQUEST_FULL_LIST:
|
||||
// Request the full list
|
||||
this.workbench.onClientRequestPartitionList( this.player );
|
||||
if( this.player.openContainer instanceof ContainerEssentiaCellWorkbench )
|
||||
{
|
||||
( (ContainerEssentiaCellWorkbench)this.player.openContainer ).onClientRequestPartitionList();
|
||||
}
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaCellWorkbench.MODE_REQUEST_CLEAR:
|
||||
// Request the clear
|
||||
this.workbench.onClientRequestClearPartitioning( this.player );
|
||||
this.workbench.clearAllPartitioning();
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaCellWorkbench.MODE_REQUEST_PARITION_CONTENTS:
|
||||
this.workbench.onClientRequestPartitionToContents( this.player );
|
||||
this.workbench.partitionToCellContents();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+20
-54
@@ -9,18 +9,12 @@ import thaumicenergistics.common.parts.PartEssentiaLevelEmitter;
|
||||
public class Packet_S_EssentiaEmitter
|
||||
extends ThEServerPacket
|
||||
{
|
||||
private static final byte MODE_REQUEST_UPDATE = 0;
|
||||
|
||||
private static final byte MODE_SEND_WANTED = 1;
|
||||
|
||||
private static final byte MODE_ADJUST_WANTED = 2;
|
||||
|
||||
private static final byte MODE_TOGGLE_REDSTONE = 3;
|
||||
private static final byte MODE_SEND_WANTED = 1,
|
||||
MODE_ADJUST_WANTED = 2,
|
||||
MODE_TOGGLE_REDSTONE = 3;
|
||||
|
||||
private PartEssentiaLevelEmitter part;
|
||||
|
||||
private long wantedAmount;
|
||||
|
||||
private int adjustmentAmount;
|
||||
|
||||
/**
|
||||
@@ -53,25 +47,6 @@ public class Packet_S_EssentiaEmitter
|
||||
NetworkHandler.sendPacketToServer( packet );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a packet to let the server know a client would like a full
|
||||
* update.
|
||||
*
|
||||
* @param part
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public static void sendUpdateRequest( final PartEssentiaLevelEmitter part, final EntityPlayer player )
|
||||
{
|
||||
Packet_S_EssentiaEmitter packet = newPacket( player, MODE_REQUEST_UPDATE );
|
||||
|
||||
// Set the part
|
||||
packet.part = part;
|
||||
|
||||
// Send it
|
||||
NetworkHandler.sendPacketToServer( packet );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a packet to update the wanted amount on the server
|
||||
*
|
||||
@@ -121,24 +96,25 @@ public class Packet_S_EssentiaEmitter
|
||||
@Override
|
||||
public void execute()
|
||||
{
|
||||
// Null check
|
||||
if( this.part == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( this.mode )
|
||||
{
|
||||
case Packet_S_EssentiaEmitter.MODE_REQUEST_UPDATE:
|
||||
// Request the full update
|
||||
this.part.onClientUpdateRequest( this.player );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaEmitter.MODE_SEND_WANTED:
|
||||
case MODE_SEND_WANTED:
|
||||
// Set the wanted amount
|
||||
this.part.onClientSetWantedAmount( this.wantedAmount, this.player );
|
||||
this.part.onSetThresholdLevel( this.wantedAmount, this.player );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaEmitter.MODE_ADJUST_WANTED:
|
||||
case MODE_ADJUST_WANTED:
|
||||
// Set the adjustment amount
|
||||
this.part.onClientAdjustWantedAmount( this.adjustmentAmount, this.player );
|
||||
this.part.onAdjustThresholdLevel( this.adjustmentAmount, this.player );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaEmitter.MODE_TOGGLE_REDSTONE:
|
||||
case MODE_TOGGLE_REDSTONE:
|
||||
// Toggle the redstone mode
|
||||
this.part.onClientToggleRedstoneMode( this.player );
|
||||
break;
|
||||
@@ -150,12 +126,12 @@ public class Packet_S_EssentiaEmitter
|
||||
{
|
||||
switch ( this.mode )
|
||||
{
|
||||
case Packet_S_EssentiaEmitter.MODE_REQUEST_UPDATE:
|
||||
case MODE_TOGGLE_REDSTONE:
|
||||
// Read the part
|
||||
this.part = (PartEssentiaLevelEmitter)ThEBasePacket.readPart( stream );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaEmitter.MODE_SEND_WANTED:
|
||||
case MODE_SEND_WANTED:
|
||||
// Read the part
|
||||
this.part = (PartEssentiaLevelEmitter)ThEBasePacket.readPart( stream );
|
||||
|
||||
@@ -163,18 +139,13 @@ public class Packet_S_EssentiaEmitter
|
||||
this.wantedAmount = stream.readLong();
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaEmitter.MODE_ADJUST_WANTED:
|
||||
case MODE_ADJUST_WANTED:
|
||||
// Read the part
|
||||
this.part = (PartEssentiaLevelEmitter)ThEBasePacket.readPart( stream );
|
||||
|
||||
// Read the adjustment amount
|
||||
this.adjustmentAmount = stream.readInt();
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaEmitter.MODE_TOGGLE_REDSTONE:
|
||||
// Read the part
|
||||
this.part = (PartEssentiaLevelEmitter)ThEBasePacket.readPart( stream );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,12 +154,12 @@ public class Packet_S_EssentiaEmitter
|
||||
{
|
||||
switch ( this.mode )
|
||||
{
|
||||
case Packet_S_EssentiaEmitter.MODE_REQUEST_UPDATE:
|
||||
case MODE_TOGGLE_REDSTONE:
|
||||
// Write the part
|
||||
ThEBasePacket.writePart( this.part, stream );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaEmitter.MODE_SEND_WANTED:
|
||||
case MODE_SEND_WANTED:
|
||||
// Write the part
|
||||
ThEBasePacket.writePart( this.part, stream );
|
||||
|
||||
@@ -196,18 +167,13 @@ public class Packet_S_EssentiaEmitter
|
||||
stream.writeLong( this.wantedAmount );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaEmitter.MODE_ADJUST_WANTED:
|
||||
case MODE_ADJUST_WANTED:
|
||||
// Write the part
|
||||
ThEBasePacket.writePart( this.part, stream );
|
||||
|
||||
// Write the adjustment amount
|
||||
stream.writeInt( this.adjustmentAmount );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaEmitter.MODE_TOGGLE_REDSTONE:
|
||||
// Write the part
|
||||
ThEBasePacket.writePart( this.part, stream );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -41,7 +41,7 @@ public class Packet_S_EssentiaIOBus
|
||||
* @param part
|
||||
* @return
|
||||
*/
|
||||
public static void sendFullUpdateRequest( final EntityPlayer player, final ThEPartEssentiaIOBus_Base part )
|
||||
public static void sendRequestFilterList( final EntityPlayer player, final ThEPartEssentiaIOBus_Base part )
|
||||
{
|
||||
Packet_S_EssentiaIOBus packet = newPacket( player, MODE_REQUEST_FULL_UPDATE, part );
|
||||
|
||||
@@ -86,7 +86,7 @@ public class Packet_S_EssentiaIOBus
|
||||
{
|
||||
case Packet_S_EssentiaIOBus.MODE_REQUEST_FULL_UPDATE:
|
||||
// Request a full update
|
||||
this.part.onClientRequestFullUpdate( this.player );
|
||||
this.part.onClientRequestFilterList( this.player );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaIOBus.MODE_REQUEST_CHANGE_REDSTONE_MODE:
|
||||
@@ -98,7 +98,7 @@ public class Packet_S_EssentiaIOBus
|
||||
// Request a void mode change
|
||||
if( this.part instanceof PartEssentiaExportBus )
|
||||
{
|
||||
( (PartEssentiaExportBus)this.part ).onClientRequestChangeVoidMode( this.player );
|
||||
( (PartEssentiaExportBus)this.part ).toggleVoidMode( this.player );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+3
-24
@@ -9,7 +9,9 @@ import thaumicenergistics.common.parts.PartEssentiaStorageBus;
|
||||
public class Packet_S_EssentiaStorageBus
|
||||
extends ThEServerPacket
|
||||
{
|
||||
private static final byte MODE_REQUEST_FULL_UPDATE = 0;
|
||||
/**
|
||||
* Packet modes
|
||||
*/
|
||||
private static final byte MODE_REQUEST_SET_VOID = 1;
|
||||
|
||||
private PartEssentiaStorageBus part;
|
||||
@@ -35,14 +37,6 @@ public class Packet_S_EssentiaStorageBus
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static void sendFullUpdateRequest( final EntityPlayer player, final PartEssentiaStorageBus part )
|
||||
{
|
||||
Packet_S_EssentiaStorageBus packet = newPacket( player, MODE_REQUEST_FULL_UPDATE, part );
|
||||
|
||||
// Send it
|
||||
NetworkHandler.sendPacketToServer( packet );
|
||||
}
|
||||
|
||||
public static void setVoidAllowed( final EntityPlayer player, final PartEssentiaStorageBus part,
|
||||
final boolean isVoidAllowed )
|
||||
{
|
||||
@@ -60,11 +54,6 @@ public class Packet_S_EssentiaStorageBus
|
||||
{
|
||||
switch ( this.mode )
|
||||
{
|
||||
case Packet_S_EssentiaStorageBus.MODE_REQUEST_FULL_UPDATE:
|
||||
// Request a full update
|
||||
this.part.onClientRequestFullUpdate( this.player );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaStorageBus.MODE_REQUEST_SET_VOID:
|
||||
// Request set void
|
||||
this.part.onClientRequestSetVoidMode( this.player, this.isVoidAllowed );
|
||||
@@ -77,11 +66,6 @@ public class Packet_S_EssentiaStorageBus
|
||||
{
|
||||
switch ( this.mode )
|
||||
{
|
||||
case Packet_S_EssentiaStorageBus.MODE_REQUEST_FULL_UPDATE:
|
||||
// Read the part
|
||||
this.part = ( (PartEssentiaStorageBus)ThEBasePacket.readPart( stream ) );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaStorageBus.MODE_REQUEST_SET_VOID:
|
||||
// Read the part
|
||||
this.part = ( (PartEssentiaStorageBus)ThEBasePacket.readPart( stream ) );
|
||||
@@ -96,11 +80,6 @@ public class Packet_S_EssentiaStorageBus
|
||||
{
|
||||
switch ( this.mode )
|
||||
{
|
||||
case Packet_S_EssentiaStorageBus.MODE_REQUEST_FULL_UPDATE:
|
||||
// Write the part
|
||||
ThEBasePacket.writePart( this.part, stream );
|
||||
break;
|
||||
|
||||
case Packet_S_EssentiaStorageBus.MODE_REQUEST_SET_VOID:
|
||||
// Write the part
|
||||
ThEBasePacket.writePart( this.part, stream );
|
||||
|
||||
+35
-13
@@ -8,9 +8,14 @@ import thaumicenergistics.common.network.NetworkHandler;
|
||||
public class Packet_S_KnowledgeInscriber
|
||||
extends ThEServerPacket
|
||||
{
|
||||
private static final byte MODE_FULL_UPDATE = 0, MODE_SAVEDELETE = 1;
|
||||
/**
|
||||
* Packet modes
|
||||
*/
|
||||
private static final byte MODE_FULL_UPDATE = 0,
|
||||
MODE_SAVEDELETE = 1,
|
||||
MODE_CLEAR = 2;
|
||||
|
||||
public static void sendFullUpdateRequest( final EntityPlayer player )
|
||||
private static Packet_S_KnowledgeInscriber newPacket( final EntityPlayer player, final byte mode )
|
||||
{
|
||||
Packet_S_KnowledgeInscriber packet = new Packet_S_KnowledgeInscriber();
|
||||
|
||||
@@ -18,7 +23,24 @@ public class Packet_S_KnowledgeInscriber
|
||||
packet.player = player;
|
||||
|
||||
// Set the mode
|
||||
packet.mode = Packet_S_KnowledgeInscriber.MODE_FULL_UPDATE;
|
||||
packet.mode = mode;
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static void sendClearGrid( final EntityPlayer player )
|
||||
{
|
||||
// Create the packet
|
||||
Packet_S_KnowledgeInscriber packet = newPacket( player, MODE_CLEAR );
|
||||
|
||||
// Send it
|
||||
NetworkHandler.sendPacketToServer( packet );
|
||||
}
|
||||
|
||||
public static void sendFullUpdateRequest( final EntityPlayer player )
|
||||
{
|
||||
// Create the packet
|
||||
Packet_S_KnowledgeInscriber packet = newPacket( player, MODE_FULL_UPDATE );
|
||||
|
||||
// Send it
|
||||
NetworkHandler.sendPacketToServer( packet );
|
||||
@@ -26,13 +48,8 @@ public class Packet_S_KnowledgeInscriber
|
||||
|
||||
public static void sendSaveDelete( final EntityPlayer player )
|
||||
{
|
||||
Packet_S_KnowledgeInscriber packet = new Packet_S_KnowledgeInscriber();
|
||||
|
||||
// Set the player
|
||||
packet.player = player;
|
||||
|
||||
// Set the mode
|
||||
packet.mode = Packet_S_KnowledgeInscriber.MODE_SAVEDELETE;
|
||||
// Create the packet
|
||||
Packet_S_KnowledgeInscriber packet = newPacket( player, MODE_SAVEDELETE );
|
||||
|
||||
// Send it
|
||||
NetworkHandler.sendPacketToServer( packet );
|
||||
@@ -59,15 +76,20 @@ public class Packet_S_KnowledgeInscriber
|
||||
{
|
||||
switch ( this.mode )
|
||||
{
|
||||
case Packet_S_KnowledgeInscriber.MODE_FULL_UPDATE:
|
||||
case MODE_FULL_UPDATE:
|
||||
// Request full update
|
||||
( (ContainerKnowledgeInscriber)this.player.openContainer ).onClientRequestFullUpdate( this.player, false );
|
||||
( (ContainerKnowledgeInscriber)this.player.openContainer ).onClientRequestSaveState();
|
||||
break;
|
||||
|
||||
case Packet_S_KnowledgeInscriber.MODE_SAVEDELETE:
|
||||
case MODE_SAVEDELETE:
|
||||
// Request save/delete
|
||||
( (ContainerKnowledgeInscriber)this.player.openContainer ).onClientRequestSaveOrDelete( this.player );
|
||||
break;
|
||||
|
||||
case MODE_CLEAR:
|
||||
// Request clear
|
||||
( (ContainerKnowledgeInscriber)this.player.openContainer ).onClientRequestClearGrid();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ import appeng.items.storage.ItemViewCell;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
// TODO: convert inventory to internal inventory
|
||||
public class PartArcaneCraftingTerminal
|
||||
extends ThERotateablePart
|
||||
implements IInventory, IGridTickable, ICraftingIssuerHost, ITerminalHost
|
||||
@@ -153,7 +154,7 @@ public class PartArcaneCraftingTerminal
|
||||
public PartArcaneCraftingTerminal()
|
||||
{
|
||||
// Call super
|
||||
super( AEPartsEnum.ArcaneCraftingTerminal );
|
||||
super( AEPartsEnum.ArcaneCraftingTerminal, SecurityPermissions.EXTRACT, SecurityPermissions.INJECT );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,24 +264,6 @@ public class PartArcaneCraftingTerminal
|
||||
return returnStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified player can open the gui.
|
||||
*/
|
||||
@Override
|
||||
public boolean doesPlayerHavePermissionToOpenGui( final EntityPlayer player )
|
||||
{
|
||||
// Does the player have export & import permissions
|
||||
if( this.doesPlayerHavePermission( player, SecurityPermissions.EXTRACT ) )
|
||||
{
|
||||
if( this.doesPlayerHavePermission( player, SecurityPermissions.INJECT ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collision boxes
|
||||
*/
|
||||
@@ -550,15 +533,6 @@ public class PartArcaneCraftingTerminal
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Who can use this?
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchGUI( final EntityPlayer player )
|
||||
{
|
||||
@@ -987,6 +961,12 @@ public class PartArcaneCraftingTerminal
|
||||
// Call super
|
||||
super.writeToNBT( data, saveType );
|
||||
|
||||
// Only write NBT data if saving, or wrenched.
|
||||
if( ( saveType != PartItemStack.World ) && ( saveType != PartItemStack.Wrench ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a new tag list
|
||||
NBTTagList nbtList = new NBTTagList();
|
||||
|
||||
@@ -1035,7 +1015,7 @@ public class PartArcaneCraftingTerminal
|
||||
}
|
||||
|
||||
// Write the vis source info
|
||||
if( saveType != PartItemStack.Wrench )
|
||||
if( saveType == PartItemStack.World )
|
||||
{
|
||||
this.visSourceInfo.writeToNBT( data, PartArcaneCraftingTerminal.VIS_INTERFACE_NBT_KEY );
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.tiles.TileJarFillableVoid;
|
||||
import thaumicenergistics.api.grid.IMEEssentiaMonitor;
|
||||
import thaumicenergistics.client.textures.BlockTextureManager;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_EssentiaIOBus;
|
||||
import thaumicenergistics.common.registries.AEPartsEnum;
|
||||
import thaumicenergistics.integration.tc.EssentiaTileContainerHelper;
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -34,17 +33,7 @@ public class PartEssentiaExportBus
|
||||
|
||||
public PartEssentiaExportBus()
|
||||
{
|
||||
super( AEPartsEnum.EssentiaExportBus );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the state of the void mode to the specified player.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
private void sendVoidModeToClient( final EntityPlayer player )
|
||||
{
|
||||
Packet_C_EssentiaIOBus.sendVoidMode( player, this.isVoidAllowed );
|
||||
super( AEPartsEnum.EssentiaExportBus, SecurityPermissions.EXTRACT );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,16 +48,6 @@ public class PartEssentiaExportBus
|
||||
return 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified player can open the gui.
|
||||
*/
|
||||
@Override
|
||||
public boolean doesPlayerHavePermissionToOpenGui( final EntityPlayer player )
|
||||
{
|
||||
// Does the player have export permissions
|
||||
return this.doesPlayerHavePermission( player, SecurityPermissions.EXTRACT );
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to transfer essentia out of the network and into the adjacent
|
||||
* container.
|
||||
@@ -180,25 +159,21 @@ public class PartEssentiaExportBus
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player has requested to change the void mode
|
||||
* Returns if voiding is allowed.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void onClientRequestChangeVoidMode( final EntityPlayer player )
|
||||
@Override
|
||||
public boolean isVoidAllowed()
|
||||
{
|
||||
// Swap void modes
|
||||
this.isVoidAllowed = !this.isVoidAllowed;
|
||||
|
||||
// Send reply back
|
||||
this.sendVoidModeToClient( player );
|
||||
return this.isVoidAllowed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientRequestFullUpdate( final EntityPlayer player )
|
||||
public void onClientRequestFilterList( final EntityPlayer player )
|
||||
{
|
||||
// Call super
|
||||
super.onClientRequestFullUpdate( player );
|
||||
|
||||
// Send void mode
|
||||
this.sendVoidModeToClient( player );
|
||||
super.onClientRequestFilterList( player );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -335,14 +310,38 @@ public class PartEssentiaExportBus
|
||||
this.renderStaticBusLights( x, y, z, helper, renderer );
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player has requested to change the void mode
|
||||
*/
|
||||
public void toggleVoidMode( final EntityPlayer player )
|
||||
{
|
||||
// Swap void modes
|
||||
this.isVoidAllowed = !this.isVoidAllowed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( final NBTTagCompound data, final PartItemStack saveType )
|
||||
{
|
||||
// Call super
|
||||
super.writeToNBT( data, saveType );
|
||||
|
||||
boolean doSave = ( saveType == PartItemStack.World );
|
||||
if( !doSave )
|
||||
{
|
||||
// Are there any filters?
|
||||
for( Aspect aspect : this.filteredAspects )
|
||||
{
|
||||
if( aspect != null )
|
||||
{
|
||||
// Only save the void state if filters are set.
|
||||
doSave = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write void
|
||||
if( this.isVoidAllowed )
|
||||
if( doSave && this.isVoidAllowed )
|
||||
{
|
||||
data.setBoolean( PartEssentiaExportBus.NBT_KEY_VOID, this.isVoidAllowed );
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package thaumicenergistics.common.parts;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
@@ -24,7 +23,7 @@ public class PartEssentiaImportBus
|
||||
|
||||
public PartEssentiaImportBus()
|
||||
{
|
||||
super( AEPartsEnum.EssentiaImportBus );
|
||||
super( AEPartsEnum.EssentiaImportBus, SecurityPermissions.INJECT );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,16 +63,6 @@ public class PartEssentiaImportBus
|
||||
return 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified player can open the gui.
|
||||
*/
|
||||
@Override
|
||||
public boolean doesPlayerHavePermissionToOpenGui( final EntityPlayer player )
|
||||
{
|
||||
// Does the player have import permissions
|
||||
return this.doesPlayerHavePermission( player, SecurityPermissions.INJECT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doWork( final int transferAmount )
|
||||
{
|
||||
|
||||
@@ -2,9 +2,8 @@ package thaumicenergistics.common.parts;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -22,8 +21,6 @@ import thaumicenergistics.client.gui.GuiEssentiaLevelEmitter;
|
||||
import thaumicenergistics.client.textures.BlockTextureManager;
|
||||
import thaumicenergistics.common.container.ContainerPartEssentiaLevelEmitter;
|
||||
import thaumicenergistics.common.network.IAspectSlotPart;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_AspectSlot;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_EssentiaEmitter;
|
||||
import thaumicenergistics.common.registries.AEPartsEnum;
|
||||
import thaumicenergistics.common.registries.EnumCache;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
@@ -60,7 +57,7 @@ public class PartEssentiaLevelEmitter
|
||||
/**
|
||||
* Aspect we are watching.
|
||||
*/
|
||||
private Aspect trackedEssentia;
|
||||
private Aspect trackedAspect;
|
||||
|
||||
/**
|
||||
* Mode the emitter is in
|
||||
@@ -70,12 +67,12 @@ public class PartEssentiaLevelEmitter
|
||||
/**
|
||||
* Threshold value
|
||||
*/
|
||||
private long wantedAmount = 0;
|
||||
private long thresholdLevel = 0;
|
||||
|
||||
/**
|
||||
* Current value
|
||||
*/
|
||||
private long currentAmount;
|
||||
private long currentLevel;
|
||||
|
||||
/**
|
||||
* True if the emitter is emitting a redstone signal.
|
||||
@@ -92,7 +89,7 @@ public class PartEssentiaLevelEmitter
|
||||
*/
|
||||
public PartEssentiaLevelEmitter()
|
||||
{
|
||||
super( AEPartsEnum.EssentiaLevelEmitter );
|
||||
super( AEPartsEnum.EssentiaLevelEmitter, SecurityPermissions.BUILD );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,11 +110,11 @@ public class PartEssentiaLevelEmitter
|
||||
this.essentiaWatcher.clear();
|
||||
|
||||
// Is there an essentia being tracked?
|
||||
if( this.trackedEssentia != null )
|
||||
if( this.trackedAspect != null )
|
||||
{
|
||||
//this.debugTrackingStage = 2;
|
||||
// Configure the watcher
|
||||
this.essentiaWatcher.add( this.trackedEssentia );
|
||||
this.essentiaWatcher.add( this.trackedAspect );
|
||||
|
||||
// Get the essentia monitor
|
||||
IMEEssentiaMonitor essMon = this.getGridBlock().getEssentiaMonitor();
|
||||
@@ -126,7 +123,7 @@ public class PartEssentiaLevelEmitter
|
||||
if( essMon != null )
|
||||
{
|
||||
// Update the amount.
|
||||
this.setCurrentAmount( essMon.getEssentiaAmount( this.trackedEssentia ) );
|
||||
this.setCurrentLevel( essMon.getEssentiaAmount( this.trackedAspect ) );
|
||||
didSet = true;
|
||||
//this.debugTrackingStage = 3;
|
||||
//this.debugMonID = essMon.hashCode();
|
||||
@@ -139,7 +136,7 @@ public class PartEssentiaLevelEmitter
|
||||
if( !didSet )
|
||||
{
|
||||
// Reset
|
||||
this.setCurrentAmount( 0 );
|
||||
this.setCurrentLevel( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,13 +146,13 @@ public class PartEssentiaLevelEmitter
|
||||
*
|
||||
* @param amount
|
||||
*/
|
||||
private void setCurrentAmount( final long amount )
|
||||
private void setCurrentLevel( final long amount )
|
||||
{
|
||||
// Has the amount changed?
|
||||
if( amount != this.currentAmount )
|
||||
if( amount != this.currentLevel )
|
||||
{
|
||||
// Set the current amount
|
||||
this.currentAmount = amount;
|
||||
this.currentLevel = amount;
|
||||
|
||||
// Check if we should be emitting
|
||||
this.updateEmittingState();
|
||||
@@ -182,12 +179,12 @@ public class PartEssentiaLevelEmitter
|
||||
{
|
||||
case HIGH_SIGNAL:
|
||||
// Is the current amount more than or equal to the wanted amount?
|
||||
emitting = ( this.currentAmount >= this.wantedAmount );
|
||||
emitting = ( this.currentLevel >= this.thresholdLevel );
|
||||
break;
|
||||
|
||||
case LOW_SIGNAL:
|
||||
// Is the current amount less than the wanted amount?
|
||||
emitting = ( this.currentAmount < this.wantedAmount );
|
||||
emitting = ( this.currentLevel < this.thresholdLevel );
|
||||
break;
|
||||
|
||||
case IGNORE:
|
||||
@@ -225,16 +222,6 @@ public class PartEssentiaLevelEmitter
|
||||
return 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified player can open the gui.
|
||||
*/
|
||||
@Override
|
||||
public boolean doesPlayerHavePermissionToOpenGui( final EntityPlayer player )
|
||||
{
|
||||
// Does the player have build permissions
|
||||
return this.doesPlayerHavePermission( player, SecurityPermissions.BUILD );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( final IPartCollisionHelper helper )
|
||||
{
|
||||
@@ -271,6 +258,16 @@ public class PartEssentiaLevelEmitter
|
||||
return( this.isEmitting ? 7 : 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the redstone mode.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RedstoneMode getRedstoneMode()
|
||||
{
|
||||
return this.redstoneMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the emitter container
|
||||
*/
|
||||
@@ -280,6 +277,27 @@ public class PartEssentiaLevelEmitter
|
||||
return new ContainerPartEssentiaLevelEmitter( this, player );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the threshold level.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getThresholdLevel()
|
||||
{
|
||||
return this.thresholdLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the aspect being tracked.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
public Aspect getTrackedAspect()
|
||||
{
|
||||
return this.trackedAspect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to see if this is emitting strong redstone power
|
||||
*/
|
||||
@@ -305,40 +323,9 @@ public class PartEssentiaLevelEmitter
|
||||
* @param adjustmentAmount
|
||||
* @param player
|
||||
*/
|
||||
public void onClientAdjustWantedAmount( final int adjustmentAmount, final EntityPlayer player )
|
||||
public void onAdjustThresholdLevel( final int adjustmentAmount, final EntityPlayer player )
|
||||
{
|
||||
this.onClientSetWantedAmount( this.wantedAmount + adjustmentAmount, player );
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player has changed the wanted amount
|
||||
*
|
||||
* @param wantedAmount
|
||||
* @param player
|
||||
*/
|
||||
public void onClientSetWantedAmount( final long wantedAmount, final EntityPlayer player )
|
||||
{
|
||||
// Set the wanted amount
|
||||
this.wantedAmount = wantedAmount;
|
||||
|
||||
// Bounds check it
|
||||
if( this.wantedAmount < 0L )
|
||||
{
|
||||
this.wantedAmount = 0L;
|
||||
}
|
||||
else if( this.wantedAmount > 9999999999L )
|
||||
{
|
||||
this.wantedAmount = 9999999999L;
|
||||
}
|
||||
|
||||
// Mark that we need saving
|
||||
this.markForSave();
|
||||
|
||||
// Send validated amount back to the client
|
||||
Packet_C_EssentiaEmitter.setWantedAmount( this.wantedAmount, player );
|
||||
|
||||
// Check if we should be emitting
|
||||
this.updateEmittingState();
|
||||
this.onSetThresholdLevel( this.thresholdLevel + adjustmentAmount, player );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,25 +353,6 @@ public class PartEssentiaLevelEmitter
|
||||
// Check if we should be emitting
|
||||
this.updateEmittingState();
|
||||
|
||||
// Send the new mode to the client
|
||||
Packet_C_EssentiaEmitter.sendRedstoneMode( this.redstoneMode, player );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the a client has requested a full update.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void onClientUpdateRequest( final EntityPlayer player )
|
||||
{
|
||||
// Send the full update to the client
|
||||
Packet_C_EssentiaEmitter.sendEmitterState( this.redstoneMode, this.wantedAmount, player );
|
||||
|
||||
// Send the filter to the client
|
||||
List<Aspect> filter = new ArrayList<Aspect>();
|
||||
filter.add( this.trackedEssentia );
|
||||
Packet_C_AspectSlot.setFilterList( filter, player );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -393,7 +361,35 @@ public class PartEssentiaLevelEmitter
|
||||
@Override
|
||||
public void onEssentiaChange( final Aspect aspect, final long storedAmount, final long changeAmount )
|
||||
{
|
||||
this.setCurrentAmount( storedAmount );
|
||||
this.setCurrentLevel( storedAmount );
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player has changed the wanted amount
|
||||
*
|
||||
* @param threshold
|
||||
* @param player
|
||||
*/
|
||||
public void onSetThresholdLevel( final long threshold, final EntityPlayer player )
|
||||
{
|
||||
// Set the wanted amount
|
||||
this.thresholdLevel = threshold;
|
||||
|
||||
// Bounds check it
|
||||
if( this.thresholdLevel < 0L )
|
||||
{
|
||||
this.thresholdLevel = 0L;
|
||||
}
|
||||
else if( this.thresholdLevel > 9999999999L )
|
||||
{
|
||||
this.thresholdLevel = 9999999999L;
|
||||
}
|
||||
|
||||
// Mark that we need saving
|
||||
this.markForSave();
|
||||
|
||||
// Check if we should be emitting
|
||||
this.updateEmittingState();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -429,7 +425,7 @@ public class PartEssentiaLevelEmitter
|
||||
// Read the filter
|
||||
if( data.hasKey( PartEssentiaLevelEmitter.NBT_KEY_ASPECT_FILTER ) )
|
||||
{
|
||||
this.trackedEssentia = Aspect.aspects.get( data.getString( PartEssentiaLevelEmitter.NBT_KEY_ASPECT_FILTER ) );
|
||||
this.trackedAspect = Aspect.aspects.get( data.getString( PartEssentiaLevelEmitter.NBT_KEY_ASPECT_FILTER ) );
|
||||
}
|
||||
|
||||
// Read the redstone mode
|
||||
@@ -441,7 +437,7 @@ public class PartEssentiaLevelEmitter
|
||||
// Read the wanted amount
|
||||
if( data.hasKey( PartEssentiaLevelEmitter.NBT_KEY_WANTED_AMOUNT ) )
|
||||
{
|
||||
this.wantedAmount = data.getLong( PartEssentiaLevelEmitter.NBT_KEY_WANTED_AMOUNT );
|
||||
this.thresholdLevel = data.getLong( PartEssentiaLevelEmitter.NBT_KEY_WANTED_AMOUNT );
|
||||
}
|
||||
|
||||
// Read if emitting
|
||||
@@ -536,10 +532,10 @@ public class PartEssentiaLevelEmitter
|
||||
@Override
|
||||
public void setAspect( final int index, final Aspect aspect, final EntityPlayer player )
|
||||
{
|
||||
if( this.trackedEssentia != aspect )
|
||||
if( this.trackedAspect != aspect )
|
||||
{
|
||||
// Set the filtered aspect
|
||||
this.trackedEssentia = aspect;
|
||||
this.trackedAspect = aspect;
|
||||
|
||||
// Are we client side?
|
||||
if( EffectiveSide.isClientSide() )
|
||||
@@ -552,11 +548,6 @@ public class PartEssentiaLevelEmitter
|
||||
|
||||
// Update the watcher
|
||||
this.configureWatcher();
|
||||
|
||||
// Send the aspect to the client
|
||||
List<Aspect> filter = new ArrayList<Aspect>();
|
||||
filter.add( aspect );
|
||||
Packet_C_AspectSlot.setFilterList( filter, player );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,30 +594,41 @@ public class PartEssentiaLevelEmitter
|
||||
// Call super
|
||||
super.writeToNBT( data, saveType );
|
||||
|
||||
// Do we have a filter?
|
||||
if( this.trackedEssentia != null )
|
||||
// Only write NBT data if saving, or wrenched.
|
||||
if( ( saveType != PartItemStack.World ) && ( saveType != PartItemStack.Wrench ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Is there a filter?
|
||||
if( this.trackedAspect != null )
|
||||
{
|
||||
// Write the name of the aspect
|
||||
data.setString( PartEssentiaLevelEmitter.NBT_KEY_ASPECT_FILTER, this.trackedEssentia.getTag() );
|
||||
data.setString( PartEssentiaLevelEmitter.NBT_KEY_ASPECT_FILTER, this.trackedAspect.getTag() );
|
||||
}
|
||||
|
||||
// Write the redstone mode ordinal
|
||||
if( this.redstoneMode != PartEssentiaLevelEmitter.DEFAULT_REDSTONE_MODE )
|
||||
// Only save the rest on world save, or if there is a tracked aspect
|
||||
if( ( saveType == PartItemStack.World ) || this.trackedAspect != null )
|
||||
{
|
||||
data.setInteger( PartEssentiaLevelEmitter.NBT_KEY_REDSTONE_MODE, this.redstoneMode.ordinal() );
|
||||
}
|
||||
// Write the redstone mode ordinal
|
||||
if( this.redstoneMode != PartEssentiaLevelEmitter.DEFAULT_REDSTONE_MODE )
|
||||
{
|
||||
data.setInteger( PartEssentiaLevelEmitter.NBT_KEY_REDSTONE_MODE, this.redstoneMode.ordinal() );
|
||||
}
|
||||
|
||||
// Write the threshold amount
|
||||
if( this.wantedAmount > 0 )
|
||||
{
|
||||
data.setLong( PartEssentiaLevelEmitter.NBT_KEY_WANTED_AMOUNT, this.wantedAmount );
|
||||
// Write the threshold amount
|
||||
if( this.thresholdLevel > 0 )
|
||||
{
|
||||
data.setLong( PartEssentiaLevelEmitter.NBT_KEY_WANTED_AMOUNT, this.thresholdLevel );
|
||||
}
|
||||
}
|
||||
|
||||
// Write if emitting
|
||||
if( ( saveType != PartItemStack.Wrench ) && this.isEmitting )
|
||||
if( ( saveType == PartItemStack.World ) && this.isEmitting )
|
||||
{
|
||||
data.setBoolean( PartEssentiaLevelEmitter.NBT_KEY_IS_EMITTING, true );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package thaumicenergistics.common.parts;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -18,8 +19,6 @@ import thaumicenergistics.common.grid.EssentiaMonitor;
|
||||
import thaumicenergistics.common.inventory.HandlerEssentiaStorageBusBase;
|
||||
import thaumicenergistics.common.inventory.HandlerEssentiaStorageBusDuality;
|
||||
import thaumicenergistics.common.network.IAspectSlotPart;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_AspectSlot;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_EssentiaStorageBus;
|
||||
import thaumicenergistics.common.registries.AEPartsEnum;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import thaumicenergistics.integration.tc.EssentiaItemContainerHelper;
|
||||
@@ -69,30 +68,25 @@ public class PartEssentiaStorageBus
|
||||
private static final String NBT_KEY_PRIORITY = "Priority", NBT_KEY_FILTER = "FilterAspects#", NBT_KEY_UPGRADES = "UpgradeInventory",
|
||||
NBT_KEY_VOID = "IsVoidAllowed";
|
||||
|
||||
/**
|
||||
* Storage bus priority
|
||||
*/
|
||||
private int priority = 0;
|
||||
|
||||
/**
|
||||
* "Cell" handler for the storage bus.
|
||||
*/
|
||||
private HandlerEssentiaStorageBusBase handler = new HandlerEssentiaStorageBusDuality( this );
|
||||
private final HandlerEssentiaStorageBusBase handler = new HandlerEssentiaStorageBusDuality( this );
|
||||
|
||||
/**
|
||||
* Filter list
|
||||
*/
|
||||
private List<Aspect> filteredAspects = new ArrayList<Aspect>( PartEssentiaStorageBus.FILTER_SIZE );
|
||||
private final ArrayList<Aspect> filteredAspects = new ArrayList<Aspect>( FILTER_SIZE );
|
||||
|
||||
/**
|
||||
* Upgrade inventory
|
||||
*/
|
||||
private UpgradeInventory upgradeInventory = new StackUpgradeInventory( this.associatedItem, this, 1 );
|
||||
private final UpgradeInventory upgradeInventory = new StackUpgradeInventory( this.associatedItem, this, 1 );
|
||||
|
||||
/**
|
||||
* Containers listening for events
|
||||
* Storage bus priority
|
||||
*/
|
||||
private List<ContainerPartEssentiaStorageBus> listeners = new ArrayList<ContainerPartEssentiaStorageBus>();
|
||||
private int priority = 0;
|
||||
|
||||
/**
|
||||
* Creates the bus
|
||||
@@ -100,7 +94,7 @@ public class PartEssentiaStorageBus
|
||||
public PartEssentiaStorageBus()
|
||||
{
|
||||
// Call super
|
||||
super( AEPartsEnum.EssentiaStorageBus );
|
||||
super( AEPartsEnum.EssentiaStorageBus, SecurityPermissions.EXTRACT, SecurityPermissions.INJECT );
|
||||
|
||||
// Pre-fill the list with nulls
|
||||
for( int index = 0; index < PartEssentiaStorageBus.FILTER_SIZE; index++ )
|
||||
@@ -109,17 +103,6 @@ public class PartEssentiaStorageBus
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies all listening containers that the filter list changed.
|
||||
*/
|
||||
private void notifyListenersOfFilteredAspectsChange()
|
||||
{
|
||||
for( ContainerPartEssentiaStorageBus listner : this.listeners )
|
||||
{
|
||||
listner.setFilteredAspects( this.filteredAspects );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the handler on the inverted state.
|
||||
*/
|
||||
@@ -167,19 +150,6 @@ public class PartEssentiaStorageBus
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listener for events.
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
public void addListener( final ContainerPartEssentiaStorageBus listener )
|
||||
{
|
||||
if( !this.listeners.contains( listener ) )
|
||||
{
|
||||
this.listeners.add( listener );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignored
|
||||
*/
|
||||
@@ -198,24 +168,6 @@ public class PartEssentiaStorageBus
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified player can open the gui.
|
||||
*/
|
||||
@Override
|
||||
public boolean doesPlayerHavePermissionToOpenGui( final EntityPlayer player )
|
||||
{
|
||||
// Does the player have export & import permissions
|
||||
if( this.doesPlayerHavePermission( player, SecurityPermissions.EXTRACT ) )
|
||||
{
|
||||
if( this.doesPlayerHavePermission( player, SecurityPermissions.INJECT ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts power from the network proportional to the specified essentia
|
||||
* amount.
|
||||
@@ -300,13 +252,6 @@ public class PartEssentiaStorageBus
|
||||
@Override
|
||||
public void getDrops( final List<ItemStack> drops, final boolean wrenched )
|
||||
{
|
||||
// Were we wrenched?
|
||||
if( wrenched )
|
||||
{
|
||||
// No drops
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the upgrade card
|
||||
ItemStack slotStack = this.upgradeInventory.getStackInSlot( 0 );
|
||||
|
||||
@@ -318,6 +263,17 @@ public class PartEssentiaStorageBus
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the aspect in the filter slot.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
public Aspect getFilteredAspect( final int slotIndex )
|
||||
{
|
||||
return this.filteredAspects.get( slotIndex );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines how much power the part takes for just existing.
|
||||
*/
|
||||
@@ -374,6 +330,16 @@ public class PartEssentiaStorageBus
|
||||
return this.upgradeInventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is voiding of essentia allowed?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isVoidAllowed()
|
||||
{
|
||||
return this.handler.isVoidAllowed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the upgrade inventory changes.
|
||||
*/
|
||||
@@ -383,20 +349,6 @@ public class PartEssentiaStorageBus
|
||||
this.updateInverterState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a client is requesting a full update
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void onClientRequestFullUpdate( final EntityPlayer player )
|
||||
{
|
||||
// Send the void mode
|
||||
Packet_C_EssentiaStorageBus.sendIsVoidAllowed( player, this.handler.isVoidAllowed() );
|
||||
|
||||
// Send the filter
|
||||
Packet_C_AspectSlot.setFilterList( this.filteredAspects, player );
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player has changed void mode via gui.
|
||||
*
|
||||
@@ -485,6 +437,7 @@ public class PartEssentiaStorageBus
|
||||
{
|
||||
this.upgradeInventory.readFromNBT( data, PartEssentiaStorageBus.NBT_KEY_UPGRADES );
|
||||
|
||||
// TODO: Is this needed or will onChange be called?
|
||||
// Update the handler inverted
|
||||
this.updateInverterState();
|
||||
}
|
||||
@@ -499,16 +452,6 @@ public class PartEssentiaStorageBus
|
||||
this.handler.setPrioritizedAspects( this.filteredAspects );
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a listener
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
public void removeListener( final ContainerPartEssentiaStorageBus listener )
|
||||
{
|
||||
this.listeners.remove( listener );
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the storage bus in the player inventory
|
||||
*/
|
||||
@@ -602,9 +545,6 @@ public class PartEssentiaStorageBus
|
||||
// Update the handler
|
||||
this.handler.setPrioritizedAspects( this.filteredAspects );
|
||||
|
||||
// Update the clients
|
||||
this.notifyListenersOfFilteredAspectsChange();
|
||||
|
||||
// Update the grid
|
||||
this.postGridUpdateEvent();
|
||||
|
||||
@@ -641,13 +581,14 @@ public class PartEssentiaStorageBus
|
||||
// Call super
|
||||
super.writeToNBT( data, saveType );
|
||||
|
||||
// Write the priority
|
||||
if( this.priority > 0 )
|
||||
// Only write NBT data if saving, or wrenched.
|
||||
if( ( saveType != PartItemStack.World ) && ( saveType != PartItemStack.Wrench ) )
|
||||
{
|
||||
data.setInteger( PartEssentiaStorageBus.NBT_KEY_PRIORITY, this.priority );
|
||||
return;
|
||||
}
|
||||
|
||||
// Write the filters
|
||||
boolean hasFilters = false;
|
||||
for( int index = 0; index < PartEssentiaStorageBus.FILTER_SIZE; index++ )
|
||||
{
|
||||
Aspect aspect = this.filteredAspects.get( index );
|
||||
@@ -655,20 +596,32 @@ public class PartEssentiaStorageBus
|
||||
if( aspect != null )
|
||||
{
|
||||
data.setString( PartEssentiaStorageBus.NBT_KEY_FILTER + index, aspect.getTag() );
|
||||
hasFilters = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Only save the rest if filters are set, or world save
|
||||
if( hasFilters || ( saveType == PartItemStack.World ) )
|
||||
{
|
||||
// Write the priority
|
||||
if( this.priority > 0 )
|
||||
{
|
||||
data.setInteger( PartEssentiaStorageBus.NBT_KEY_PRIORITY, this.priority );
|
||||
}
|
||||
|
||||
// Write void
|
||||
if( this.handler.isVoidAllowed() )
|
||||
{
|
||||
data.setBoolean( PartEssentiaStorageBus.NBT_KEY_VOID, this.handler.isVoidAllowed() );
|
||||
}
|
||||
}
|
||||
|
||||
// Write upgrades
|
||||
if( !this.upgradeInventory.isEmpty() )
|
||||
if( ( saveType == PartItemStack.World ) && !this.upgradeInventory.isEmpty() )
|
||||
{
|
||||
this.upgradeInventory.writeToNBT( data, PartEssentiaStorageBus.NBT_KEY_UPGRADES );
|
||||
}
|
||||
|
||||
// Write void
|
||||
if( this.handler.isVoidAllowed() )
|
||||
{
|
||||
data.setBoolean( PartEssentiaStorageBus.NBT_KEY_VOID, this.handler.isVoidAllowed() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -977,6 +977,12 @@ public class PartEssentiaStorageMonitor
|
||||
// Call super
|
||||
super.writeToNBT( data, saveType );
|
||||
|
||||
// Only save on world
|
||||
if( saveType != PartItemStack.World )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Write locked
|
||||
if( this.monitorLocked )
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.api.grid.ICraftingIssuerHost;
|
||||
import thaumicenergistics.client.gui.GuiEssentiaCellTerminal;
|
||||
import thaumicenergistics.client.textures.BlockTextureManager;
|
||||
@@ -79,6 +80,12 @@ public class PartEssentiaTerminal
|
||||
*/
|
||||
private ViewItems viewMode = DEFAULT_VIEW_MODE;
|
||||
|
||||
/**
|
||||
* The selected aspect in the GUI.
|
||||
* Only stored while the part is loaded.
|
||||
*/
|
||||
public Aspect selectedAspect = null;
|
||||
|
||||
private TheInternalInventory inventory = new TheInternalInventory( ThaumicEnergistics.MOD_ID + ".part.aspect.terminal", 2, 64 )
|
||||
{
|
||||
@Override
|
||||
@@ -123,15 +130,6 @@ public class PartEssentiaTerminal
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified player can open the gui.
|
||||
*/
|
||||
@Override
|
||||
public boolean doesPlayerHavePermissionToOpenGui( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( final IPartCollisionHelper helper )
|
||||
{
|
||||
@@ -444,6 +442,12 @@ public class PartEssentiaTerminal
|
||||
// Call super
|
||||
super.writeToNBT( data, saveType );
|
||||
|
||||
// Only write NBT data if saving, or wrenched.
|
||||
if( ( saveType != PartItemStack.World ) && ( saveType != PartItemStack.Wrench ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Write the sorting mode
|
||||
if( this.sortMode != DEFAULT_SORT_MODE )
|
||||
{
|
||||
|
||||
@@ -741,8 +741,8 @@ public class PartVisInterface
|
||||
// Call super
|
||||
super.writeToNBT( data, saveType );
|
||||
|
||||
// Do not save details if being wrenched.
|
||||
if( saveType == PartItemStack.Wrench )
|
||||
// Only write NBT if world save
|
||||
if( saveType != PartItemStack.World )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,10 +22,13 @@ import thaumicenergistics.common.ThEGuiHandler;
|
||||
import thaumicenergistics.common.grid.AEPartGridBlock;
|
||||
import thaumicenergistics.common.registries.AEPartsEnum;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
@@ -40,7 +43,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class ThEPartBase
|
||||
implements IPart, IGridHost, IActionHost
|
||||
implements IPart, IGridHost, IActionHost, IPowerChannelState
|
||||
{
|
||||
private final static String NBT_KEY_OWNER = "Owner";
|
||||
|
||||
@@ -56,6 +59,11 @@ public abstract class ThEPartBase
|
||||
*/
|
||||
protected final static int ACTIVE_TERMINAL_LIGHT_LEVEL = 9;
|
||||
|
||||
/**
|
||||
* Permission levels required to interact with the part.
|
||||
*/
|
||||
private final SecurityPermissions[] interactionPermissions;
|
||||
|
||||
/**
|
||||
* The PartHost attached to.
|
||||
*/
|
||||
@@ -76,6 +84,11 @@ public abstract class ThEPartBase
|
||||
*/
|
||||
private boolean isActive;
|
||||
|
||||
/**
|
||||
* Is the network powered?
|
||||
*/
|
||||
private boolean isPowered;
|
||||
|
||||
/**
|
||||
* The parts grid node.
|
||||
*/
|
||||
@@ -101,10 +114,27 @@ public abstract class ThEPartBase
|
||||
*/
|
||||
public final ItemStack associatedItem;
|
||||
|
||||
public ThEPartBase( final AEPartsEnum associatedPart )
|
||||
/**
|
||||
* Creates the part.
|
||||
*
|
||||
* @param associatedPart
|
||||
* @param interactionPermissions
|
||||
* Permissions required to interact with the part.
|
||||
*/
|
||||
public ThEPartBase( final AEPartsEnum associatedPart, final SecurityPermissions ... interactionPermissions )
|
||||
{
|
||||
// Set the associated item
|
||||
this.associatedItem = associatedPart.getStack();
|
||||
|
||||
// Set clearance
|
||||
if( ( interactionPermissions != null ) && ( interactionPermissions.length > 0 ) )
|
||||
{
|
||||
this.interactionPermissions = interactionPermissions;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.interactionPermissions = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateStatus()
|
||||
@@ -244,17 +274,6 @@ public abstract class ThEPartBase
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before a gui is shown to ensure a player has permission to do so.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean doesPlayerHavePermissionToOpenGui( final EntityPlayer player )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode()
|
||||
{
|
||||
@@ -337,8 +356,8 @@ public abstract class ThEPartBase
|
||||
// Get the itemstack
|
||||
ItemStack itemStack = this.associatedItem.copy();
|
||||
|
||||
// Save NBT data if the part was wrenched or creatively picked
|
||||
if( ( type == PartItemStack.Wrench ) || ( type == PartItemStack.Pick ) )
|
||||
// Save NBT data if the part was wrenched
|
||||
if( type == PartItemStack.Wrench )
|
||||
{
|
||||
// Create the item tag
|
||||
NBTTagCompound itemNBT = new NBTTagCompound();
|
||||
@@ -402,6 +421,7 @@ public abstract class ThEPartBase
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
// Are we server side?
|
||||
@@ -413,6 +433,10 @@ public abstract class ThEPartBase
|
||||
// Get it's activity
|
||||
this.isActive = this.node.isActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
return this.isActive;
|
||||
@@ -424,6 +448,27 @@ public abstract class ThEPartBase
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
// Server side?
|
||||
if( EffectiveSide.isServerSide() )
|
||||
{
|
||||
// Get the energy grid
|
||||
IEnergyGrid eGrid = this.gridBlock.getEnergyGrid();
|
||||
if( eGrid != null )
|
||||
{
|
||||
this.isPowered = eGrid.isNetworkPowered();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isPowered = false;
|
||||
}
|
||||
}
|
||||
|
||||
return this.isPowered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower()
|
||||
{
|
||||
@@ -452,6 +497,56 @@ 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.
|
||||
*/
|
||||
@@ -551,14 +646,16 @@ public abstract class ThEPartBase
|
||||
@Override
|
||||
public boolean readFromStream( final ByteBuf stream ) throws IOException
|
||||
{
|
||||
// Cache if we were active
|
||||
// Cache old values
|
||||
boolean oldActive = this.isActive;
|
||||
boolean oldPowered = this.isPowered;
|
||||
|
||||
// Read the new active
|
||||
// Read the new values
|
||||
this.isActive = stream.readBoolean();
|
||||
this.isPowered = stream.readBoolean();
|
||||
|
||||
// Redraw if they don't match.
|
||||
return( oldActive != this.isActive );
|
||||
return( ( oldActive != this.isActive ) || ( oldPowered != this.isPowered ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -736,7 +833,7 @@ public abstract class ThEPartBase
|
||||
*/
|
||||
public void writeToNBT( final NBTTagCompound data, final PartItemStack saveType )
|
||||
{
|
||||
if( saveType != PartItemStack.Wrench )
|
||||
if( saveType == PartItemStack.World )
|
||||
{
|
||||
// Set the owner ID
|
||||
data.setInteger( ThEPartBase.NBT_KEY_OWNER, this.ownerID );
|
||||
@@ -747,7 +844,11 @@ public abstract class ThEPartBase
|
||||
@Override
|
||||
public void writeToStream( final ByteBuf stream ) throws IOException
|
||||
{
|
||||
stream.writeBoolean( ( this.node != null ) && ( this.node.isActive() ) );
|
||||
// Write active
|
||||
stream.writeBoolean( this.isActive() );
|
||||
|
||||
// Write powered
|
||||
stream.writeBoolean( this.isPowered() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import thaumicenergistics.integration.tc.EssentiaItemContainerHelper;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
@@ -115,9 +116,9 @@ public abstract class ThEPartEssentiaIOBus_Base
|
||||
private static final String NBT_KEY_REDSTONE_MODE = "redstoneMode", NBT_KEY_FILTER_NUMBER = "AspectFilter#",
|
||||
NBT_KEY_UPGRADE_INV = "upgradeInventory";
|
||||
|
||||
public ThEPartEssentiaIOBus_Base( final AEPartsEnum associatedPart )
|
||||
public ThEPartEssentiaIOBus_Base( final AEPartsEnum associatedPart, final SecurityPermissions ... interactionPermissions )
|
||||
{
|
||||
super( associatedPart );
|
||||
super( associatedPart, interactionPermissions );
|
||||
|
||||
// Initialize the list
|
||||
for( int index = 0; index < ThEPartEssentiaIOBus_Base.MAX_FILTER_SIZE; index++ )
|
||||
@@ -344,13 +345,6 @@ public abstract class ThEPartEssentiaIOBus_Base
|
||||
@Override
|
||||
public void getDrops( final List<ItemStack> drops, final boolean wrenched )
|
||||
{
|
||||
// Were we wrenched?
|
||||
if( wrenched )
|
||||
{
|
||||
// No drops
|
||||
return;
|
||||
}
|
||||
|
||||
// Add upgrades to drops
|
||||
for( int slotIndex = 0; slotIndex < ThEPartEssentiaIOBus_Base.UPGRADE_INVENTORY_SIZE; slotIndex++ )
|
||||
{
|
||||
@@ -407,6 +401,11 @@ public abstract class ThEPartEssentiaIOBus_Base
|
||||
return this.upgradeInventory;
|
||||
}
|
||||
|
||||
public boolean isVoidAllowed()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivate( final EntityPlayer player, final Vec3 position )
|
||||
{
|
||||
@@ -454,7 +453,7 @@ public abstract class ThEPartEssentiaIOBus_Base
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void onClientRequestFullUpdate( final EntityPlayer player )
|
||||
public void onClientRequestFilterList( final EntityPlayer player )
|
||||
{
|
||||
// Set the filter list
|
||||
Packet_C_AspectSlot.setFilterList( this.filteredAspects, player );
|
||||
@@ -537,27 +536,18 @@ public abstract class ThEPartEssentiaIOBus_Base
|
||||
super.readFromNBT( data );
|
||||
|
||||
// Read redstone mode
|
||||
if( data.hasKey( ThEPartEssentiaIOBus_Base.NBT_KEY_REDSTONE_MODE ) )
|
||||
if( data.hasKey( NBT_KEY_REDSTONE_MODE ) )
|
||||
{
|
||||
this.redstoneMode = EnumCache.AE_REDSTONE_MODES[data.getInteger( ThEPartEssentiaIOBus_Base.NBT_KEY_REDSTONE_MODE )];
|
||||
this.redstoneMode = EnumCache.AE_REDSTONE_MODES[data.getInteger( NBT_KEY_REDSTONE_MODE )];
|
||||
}
|
||||
|
||||
// Read filters
|
||||
for( int index = 0; index < ThEPartEssentiaIOBus_Base.MAX_FILTER_SIZE; index++ )
|
||||
for( int index = 0; index < MAX_FILTER_SIZE; index++ )
|
||||
{
|
||||
if( data.hasKey( ThEPartEssentiaIOBus_Base.NBT_KEY_FILTER_NUMBER + index ) )
|
||||
if( data.hasKey( NBT_KEY_FILTER_NUMBER + index ) )
|
||||
{
|
||||
Aspect filterAspect = null;
|
||||
|
||||
// Get the name of the aspect
|
||||
String aspectTag = data.getString( ThEPartEssentiaIOBus_Base.NBT_KEY_FILTER_NUMBER + index );
|
||||
if( !aspectTag.equals( "" ) )
|
||||
{
|
||||
filterAspect = Aspect.aspects.get( aspectTag );
|
||||
|
||||
}
|
||||
|
||||
this.filteredAspects.set( index, filterAspect );
|
||||
// Get the aspect
|
||||
this.filteredAspects.set( index, Aspect.aspects.get( data.getString( NBT_KEY_FILTER_NUMBER + index ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,30 +620,32 @@ public abstract class ThEPartEssentiaIOBus_Base
|
||||
// Call super
|
||||
super.writeToNBT( data, saveType );
|
||||
|
||||
// Write the redstone mode
|
||||
if( this.redstoneMode != ThEPartEssentiaIOBus_Base.DEFAULT_REDSTONE_MODE )
|
||||
if( ( saveType == PartItemStack.World ) || ( saveType == PartItemStack.Wrench ) )
|
||||
{
|
||||
data.setInteger( ThEPartEssentiaIOBus_Base.NBT_KEY_REDSTONE_MODE, this.redstoneMode.ordinal() );
|
||||
}
|
||||
|
||||
// Write each filter
|
||||
for( int i = 0; i < ThEPartEssentiaIOBus_Base.MAX_FILTER_SIZE; i++ )
|
||||
{
|
||||
Aspect aspect = this.filteredAspects.get( i );
|
||||
String aspectTag = "";
|
||||
|
||||
if( aspect != null )
|
||||
// Write each filter
|
||||
for( int i = 0; i < MAX_FILTER_SIZE; i++ )
|
||||
{
|
||||
aspectTag = aspect.getTag();
|
||||
Aspect aspect = this.filteredAspects.get( i );
|
||||
if( aspect != null )
|
||||
{
|
||||
data.setString( NBT_KEY_FILTER_NUMBER + i, aspect.getTag() );
|
||||
}
|
||||
}
|
||||
|
||||
data.setString( ThEPartEssentiaIOBus_Base.NBT_KEY_FILTER_NUMBER + i, aspectTag );
|
||||
}
|
||||
if( saveType == PartItemStack.World )
|
||||
{
|
||||
// Write the redstone mode
|
||||
if( this.redstoneMode != DEFAULT_REDSTONE_MODE )
|
||||
{
|
||||
data.setInteger( NBT_KEY_REDSTONE_MODE, this.redstoneMode.ordinal() );
|
||||
}
|
||||
|
||||
// Write the upgrade inventory
|
||||
if( !this.upgradeInventory.isEmpty() )
|
||||
{
|
||||
this.upgradeInventory.writeToNBT( data, ThEPartEssentiaIOBus_Base.NBT_KEY_UPGRADE_INV );
|
||||
// Write the upgrade inventory
|
||||
if( !this.upgradeInventory.isEmpty() )
|
||||
{
|
||||
this.upgradeInventory.writeToNBT( data, NBT_KEY_UPGRADE_INV );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import thaumicenergistics.common.registries.AEPartsEnum;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@@ -26,9 +27,9 @@ public abstract class ThERotateablePart
|
||||
*/
|
||||
private byte renderRotation = 0;
|
||||
|
||||
public ThERotateablePart( final AEPartsEnum associatedPart )
|
||||
public ThERotateablePart( final AEPartsEnum associatedPart, final SecurityPermissions ... interactionPermissions )
|
||||
{
|
||||
super( associatedPart );
|
||||
super( associatedPart, interactionPermissions );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +141,7 @@ public abstract class ThERotateablePart
|
||||
super.writeToNBT( data, saveType );
|
||||
|
||||
// Write the rotation
|
||||
if( this.renderRotation != 0 )
|
||||
if( ( saveType == PartItemStack.World ) && ( this.renderRotation != 0 ) )
|
||||
{
|
||||
data.setByte( ThERotateablePart.NBT_KEY_ROT_DIR, this.renderRotation );
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ public enum ThEStrings
|
||||
Tooltip_ArcaneAssemblerHasVis ("tooltip.arcane.assembler.hasVis", false),
|
||||
|
||||
// Button Tooltips
|
||||
TooltipButton_DepositCraftingGrid ("tooltip.button.clear.crafting", false),
|
||||
TooltipButton_VoidHeader ("tooltip.button.void", false),
|
||||
TooltipButton_VoidAllow ("tooltip.button.void.allowed", false),
|
||||
TooltipButton_VoidDisable ("tooltip.button.void.disabled", false),
|
||||
|
||||
@@ -12,7 +12,7 @@ public enum TileEnum
|
||||
ArcaneAssembler ("TileArcaneAssembler", TileArcaneAssembler.class),
|
||||
KnowledgeInscriber ("TileKnowledgeInscriber", TileKnowledgeInscriber.class),
|
||||
EssentiaVibrationChamber ("TileEssentiaVibrationChamber", TileEssentiaVibrationChamber.class),
|
||||
DistillationInscriber ("TileDistillationInscriber", TileDistillationEncoder.class);
|
||||
DistillationInscriber ("TileDistillationInscriber", TileDistillationPatternEncoder.class);
|
||||
|
||||
/**
|
||||
* Unique ID of the tile entity
|
||||
|
||||
@@ -292,6 +292,12 @@ public class AspectStack
|
||||
this.stackSize = stack.getStackSize();
|
||||
this.isCraftable = stack.getCraftable();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.aspect = null;
|
||||
this.stackSize = 0;
|
||||
this.isCraftable = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -303,7 +303,7 @@ public class TileArcaneAssembler
|
||||
|
||||
// Mark the assembler as no longer crafting
|
||||
this.isCrafting = false;
|
||||
this.internalInventory.clearSlot( TARGET_SLOT_INDEX );
|
||||
this.internalInventory.setInventorySlotContents( TARGET_SLOT_INDEX, null );
|
||||
this.currentPattern = null;
|
||||
|
||||
// Mark for network update
|
||||
@@ -526,7 +526,7 @@ public class TileArcaneAssembler
|
||||
else
|
||||
{
|
||||
// Clear slot
|
||||
this.internalInventory.clearSlot( index );
|
||||
this.internalInventory.setInventorySlotContents( index, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-16
@@ -3,11 +3,10 @@ package thaumicenergistics.common.tiles;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import thaumicenergistics.common.items.ItemCraftingAspect;
|
||||
import thaumicenergistics.common.tiles.abstraction.ThETileInventory;
|
||||
import appeng.api.AEApi;
|
||||
|
||||
public class TileDistillationEncoder
|
||||
public class TileDistillationPatternEncoder
|
||||
extends ThETileInventory
|
||||
{
|
||||
/**
|
||||
@@ -18,28 +17,33 @@ public class TileDistillationEncoder
|
||||
/**
|
||||
* Slot counts
|
||||
*/
|
||||
public static int SLOT_SOURCE_ASPECTS_COUNT = 6,
|
||||
SLOT_SELECTED_ASPECT_COUNT = 1,
|
||||
SLOT_PATTERNS_COUNT = 2,
|
||||
public static int SLOT_PATTERNS_COUNT = 2,
|
||||
SLOT_SOURCE_ITEM_COUNT = 1,
|
||||
SLOT_TOTAL_COUNT = SLOT_SOURCE_ITEM_COUNT + SLOT_SOURCE_ASPECTS_COUNT + SLOT_SELECTED_ASPECT_COUNT + SLOT_PATTERNS_COUNT;
|
||||
SLOT_TOTAL_COUNT = SLOT_SOURCE_ITEM_COUNT + SLOT_PATTERNS_COUNT;
|
||||
/**
|
||||
* Slot ID's
|
||||
*/
|
||||
public static int SLOT_SOURCE_ITEM = 0,
|
||||
SLOT_BLANK_PATTERNS = 1,
|
||||
SLOT_ENCODED_PATTERN = 2,
|
||||
SLOT_SOURCE_ASPECTS = 3,
|
||||
SLOT_SELECTED_ASPECT = SLOT_SOURCE_ASPECTS + SLOT_SOURCE_ASPECTS_COUNT;
|
||||
SLOT_ENCODED_PATTERN = 2;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public TileDistillationEncoder()
|
||||
public TileDistillationPatternEncoder()
|
||||
{
|
||||
super( "distillation.inscriber", SLOT_TOTAL_COUNT, 64 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Does not need ticks.
|
||||
*/
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of items to drop when broken.
|
||||
*
|
||||
@@ -96,12 +100,6 @@ public class TileDistillationEncoder
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import thaumicenergistics.common.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.container.ContainerEssentiaCellWorkbench;
|
||||
import thaumicenergistics.common.inventory.HandlerItemEssentiaCell;
|
||||
import thaumicenergistics.common.items.ItemEssentiaCell;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_AspectSlot;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
|
||||
@@ -21,6 +21,9 @@ public class TileEssentiaCellWorkbench
|
||||
extends TileEntity
|
||||
implements IInventory, ISaveProvider
|
||||
{
|
||||
/**
|
||||
* NBT Keys
|
||||
*/
|
||||
private static String NBT_KEY_CELL = "EssentiaCell";
|
||||
|
||||
/**
|
||||
@@ -36,32 +39,44 @@ public class TileEssentiaCellWorkbench
|
||||
/**
|
||||
* List of containers that are open.
|
||||
*/
|
||||
private final List<ContainerEssentiaCellWorkbench> openContainers = new ArrayList<ContainerEssentiaCellWorkbench>();
|
||||
private final List<ContainerEssentiaCellWorkbench> listeners = new ArrayList<ContainerEssentiaCellWorkbench>();
|
||||
|
||||
public TileEssentiaCellWorkbench()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces all containers to sync the cell itemstack
|
||||
* Notifies listeners that the partition list has changed.
|
||||
*/
|
||||
private void forceContainerSyncCell()
|
||||
private void notifyListenersOfPartitionChange()
|
||||
{
|
||||
for( ContainerEssentiaCellWorkbench container : this.openContainers )
|
||||
ArrayList<Aspect> partitionList = this.getPartitionList();
|
||||
|
||||
// Update each listener
|
||||
for( ContainerEssentiaCellWorkbench container : this.listeners )
|
||||
{
|
||||
container.onForceSyncCell();
|
||||
container.onPartitionChanged( partitionList );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the open containers that the cell changed.
|
||||
* Attempts to add an aspect to the partition.
|
||||
*
|
||||
* @param aspect
|
||||
*/
|
||||
private void onCellChanged()
|
||||
public boolean addAspectToPartition( final Aspect aspect )
|
||||
{
|
||||
for( ContainerEssentiaCellWorkbench container : this.openContainers )
|
||||
if( ( this.eCellHandler != null ) )
|
||||
{
|
||||
container.onCellChanged();
|
||||
if( this.eCellHandler.addAspectToPartitionList( aspect ) )
|
||||
{
|
||||
// Update listeners
|
||||
this.notifyListenersOfPartitionChange();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,6 +88,24 @@ public class TileEssentiaCellWorkbench
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all partitioning.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void clearAllPartitioning()
|
||||
{
|
||||
// Ensure there is a handler
|
||||
if( this.eCellHandler != null )
|
||||
{
|
||||
// Clear the partitioning
|
||||
this.eCellHandler.clearPartitioning();
|
||||
|
||||
// Update listeners
|
||||
this.notifyListenersOfPartitionChange();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
@@ -110,6 +143,30 @@ public class TileEssentiaCellWorkbench
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the partition list.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ArrayList<Aspect> getPartitionList()
|
||||
{
|
||||
ArrayList<Aspect> partitionList;
|
||||
|
||||
// Ensure there is a handler
|
||||
if( ( this.eCellHandler != null ) )
|
||||
{
|
||||
// Get the partition list
|
||||
partitionList = this.eCellHandler.getPartitionAspects();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create an empty list
|
||||
partitionList = new ArrayList<Aspect>();
|
||||
}
|
||||
|
||||
return partitionList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
@@ -162,120 +219,7 @@ public class TileEssentiaCellWorkbench
|
||||
@Override
|
||||
public boolean isUseableByPlayer( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A client requests to add an aspect to the partition list.
|
||||
*
|
||||
* @param aspect
|
||||
*/
|
||||
public boolean onClientRequestAddAspectToPartitionList( final EntityPlayer player, final Aspect aspect )
|
||||
{
|
||||
if( ( this.eCellHandler != null ) )
|
||||
{
|
||||
if( this.eCellHandler.addAspectToPartitionList( aspect ) )
|
||||
{
|
||||
// Re-send the list
|
||||
this.onClientRequestPartitionList( player );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A client requests all partition data be removed.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void onClientRequestClearPartitioning( final EntityPlayer player )
|
||||
{
|
||||
if( this.eCellHandler != null )
|
||||
{
|
||||
this.eCellHandler.clearPartitioning();
|
||||
|
||||
// Re-send the list
|
||||
this.onClientRequestPartitionList( player );
|
||||
|
||||
// Force containers to update the cell item.
|
||||
this.forceContainerSyncCell();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A client requests the partition list.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void onClientRequestPartitionList( final EntityPlayer player )
|
||||
{
|
||||
List<Aspect> partitionList;
|
||||
|
||||
if( ( this.eCellHandler != null ) )
|
||||
{
|
||||
partitionList = this.eCellHandler.getPartitionAspects();
|
||||
}
|
||||
else
|
||||
{
|
||||
partitionList = new ArrayList<Aspect>();
|
||||
}
|
||||
|
||||
// Send to client
|
||||
Packet_C_AspectSlot.setFilterList( partitionList, player );
|
||||
}
|
||||
|
||||
/**
|
||||
* A client requests the cell partition list be set to match
|
||||
* the contents of the cell.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void onClientRequestPartitionToContents( final EntityPlayer player )
|
||||
{
|
||||
if( this.eCellHandler != null )
|
||||
{
|
||||
this.eCellHandler.partitionToCellContents();
|
||||
|
||||
// Re-send the list
|
||||
this.onClientRequestPartitionList( player );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A client requests to remove an aspect from the partition list.
|
||||
*
|
||||
* @param aspect
|
||||
*/
|
||||
public void onClientRequestRemoveAspectFromPartitionList( final EntityPlayer player, final Aspect aspect )
|
||||
{
|
||||
if( ( this.eCellHandler != null ) )
|
||||
{
|
||||
if( this.eCellHandler.removeAspectFromPartitionList( aspect ) )
|
||||
{
|
||||
// Re-send the list
|
||||
this.onClientRequestPartitionList( player );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A client requests to replace an aspect from the partition list.
|
||||
*
|
||||
* @param aspect
|
||||
*/
|
||||
public void onClientRequestReplaceAspectFromPartitionList( final EntityPlayer player, final Aspect fromAspect, final Aspect toAspect )
|
||||
{
|
||||
if( this.eCellHandler != null )
|
||||
{
|
||||
if( this.eCellHandler.replaceAspectInPartitionList( fromAspect, toAspect ) )
|
||||
{
|
||||
// Re-send the list
|
||||
this.onClientRequestPartitionList( player );
|
||||
}
|
||||
}
|
||||
return ThEUtils.canPlayerInteractWith( player, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -284,6 +228,24 @@ public class TileEssentiaCellWorkbench
|
||||
// Ignored
|
||||
}
|
||||
|
||||
/**
|
||||
* Partitions the cell be set to the contents of the cell.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void partitionToCellContents()
|
||||
{
|
||||
// Ensure there is a handler
|
||||
if( this.eCellHandler != null )
|
||||
{
|
||||
// Partition the cell
|
||||
this.eCellHandler.partitionToCellContents();
|
||||
|
||||
// Update listeners
|
||||
this.notifyListenersOfPartitionChange();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the workbench.
|
||||
*/
|
||||
@@ -307,24 +269,43 @@ public class TileEssentiaCellWorkbench
|
||||
*
|
||||
* @param container
|
||||
*/
|
||||
public void registerContainer( final ContainerEssentiaCellWorkbench container )
|
||||
public void registerListener( final ContainerEssentiaCellWorkbench container )
|
||||
{
|
||||
if( !this.openContainers.contains( container ) )
|
||||
if( !this.listeners.contains( container ) )
|
||||
{
|
||||
this.openContainers.add( container );
|
||||
this.listeners.add( container );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an aspect from the partition.
|
||||
*
|
||||
* @param aspect
|
||||
*/
|
||||
public void removeAspectFromPartition( final Aspect aspect )
|
||||
{
|
||||
// Ensure there is a handler
|
||||
if( ( this.eCellHandler != null ) )
|
||||
{
|
||||
// Remove from the partition list
|
||||
if( this.eCellHandler.removeAspectFromPartitionList( aspect ) )
|
||||
{
|
||||
// Update listeners
|
||||
this.notifyListenersOfPartitionChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a container.
|
||||
* It will no longer receive notifications when the cell changes.
|
||||
*
|
||||
* @param container
|
||||
*/
|
||||
public void removeContainer( final ContainerEssentiaCellWorkbench container )
|
||||
public void removeListener( final ContainerEssentiaCellWorkbench container )
|
||||
{
|
||||
this.openContainers.remove( container );
|
||||
this.listeners.remove( container );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,7 +314,8 @@ public class TileEssentiaCellWorkbench
|
||||
@Override
|
||||
public void saveChanges( final IMEInventory cellInventory )
|
||||
{
|
||||
// Mark the chunk as needing to be saved.( less invasive than this.markDirty() )
|
||||
// Mark the chunk as needing to be saved.
|
||||
// Much less invasive than markDirty(), which issues onNeighborChanged events to a 12 block radius...
|
||||
this.worldObj.markTileEntityChunkModified( this.xCoord, this.yCoord, this.zCoord, this );
|
||||
}
|
||||
|
||||
@@ -364,7 +346,26 @@ public class TileEssentiaCellWorkbench
|
||||
}
|
||||
|
||||
// Update containers
|
||||
this.onCellChanged();
|
||||
this.notifyListenersOfPartitionChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces one aspect with another.
|
||||
*
|
||||
* @param aspect
|
||||
*/
|
||||
public void swapPartitionedAspect( final Aspect fromAspect, final Aspect toAspect )
|
||||
{
|
||||
// Ensure there is a handler
|
||||
if( this.eCellHandler != null )
|
||||
{
|
||||
// Replace the aspect
|
||||
if( this.eCellHandler.replaceAspectInPartitionList( fromAspect, toAspect ) )
|
||||
{
|
||||
// Update listeners
|
||||
this.notifyListenersOfPartitionChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package thaumicenergistics.common.tiles;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import thaumicenergistics.common.inventory.HandlerKnowledgeCore;
|
||||
import thaumicenergistics.common.items.ItemKnowledgeCore;
|
||||
import thaumicenergistics.common.tiles.abstraction.ThETileInventory;
|
||||
|
||||
@@ -10,15 +9,17 @@ 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";
|
||||
|
||||
public TileKnowledgeInscriber()
|
||||
{
|
||||
super( "knowledge.inscriber", 32, 64 );
|
||||
super( "knowledge.inscriber", 1, 64 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -82,6 +82,12 @@ public abstract class ThETileInventory
|
||||
return this.internalInventory.isUseableByPlayer( player, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
this.worldObj.markTileEntityChunkModified( this.xCoord, this.yCoord, this.zCoord, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
|
||||
@@ -174,11 +174,16 @@ public class DistillationPatternHelper
|
||||
*/
|
||||
public void setOutputItem( final ItemStack outputItem )
|
||||
{
|
||||
// Crafting aspect?
|
||||
// Not valid crafting aspect?
|
||||
if( ( outputItem != null ) && !( outputItem.getItem() instanceof ItemCraftingAspect ) )
|
||||
{
|
||||
this.output = null;
|
||||
}
|
||||
// Aspect null?
|
||||
else if( ItemCraftingAspect.getAspect( outputItem ) == null )
|
||||
{
|
||||
this.output = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.output = outputItem;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package thaumicenergistics.common.utils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
import thaumicenergistics.common.network.packet.client.Packet_C_Sync;
|
||||
@@ -20,6 +22,11 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
*/
|
||||
public final class ThEUtils
|
||||
{
|
||||
/**
|
||||
* The squared reach distance.
|
||||
*/
|
||||
private static final double SQUARED_REACH = 64.0D;
|
||||
|
||||
/**
|
||||
* Plays a sound for this player.
|
||||
*/
|
||||
@@ -30,6 +37,20 @@ public final class ThEUtils
|
||||
.playSound( PositionedSoundRecord.func_147674_a( sound, 1.0F ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the tile still exists and the player is within reach range.
|
||||
*
|
||||
* @param player
|
||||
* @param tile
|
||||
* @return
|
||||
*/
|
||||
public static final boolean canPlayerInteractWith( @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 );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the item stack is a wand, scepter, or staff if they are
|
||||
* allowed.
|
||||
|
||||
@@ -45,6 +45,8 @@ public class ModuleWaila
|
||||
{
|
||||
// Register the providers
|
||||
registrar.registerBodyProvider( ModuleWaila.INSTANCE, AbstractBlockProviderBase.class );
|
||||
|
||||
// Register the assembler
|
||||
registrar.registerBodyProvider( ModuleWaila.INSTANCE, BlockArcaneAssembler.class );
|
||||
|
||||
// Register the vibration chamber
|
||||
|
||||
@@ -50,7 +50,6 @@ thaumicenergistics.item.focus.aewrench.disabled.name=Wand Focus: AE Wrench - Wre
|
||||
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.button.clear.crafting=Deposit Crafting Grid
|
||||
thaumicenergistics.tooltip.button.void=Allow Void?
|
||||
thaumicenergistics.tooltip.button.void.disabled=Do not void essentia
|
||||
thaumicenergistics.tooltip.button.void.allowed=Void essentia if jar is full
|
||||
|
||||
Reference in new issue
Block a user