mirror of
https://github.com/GTNewHorizons/ThaumicEnergistics.git
synced 2026-11-16 10:44:40 +00:00
Locked icon + more MP fixes.
Fixed occasional crash when the Knowledge Inscriber GUI was clicked. Added locked/unlocked texture & indicator to storage monitors. Fixed bug where autocrafting gui didn't always show the item being crafted. Fixed and cleaned up some gui sync issues. (will this never end?!)
This commit is contained in:
1 parent
ddb483d817
commit
ae17e65313
18 files changed
+627
-558
No files matched your search
+7
-1
@@ -1,4 +1,10 @@
|
||||
01/10/2016 0.10.0.0 - Beta
|
||||
01/11/2016 0.10.0.0 - Beta
|
||||
Fixed occasional crash when the Knowledge Inscriber GUI was clicked.
|
||||
Added locked/unlocked texture & indicator to storage monitors.
|
||||
Fixed bug where autocrafting gui didn't always show the item being crafted.
|
||||
Fixed and cleaned up some gui sync issues. (will this never end?!)
|
||||
|
||||
01/10/2016 0.10.0.0 - Beta
|
||||
Fixed name collision with "isUseableByPlayer".
|
||||
Fixed KnowledgeInscriber not being able to erase patterns.
|
||||
Fixed bug where Terminals would not properly update during certain AE-network changes.
|
||||
|
||||
@@ -76,6 +76,9 @@ public class ContainerArcaneAssembler
|
||||
|
||||
public ContainerArcaneAssembler( final EntityPlayer player, final World world, final int X, final int Y, final int Z )
|
||||
{
|
||||
// Call super
|
||||
super( player );
|
||||
|
||||
// Get the assembler
|
||||
this.assembler = (TileArcaneAssembler)world.getTileEntity( X, Y, Z );
|
||||
|
||||
@@ -186,7 +189,7 @@ public class ContainerArcaneAssembler
|
||||
}
|
||||
|
||||
// Get the slot that was shift-clicked
|
||||
Slot slot = (Slot)this.inventorySlots.get( slotNumber );
|
||||
Slot slot = this.getSlotOrNull( slotNumber );
|
||||
|
||||
// Is there a valid slot with and item?
|
||||
if( ( slot != null ) && ( slot.getHasStack() ) )
|
||||
|
||||
+25
-34
@@ -56,11 +56,6 @@ public class ContainerDistillationPatternEncoder
|
||||
*/
|
||||
private static final int SLOT_PATTERN_ENCODED_POS_X = 146, SLOT_PATTERN_ENCODED_POS_Y = 113;
|
||||
|
||||
/**
|
||||
* Player who opened the GUI.
|
||||
*/
|
||||
private final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Host encoder.
|
||||
*/
|
||||
@@ -117,8 +112,8 @@ public class ContainerDistillationPatternEncoder
|
||||
*/
|
||||
public ContainerDistillationPatternEncoder( final EntityPlayer player, final World world, final int x, final int y, final int z )
|
||||
{
|
||||
// Set the player
|
||||
this.player = player;
|
||||
// Call super
|
||||
super( player );
|
||||
|
||||
// Get the encoder
|
||||
this.encoder = (TileDistillationPatternEncoder)world.getTileEntity( x, y, z );
|
||||
@@ -354,6 +349,27 @@ public class ContainerDistillationPatternEncoder
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean detectAndSendChangesMP( final EntityPlayerMP playerMP )
|
||||
{
|
||||
// Does the pattern slot need to be sync'd?
|
||||
if( this.doesSlotNeedSync( this.slotPatternEncoded ) )
|
||||
{
|
||||
// Load the pattern
|
||||
this.loadPattern();
|
||||
return true;
|
||||
}
|
||||
// Does the source item need to be sync'd?
|
||||
else if( this.doesSlotNeedSync( this.slotSourceItem ) )
|
||||
{
|
||||
// Scan the source item
|
||||
this.scanSourceItem( true );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set's the selected aspect stack.
|
||||
*
|
||||
@@ -399,31 +415,6 @@ public class ContainerDistillationPatternEncoder
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player for this container.
|
||||
*
|
||||
@@ -569,10 +560,10 @@ public class ContainerDistillationPatternEncoder
|
||||
}
|
||||
|
||||
// Get the slot
|
||||
Slot clickedSlot = this.getSlot( slotNumber );
|
||||
Slot clickedSlot = this.getSlotOrNull( slotNumber );
|
||||
|
||||
// Slot empty?
|
||||
if( !clickedSlot.getHasStack() )
|
||||
if( ( clickedSlot == null ) || !clickedSlot.getHasStack() )
|
||||
{
|
||||
// Done
|
||||
return null;
|
||||
|
||||
+56
-59
@@ -3,6 +3,7 @@ package thaumicenergistics.common.container;
|
||||
import java.util.Collection;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotFurnace;
|
||||
@@ -153,11 +154,6 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
*/
|
||||
protected final IEssentiaRepo repo;
|
||||
|
||||
/**
|
||||
* The player that owns this container.
|
||||
*/
|
||||
protected final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Essentia network monitor
|
||||
*/
|
||||
@@ -170,7 +166,8 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
*/
|
||||
public ContainerEssentiaCellTerminalBase( final EntityPlayer player )
|
||||
{
|
||||
this.player = player;
|
||||
// Call super
|
||||
super( player );
|
||||
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
@@ -467,6 +464,54 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is any work to perform.
|
||||
* If there is it does so.
|
||||
*/
|
||||
@Override
|
||||
protected boolean detectAndSendChangesMP( final EntityPlayerMP playerMP )
|
||||
{
|
||||
// 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 );
|
||||
}
|
||||
|
||||
// Is there a monitor?
|
||||
if( this.essentiaMonitor != null )
|
||||
{
|
||||
// Inc tick tracker
|
||||
this.tickCounter += 1;
|
||||
|
||||
if( this.tickCounter > ContainerEssentiaCellTerminalBase.WORK_TICK_RATE )
|
||||
{
|
||||
// Do work
|
||||
this.doWork( this.tickCounter );
|
||||
|
||||
// Reset the tick counter
|
||||
this.tickCounter = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Attempt to attach to a monitor
|
||||
if( this.attachToMonitor( this.getNewMonitor() ) )
|
||||
{
|
||||
// Send update
|
||||
this.onClientRequestFullUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called periodically so that the container can perform work.
|
||||
*/
|
||||
@@ -677,58 +722,6 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
while( this.workCounter < ESSENTIA_TRANSFER_PER_WORK_CYCLE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is any work to perform.
|
||||
* If there is it does so.
|
||||
*/
|
||||
@Override
|
||||
public final void detectAndSendChanges()
|
||||
{
|
||||
// Call super
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Is there a monitor?
|
||||
if( this.essentiaMonitor != null )
|
||||
{
|
||||
// Inc tick tracker
|
||||
this.tickCounter += 1;
|
||||
|
||||
if( this.tickCounter > ContainerEssentiaCellTerminalBase.WORK_TICK_RATE )
|
||||
{
|
||||
// Do work
|
||||
this.doWork( this.tickCounter );
|
||||
|
||||
// Reset the tick counter
|
||||
this.tickCounter = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Attempt to attach to a monitor
|
||||
if( this.attachToMonitor( this.getNewMonitor() ) )
|
||||
{
|
||||
// Send update
|
||||
this.onClientRequestFullUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of aspect stacks in the container.
|
||||
*
|
||||
@@ -895,6 +888,10 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
|
||||
// Update
|
||||
Packet_C_Sync.sendPlayerHeldItem( player, sourceStack );
|
||||
if( player instanceof EntityPlayerMP )
|
||||
{
|
||||
( (EntityPlayerMP)player ).isChangingQuantityOnly = false;
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
this.playTransferSound( player, false,
|
||||
( EssentiaItemContainerHelper.INSTANCE.getItemType( sourceStack ) == AspectItemType.JarLabel ? 1 : 0 ) );
|
||||
@@ -1069,7 +1066,7 @@ public abstract class ContainerEssentiaCellTerminalBase
|
||||
public ItemStack transferStackInSlot( final EntityPlayer player, final int slotNumber )
|
||||
{
|
||||
// Get the slot that was shift-clicked
|
||||
Slot slot = (Slot)this.inventorySlots.get( slotNumber );
|
||||
Slot slot = this.getSlotOrNull( slotNumber );
|
||||
|
||||
// Is there a valid slot with and item?
|
||||
if( ( slot != null ) && ( slot.getHasStack() ) )
|
||||
|
||||
+11
-29
@@ -31,34 +31,28 @@ public class ContainerEssentiaCellWorkbench
|
||||
*/
|
||||
public static int CELL_SLOT_X = 152, CELL_SLOT_Y = 8;
|
||||
|
||||
/**
|
||||
* The player that owns this container.
|
||||
*/
|
||||
private EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Cell Workbench.
|
||||
*/
|
||||
public final TileEssentiaCellWorkbench workbench;
|
||||
|
||||
/**
|
||||
* Index of the cell slot.
|
||||
* The cell slot.
|
||||
*/
|
||||
private final int cellSlotIndex;
|
||||
private final Slot cellSlot;
|
||||
|
||||
public ContainerEssentiaCellWorkbench( final EntityPlayer player, final World world, final int x, final int y, final int z )
|
||||
{
|
||||
// Set the player
|
||||
this.player = player;
|
||||
// Call super
|
||||
super( player );
|
||||
|
||||
// Get the workbench
|
||||
this.workbench = (TileEssentiaCellWorkbench)world.getTileEntity( x, y, z );
|
||||
|
||||
// Create the cell slot
|
||||
Slot cellSlot = new SlotRestrictive( this.workbench, 0, ContainerEssentiaCellWorkbench.CELL_SLOT_X,
|
||||
this.cellSlot = new SlotRestrictive( this.workbench, 0, ContainerEssentiaCellWorkbench.CELL_SLOT_X,
|
||||
ContainerEssentiaCellWorkbench.CELL_SLOT_Y );
|
||||
this.addSlotToContainer( cellSlot );
|
||||
this.cellSlotIndex = cellSlot.slotNumber;
|
||||
this.addSlotToContainer( this.cellSlot );
|
||||
|
||||
// Bind to the player's inventory
|
||||
this.bindPlayerInventory( this.player.inventory, ContainerEssentiaCellWorkbench.PLAYER_INV_POSITION_Y,
|
||||
@@ -102,15 +96,6 @@ public class ContainerEssentiaCellWorkbench
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Syncs the cell item.
|
||||
*/
|
||||
public void onForceSyncCell()
|
||||
{
|
||||
this.getSlot( this.cellSlotIndex ).onSlotChanged();
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the partition list changes.
|
||||
*/
|
||||
@@ -131,7 +116,7 @@ public class ContainerEssentiaCellWorkbench
|
||||
}
|
||||
|
||||
// Get the slot that was shift-clicked
|
||||
Slot slot = (Slot)this.inventorySlots.get( slotNumber );
|
||||
Slot slot = this.getSlotOrNull( slotNumber );
|
||||
|
||||
// Is there a valid slot with and item?
|
||||
if( ( slot != null ) && ( slot.getHasStack() ) )
|
||||
@@ -142,7 +127,7 @@ public class ContainerEssentiaCellWorkbench
|
||||
ItemStack slotStack = slot.getStack();
|
||||
|
||||
// Was the slot clicked the cell slot
|
||||
if( ( slotNumber == this.cellSlotIndex ) )
|
||||
if( ( slot == this.cellSlot ) )
|
||||
{
|
||||
// Attempt to merge with the player inventory
|
||||
didMerge = this.mergeSlotWithPlayerInventory( slotStack );
|
||||
@@ -150,17 +135,14 @@ public class ContainerEssentiaCellWorkbench
|
||||
// Was the slot clicked in the player or hotbar inventory?
|
||||
else if( this.slotClickedWasInPlayerInventory( slotNumber ) || this.slotClickedWasInHotbarInventory( slotNumber ) )
|
||||
{
|
||||
// Get the cell slot
|
||||
Slot cellSlot = ( (Slot)this.inventorySlots.get( this.cellSlotIndex ) );
|
||||
|
||||
// Is the cell slot empty?
|
||||
if( !cellSlot.getHasStack() )
|
||||
if( !this.cellSlot.getHasStack() )
|
||||
{
|
||||
// Is the item in the clicked slot a valid cell?
|
||||
if( cellSlot.isItemValid( slotStack ) )
|
||||
if( this.cellSlot.isItemValid( slotStack ) )
|
||||
{
|
||||
// Set the slot
|
||||
cellSlot.putStack( slotStack.copy() );
|
||||
this.cellSlot.putStack( slotStack.copy() );
|
||||
|
||||
// Clear the clicked slot
|
||||
slotStack.stackSize = 0;
|
||||
|
||||
@@ -2,6 +2,7 @@ package thaumicenergistics.common.container;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.api.grid.ICraftingIssuerHost;
|
||||
@@ -168,6 +169,10 @@ public class ContainerEssentiaTerminal
|
||||
cca.setItemToCraft( result );
|
||||
|
||||
// Issue update
|
||||
if( player instanceof EntityPlayerMP )
|
||||
{
|
||||
( (EntityPlayerMP)player ).isChangingQuantityOnly = false;
|
||||
}
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-9
@@ -1,7 +1,6 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
@@ -12,7 +11,7 @@ import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import thaumicenergistics.common.utils.ThEUtils;
|
||||
|
||||
public class ContainerEssentiaVibrationChamber
|
||||
extends Container
|
||||
extends TheContainerBase
|
||||
{
|
||||
/**
|
||||
* The number of items to average.
|
||||
@@ -24,18 +23,13 @@ public class ContainerEssentiaVibrationChamber
|
||||
*/
|
||||
private final TileEssentiaVibrationChamber chamber;
|
||||
|
||||
/**
|
||||
* Player who has this container open.
|
||||
*/
|
||||
private final EntityPlayer player;
|
||||
|
||||
private float powerPerTick = 0, powerPercent = 1.0F, ticksPercent = 1.0F, ticksRemaningMovingAverage = 0.0F;
|
||||
private int averageTicksRemaning;
|
||||
|
||||
public ContainerEssentiaVibrationChamber( final EntityPlayer player, final World world, final int x, final int y, final int z )
|
||||
{
|
||||
// Set the player
|
||||
this.player = player;
|
||||
// Call super
|
||||
super( player );
|
||||
|
||||
// Get the tile entity
|
||||
TileEntity te = world.getTileEntity( x, y, z );
|
||||
|
||||
+91
-110
@@ -83,18 +83,8 @@ public class ContainerKnowledgeInscriber
|
||||
*/
|
||||
private final SlotRestrictive kCoreSlot;
|
||||
private final SlotFake resultSlot;
|
||||
private SlotInaccessible[] patternSlots = new SlotInaccessible[MAXIMUM_PATTERNS];
|
||||
private SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[CRAFTING_ROWS * CRAFTING_COLS];
|
||||
|
||||
/**
|
||||
* Slot index ranges.
|
||||
*/
|
||||
private int patternSlot_first, patternSlot_last, craftingSlot_first, craftingSlot_last;
|
||||
|
||||
/**
|
||||
* Player using the inscriber
|
||||
*/
|
||||
private EntityPlayer player;
|
||||
private final SlotInaccessible[] patternSlots = new SlotInaccessible[MAXIMUM_PATTERNS];
|
||||
private final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[CRAFTING_ROWS * CRAFTING_COLS];
|
||||
|
||||
/**
|
||||
* The current recipe, if any.
|
||||
@@ -113,8 +103,8 @@ public class ContainerKnowledgeInscriber
|
||||
|
||||
public ContainerKnowledgeInscriber( final EntityPlayer player, final World world, final int x, final int y, final int z )
|
||||
{
|
||||
// Set the player
|
||||
this.player = player;
|
||||
// Call super
|
||||
super( player );
|
||||
|
||||
// Bind to the players inventory
|
||||
this.bindPlayerInventory( player.inventory, ContainerKnowledgeInscriber.PLAYER_INV_POSITION_Y,
|
||||
@@ -211,27 +201,22 @@ public class ContainerKnowledgeInscriber
|
||||
int slotIndex;
|
||||
// Create the crafting slots
|
||||
slotIndex = CRAFTING_MATRIX_SLOT;
|
||||
for( int row = 0; row < ContainerKnowledgeInscriber.CRAFTING_ROWS; row++ )
|
||||
for( int row = 0; row < CRAFTING_ROWS; row++ )
|
||||
{
|
||||
for( int column = 0; column < ContainerKnowledgeInscriber.CRAFTING_COLS; column++ )
|
||||
for( int column = 0; column < CRAFTING_COLS; column++ )
|
||||
{
|
||||
// Calculate the array index
|
||||
int index = ( row * ContainerKnowledgeInscriber.CRAFTING_COLS ) + column;
|
||||
int index = ( row * CRAFTING_COLS ) + column;
|
||||
|
||||
// Calculate the position
|
||||
int posX = ContainerKnowledgeInscriber.CRAFTING_SLOT_X + ( ContainerKnowledgeInscriber.CRAFTING_SLOT_SPACING * column );
|
||||
int posY = ContainerKnowledgeInscriber.CRAFTING_SLOT_Y + ( ContainerKnowledgeInscriber.CRAFTING_SLOT_SPACING * row );
|
||||
|
||||
// Add to the array
|
||||
this.craftingSlots[index] = new SlotFakeCraftingMatrix( this.internalInventory, slotIndex++ , posX, posY );
|
||||
int posX = CRAFTING_SLOT_X + ( CRAFTING_SLOT_SPACING * column );
|
||||
int posY = CRAFTING_SLOT_Y + ( CRAFTING_SLOT_SPACING * row );
|
||||
|
||||
// Add the slot
|
||||
this.addSlotToContainer( this.craftingSlots[index] );
|
||||
this.addSlotToContainer( this.craftingSlots[index] = new SlotFakeCraftingMatrix( this.internalInventory, slotIndex++ , posX, posY ) );
|
||||
|
||||
}
|
||||
}
|
||||
this.craftingSlot_first = this.craftingSlots[0].slotNumber;
|
||||
this.craftingSlot_last = this.craftingSlots[this.craftingSlots.length - 1].slotNumber;
|
||||
}
|
||||
|
||||
private void initPatternSlots()
|
||||
@@ -239,16 +224,16 @@ public class ContainerKnowledgeInscriber
|
||||
int slotIndex;
|
||||
// Create the pattern slots
|
||||
slotIndex = PATTERN_SLOT;
|
||||
for( int row = 0; row < ContainerKnowledgeInscriber.PATTERN_ROWS; row++ )
|
||||
for( int row = 0; row < PATTERN_ROWS; row++ )
|
||||
{
|
||||
for( int column = 0; column < ContainerKnowledgeInscriber.PATTERN_COLS; column++ )
|
||||
for( int column = 0; column < PATTERN_COLS; column++ )
|
||||
{
|
||||
// Calculate the array index
|
||||
int index = ( row * ContainerKnowledgeInscriber.PATTERN_COLS ) + column;
|
||||
int index = ( row * PATTERN_COLS ) + column;
|
||||
|
||||
// Calculate the position
|
||||
int posX = ContainerKnowledgeInscriber.PATTERN_SLOT_X + ( ContainerKnowledgeInscriber.PATTERN_SLOT_SPACING * column );
|
||||
int posY = ContainerKnowledgeInscriber.PATTERN_SLOT_Y + ( ContainerKnowledgeInscriber.PATTERN_SLOT_SPACING * row );
|
||||
int posX = PATTERN_SLOT_X + ( PATTERN_SLOT_SPACING * column );
|
||||
int posY = PATTERN_SLOT_Y + ( PATTERN_SLOT_SPACING * row );
|
||||
|
||||
// Add to the array
|
||||
this.patternSlots[index] = new SlotInaccessible( this.internalInventory, slotIndex++ , posX, posY );
|
||||
@@ -257,8 +242,6 @@ public class ContainerKnowledgeInscriber
|
||||
this.addSlotToContainer( this.patternSlots[index] );
|
||||
}
|
||||
}
|
||||
this.patternSlot_first = this.patternSlots[0].slotNumber;
|
||||
this.patternSlot_last = this.patternSlots[this.patternSlots.length - 1].slotNumber;
|
||||
}
|
||||
|
||||
private void loadPattern( final ArcaneCraftingPattern pattern )
|
||||
@@ -356,6 +339,41 @@ public class ContainerKnowledgeInscriber
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for core insertion or removal.
|
||||
*
|
||||
* @param playerMP
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected boolean detectAndSendChangesMP( final EntityPlayerMP playerMP )
|
||||
{
|
||||
// Has a core changed?
|
||||
if( !this.kCoreHandler.isHandlingCore( this.kCoreSlot.getStack() ) )
|
||||
{
|
||||
if( this.kCoreSlot.getHasStack() )
|
||||
{
|
||||
// Setup the handler
|
||||
this.kCoreHandler.open( this.kCoreSlot.getStack() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Close the handler
|
||||
this.kCoreHandler.close();
|
||||
}
|
||||
|
||||
// Update the slots
|
||||
this.updatePatternSlots();
|
||||
|
||||
// Update the save state
|
||||
this.sendSaveState( false );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can interact with anyone
|
||||
*
|
||||
@@ -372,42 +390,6 @@ public class ContainerKnowledgeInscriber
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for core insertion or removal.
|
||||
*/
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if( this.player instanceof EntityPlayerMP )
|
||||
{
|
||||
// Has a core changed?
|
||||
if( !this.kCoreHandler.isHandlingCore( this.kCoreSlot.getStack() ) )
|
||||
{
|
||||
if( this.kCoreSlot.getHasStack() )
|
||||
{
|
||||
// Setup the handler
|
||||
this.kCoreHandler.open( this.kCoreSlot.getStack() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Close the handler
|
||||
this.kCoreHandler.close();
|
||||
}
|
||||
|
||||
// Update the slots
|
||||
this.updatePatternSlots();
|
||||
( (EntityPlayerMP)this.player ).isChangingQuantityOnly = false;
|
||||
|
||||
// Update the save state
|
||||
this.sendSaveState( false );
|
||||
}
|
||||
}
|
||||
|
||||
// Call super
|
||||
super.detectAndSendChanges();
|
||||
|
||||
}
|
||||
|
||||
public void onClientRequestClearGrid()
|
||||
{
|
||||
// Clear the grid
|
||||
@@ -559,67 +541,66 @@ public class ContainerKnowledgeInscriber
|
||||
/**
|
||||
* Creates 'ghost' items when a crafting slot is clicked.
|
||||
*
|
||||
* @param slotID
|
||||
* @param slotNumber
|
||||
* @param buttonPressed
|
||||
* @param flag
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ItemStack slotClick( final int slotID, final int buttonPressed, final int flag, final EntityPlayer player )
|
||||
public ItemStack slotClick( final int slotNumber, final int buttonPressed, final int flag, final EntityPlayer player )
|
||||
{
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the clicked slot
|
||||
Slot clickedSlot = this.getSlot( slotID );
|
||||
|
||||
// Get the itemstack the player is holding with the mouse
|
||||
ItemStack draggingStack = player.inventory.getItemStack();
|
||||
|
||||
// Was the clicked slot a crafting slot?
|
||||
if( ( clickedSlot.slotNumber >= this.craftingSlot_first ) && ( clickedSlot.slotNumber <= this.craftingSlot_last ) )
|
||||
for( Slot slot : this.craftingSlots )
|
||||
{
|
||||
// Is the player holding anything?
|
||||
if( draggingStack != null )
|
||||
if( slot.slotNumber == slotNumber )
|
||||
{
|
||||
ItemStack copiedStack = draggingStack.copy();
|
||||
copiedStack.stackSize = 1;
|
||||
// Is the player holding anything?
|
||||
if( draggingStack != null )
|
||||
{
|
||||
ItemStack copiedStack = draggingStack.copy();
|
||||
copiedStack.stackSize = 1;
|
||||
|
||||
// Place a copy of the stack into the clicked slot
|
||||
clickedSlot.putStack( copiedStack );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear the slot
|
||||
clickedSlot.putStack( null );
|
||||
}
|
||||
|
||||
// Update the matrix
|
||||
this.onCraftMatrixChanged( clickedSlot.inventory );
|
||||
|
||||
return draggingStack;
|
||||
}
|
||||
// Was the clicked slot a pattern slot?
|
||||
else if( ( clickedSlot.slotNumber >= this.patternSlot_first ) && ( clickedSlot.slotNumber <= this.patternSlot_last ) )
|
||||
{
|
||||
// Does the slot correspond to a stored pattern?
|
||||
if( clickedSlot.getHasStack() )
|
||||
{
|
||||
// Load the pattern
|
||||
this.loadPattern( this.kCoreHandler.getPatternForItem( clickedSlot.getStack() ) );
|
||||
// Place a copy of the stack into the clicked slot
|
||||
slot.putStack( copiedStack );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear the slot
|
||||
slot.putStack( null );
|
||||
}
|
||||
|
||||
// Update the matrix
|
||||
this.onCraftMatrixChanged( clickedSlot.inventory );
|
||||
}
|
||||
this.onCraftMatrixChanged( slot.inventory );
|
||||
|
||||
return draggingStack;
|
||||
return draggingStack;
|
||||
}
|
||||
}
|
||||
|
||||
// Was the clicked slot a pattern slot?
|
||||
for( Slot slot : this.patternSlots )
|
||||
{
|
||||
if( slot.slotNumber == slotNumber )
|
||||
{
|
||||
// Does the slot correspond to a stored pattern?
|
||||
if( slot.getHasStack() )
|
||||
{
|
||||
// Load the pattern
|
||||
this.loadPattern( this.kCoreHandler.getPatternForItem( slot.getStack() ) );
|
||||
|
||||
// Update the matrix
|
||||
this.onCraftMatrixChanged( slot.inventory );
|
||||
}
|
||||
|
||||
return draggingStack;
|
||||
}
|
||||
}
|
||||
|
||||
// Pass to super
|
||||
return super.slotClick( slotID, buttonPressed, flag, player );
|
||||
return super.slotClick( slotNumber, buttonPressed, flag, player );
|
||||
|
||||
}
|
||||
|
||||
@@ -634,7 +615,7 @@ public class ContainerKnowledgeInscriber
|
||||
}
|
||||
|
||||
// Get the slot that was shift-clicked
|
||||
Slot slot = (Slot)this.inventorySlots.get( slotNumber );
|
||||
Slot slot = this.getSlotOrNull( slotNumber );
|
||||
|
||||
// Is there a valid slot with and item?
|
||||
if( ( slot != null ) && ( slot.getHasStack() ) )
|
||||
|
||||
+113
-138
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
@@ -136,11 +137,6 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
*/
|
||||
private final PartArcaneCraftingTerminal terminal;
|
||||
|
||||
/**
|
||||
* The player associated with this container.
|
||||
*/
|
||||
private final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Network source representing the player who is interacting with the
|
||||
* container.
|
||||
@@ -165,12 +161,12 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
/**
|
||||
* Slot number of the wand.
|
||||
*/
|
||||
private int wandSlotNumber = -1;
|
||||
private final SlotRestrictive wandSlot;
|
||||
|
||||
/**
|
||||
* Slot number of the result.
|
||||
*/
|
||||
private int resultSlotNumber = -1;
|
||||
private final SlotArcaneCraftingResult resultSlot;
|
||||
|
||||
/**
|
||||
* The wand currently in the wand slot.
|
||||
@@ -210,31 +206,31 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
*/
|
||||
public ContainerPartArcaneCraftingTerminal( final PartArcaneCraftingTerminal terminal, final EntityPlayer player )
|
||||
{
|
||||
// Call super
|
||||
super( player );
|
||||
|
||||
// Set the part
|
||||
this.terminal = terminal;
|
||||
|
||||
// Set the player
|
||||
this.player = player;
|
||||
|
||||
// Set the player source
|
||||
this.playerSource = new PlayerSource( this.player, terminal );
|
||||
|
||||
// Bind to the players inventory
|
||||
this.bindPlayerInventory( player.inventory, ContainerPartArcaneCraftingTerminal.PLAYER_INV_POSITION_Y,
|
||||
ContainerPartArcaneCraftingTerminal.HOTBAR_INV_POSITION_Y );
|
||||
this.bindPlayerInventory( player.inventory, PLAYER_INV_POSITION_Y,
|
||||
HOTBAR_INV_POSITION_Y );
|
||||
|
||||
// Add crafting slots
|
||||
Slot craftingSlot = null;
|
||||
for( int row = 0; row < ContainerPartArcaneCraftingTerminal.CRAFTING_GRID_SIZE; row++ )
|
||||
for( int row = 0; row < CRAFTING_GRID_SIZE; row++ )
|
||||
{
|
||||
for( int column = 0; column < ContainerPartArcaneCraftingTerminal.CRAFTING_GRID_SIZE; column++ )
|
||||
for( int column = 0; column < CRAFTING_GRID_SIZE; column++ )
|
||||
{
|
||||
// Calculate the index
|
||||
int slotIndex = ( row * ContainerPartArcaneCraftingTerminal.CRAFTING_GRID_SIZE ) + column;
|
||||
int slotIndex = ( row * CRAFTING_GRID_SIZE ) + column;
|
||||
|
||||
// Create the slot
|
||||
craftingSlot = new Slot( terminal, slotIndex, ContainerPartArcaneCraftingTerminal.CRAFTING_SLOT_X_POS +
|
||||
( column * ContainerWithPlayerInventory.SLOT_SIZE ), ContainerPartArcaneCraftingTerminal.CRAFTING_SLOT_Y_POS +
|
||||
craftingSlot = new Slot( terminal, slotIndex, CRAFTING_SLOT_X_POS +
|
||||
( column * ContainerWithPlayerInventory.SLOT_SIZE ), CRAFTING_SLOT_Y_POS +
|
||||
( row * ContainerWithPlayerInventory.SLOT_SIZE ) );
|
||||
|
||||
// Add the slot
|
||||
@@ -255,25 +251,19 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
}
|
||||
|
||||
// Create the result slot
|
||||
SlotArcaneCraftingResult resultSlot = new SlotArcaneCraftingResult( player, this, terminal, terminal,
|
||||
PartArcaneCraftingTerminal.RESULT_SLOT_INDEX, ContainerPartArcaneCraftingTerminal.RESULT_SLOT_X_POS,
|
||||
ContainerPartArcaneCraftingTerminal.RESULT_SLOT_Y_POS );
|
||||
this.resultSlot = new SlotArcaneCraftingResult( player, this, terminal, terminal,
|
||||
PartArcaneCraftingTerminal.RESULT_SLOT_INDEX, RESULT_SLOT_X_POS,
|
||||
RESULT_SLOT_Y_POS );
|
||||
|
||||
// Add the result slot
|
||||
this.addSlotToContainer( resultSlot );
|
||||
|
||||
// Set the result slot number
|
||||
this.resultSlotNumber = resultSlot.slotNumber;
|
||||
this.addSlotToContainer( this.resultSlot );
|
||||
|
||||
// Create the wand slot
|
||||
SlotRestrictive wandSlot = new SlotRestrictive( terminal, PartArcaneCraftingTerminal.WAND_SLOT_INDEX,
|
||||
ContainerPartArcaneCraftingTerminal.WAND_SLOT_XPOS, ContainerPartArcaneCraftingTerminal.WAND_SLOT_YPOS );
|
||||
this.wandSlot = new SlotRestrictive( terminal, PartArcaneCraftingTerminal.WAND_SLOT_INDEX,
|
||||
WAND_SLOT_XPOS, WAND_SLOT_YPOS );
|
||||
|
||||
// Add the wand slot
|
||||
this.addSlotToContainer( wandSlot );
|
||||
|
||||
// Set wand slot number
|
||||
this.wandSlotNumber = wandSlot.slotNumber;
|
||||
this.addSlotToContainer( this.wandSlot );
|
||||
|
||||
// Create the view slots
|
||||
SlotRestrictive viewSlot = null;
|
||||
@@ -281,10 +271,10 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
{
|
||||
// Calculate the y position
|
||||
int row = viewSlotID - PartArcaneCraftingTerminal.VIEW_SLOT_MIN;
|
||||
int yPos = ContainerPartArcaneCraftingTerminal.VIEW_SLOT_YPOS + ( row * ContainerWithPlayerInventory.SLOT_SIZE );
|
||||
int yPos = VIEW_SLOT_YPOS + ( row * ContainerWithPlayerInventory.SLOT_SIZE );
|
||||
|
||||
// Create the slot
|
||||
viewSlot = new SlotRestrictive( terminal, viewSlotID, ContainerPartArcaneCraftingTerminal.VIEW_SLOT_XPOS, yPos );
|
||||
viewSlot = new SlotRestrictive( terminal, viewSlotID, VIEW_SLOT_XPOS, yPos );
|
||||
|
||||
// Add the slot
|
||||
this.addSlotToContainer( viewSlot );
|
||||
@@ -303,14 +293,14 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
}
|
||||
|
||||
// Create the armor slots
|
||||
for( int armorIndex = 0; armorIndex < ContainerPartArcaneCraftingTerminal.ARMOR_SLOT_COUNT; ++armorIndex )
|
||||
for( int armorIndex = 0; armorIndex < ARMOR_SLOT_COUNT; ++armorIndex )
|
||||
{
|
||||
// Calculate y position
|
||||
int yPos = ContainerPartArcaneCraftingTerminal.ARMOR_SLOT_Y_POS + ( ContainerWithPlayerInventory.SLOT_SIZE * armorIndex );
|
||||
int yPos = ARMOR_SLOT_Y_POS + ( ContainerWithPlayerInventory.SLOT_SIZE * armorIndex );
|
||||
|
||||
// Create the slot
|
||||
SlotArmor armorSlot = new SlotArmor( terminal, PartArcaneCraftingTerminal.ARMOR_SLOT_MIN + armorIndex,
|
||||
ContainerPartArcaneCraftingTerminal.ARMOR_SLOT_X_POS, yPos, armorIndex, false );
|
||||
ARMOR_SLOT_X_POS, yPos, armorIndex, false );
|
||||
|
||||
// Add to container
|
||||
this.addSlotToContainer( armorSlot );
|
||||
@@ -457,11 +447,8 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
// Tracks how many items we have made
|
||||
int autoCraftCounter = 0;
|
||||
|
||||
// Get the result slot
|
||||
SlotArcaneCraftingResult resultSlot = (SlotArcaneCraftingResult)this.getSlot( this.resultSlotNumber );
|
||||
|
||||
// Get the current crafting result.
|
||||
ItemStack resultStack = resultSlot.getStack();
|
||||
ItemStack resultStack = this.resultSlot.getStack();
|
||||
|
||||
// Make a copy of it
|
||||
ItemStack slotStackOriginal = resultStack.copy();
|
||||
@@ -475,13 +462,13 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
if( didMerge )
|
||||
{
|
||||
// Let the result slot know it was picked up
|
||||
resultSlot.onPickupFromSlotViaTransfer( player, resultStack );
|
||||
this.resultSlot.onPickupFromSlotViaTransfer( player, resultStack );
|
||||
|
||||
// Update the matrix
|
||||
this.onCraftMatrixChanged( null );
|
||||
|
||||
// Get the stack in the result slot now.
|
||||
resultStack = resultSlot.getStack();
|
||||
resultStack = this.resultSlot.getStack();
|
||||
|
||||
// Is it empty?
|
||||
if( ( resultStack == null ) || ( resultStack.stackSize == 0 ) )
|
||||
@@ -508,7 +495,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
if( autoCraftCounter > 0 )
|
||||
{
|
||||
// Mark the result slot as dirty
|
||||
resultSlot.onSlotChanged();
|
||||
this.resultSlot.onSlotChanged();
|
||||
|
||||
// Send changes
|
||||
this.detectAndSendChanges();
|
||||
@@ -568,7 +555,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
|
||||
// Is there a matching recipe?
|
||||
IArcaneRecipe matchingRecipe = ArcaneRecipeHelper.INSTANCE.findMatchingArcaneResult( this.terminal, 0,
|
||||
ContainerPartArcaneCraftingTerminal.CRAFTING_GRID_TOTAL_SIZE, this.player );
|
||||
CRAFTING_GRID_TOTAL_SIZE, this.player );
|
||||
|
||||
if( matchingRecipe != null )
|
||||
{
|
||||
@@ -589,10 +576,10 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
{
|
||||
// Create a new crafting inventory
|
||||
InventoryCrafting craftingInventory = new InventoryCrafting( new ContainerInternalCrafting(),
|
||||
ContainerPartArcaneCraftingTerminal.CRAFTING_GRID_SIZE, ContainerPartArcaneCraftingTerminal.CRAFTING_GRID_SIZE );
|
||||
CRAFTING_GRID_SIZE, CRAFTING_GRID_SIZE );
|
||||
|
||||
// Load the inventory based on what is in the part's inventory
|
||||
for( int slotIndex = 0; slotIndex < ( ContainerPartArcaneCraftingTerminal.CRAFTING_GRID_TOTAL_SIZE ); slotIndex++ )
|
||||
for( int slotIndex = 0; slotIndex < ( CRAFTING_GRID_TOTAL_SIZE ); slotIndex++ )
|
||||
{
|
||||
// Set the slot
|
||||
craftingInventory.setInventorySlotContents( slotIndex, this.terminal.getStackInSlot( slotIndex ) );
|
||||
@@ -615,7 +602,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
for( int viewSlotIndex = this.firstViewSlotNumber; viewSlotIndex <= this.lastViewSlotNumber; viewSlotIndex++ )
|
||||
{
|
||||
// Get the slot
|
||||
viewSlot = this.getSlot( viewSlotIndex );
|
||||
viewSlot = this.getSlotOrNull( viewSlotIndex );
|
||||
|
||||
// Ensure the slot is not empty
|
||||
if( !viewSlot.getHasStack() )
|
||||
@@ -635,27 +622,20 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
*/
|
||||
private void getWand()
|
||||
{
|
||||
// Get the wand slot
|
||||
Slot wandSlot = this.getSlot( this.wandSlotNumber );
|
||||
|
||||
// Ensure the slot is not null
|
||||
if( wandSlot != null )
|
||||
// Is this the same wand that we have cached?
|
||||
if( this.wand == this.wandSlot.getStack() )
|
||||
{
|
||||
// Is this the same wand that we have cached?
|
||||
if( this.wand == wandSlot.getStack() )
|
||||
{
|
||||
// Nothing has changed
|
||||
return;
|
||||
}
|
||||
// Nothing has changed
|
||||
return;
|
||||
}
|
||||
|
||||
// Is the item a valid crafting wand?
|
||||
if( ThEUtils.isItemValidWand( wandSlot.getStack(), false ) )
|
||||
{
|
||||
// Set the wand
|
||||
this.wand = wandSlot.getStack();
|
||||
// Is the item a valid crafting wand?
|
||||
if( ThEUtils.isItemValidWand( this.wandSlot.getStack(), false ) )
|
||||
{
|
||||
// Set the wand
|
||||
this.wand = this.wandSlot.getStack();
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the wand to null
|
||||
@@ -718,7 +698,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
for( int viewSlotIndex = this.firstViewSlotNumber; viewSlotIndex <= this.lastViewSlotNumber; viewSlotIndex++ )
|
||||
{
|
||||
// Get the slot
|
||||
viewSlot = this.getSlot( viewSlotIndex );
|
||||
viewSlot = this.getSlotOrNull( viewSlotIndex );
|
||||
|
||||
// Is there a slot?
|
||||
if( viewSlot == null )
|
||||
@@ -778,7 +758,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
|
||||
// Get the cost
|
||||
this.requiredAspects = ArcaneRecipeHelper.INSTANCE.getRecipeAspectCost( this.terminal, 0,
|
||||
ContainerPartArcaneCraftingTerminal.CRAFTING_GRID_TOTAL_SIZE, forRecipe );
|
||||
CRAFTING_GRID_TOTAL_SIZE, forRecipe );
|
||||
|
||||
// Ensure there is a cost
|
||||
if( this.requiredAspects == null )
|
||||
@@ -836,13 +816,64 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
{
|
||||
// Get the result of the recipe.
|
||||
return ArcaneRecipeHelper.INSTANCE.getRecipeOutput( this.terminal, 0,
|
||||
ContainerPartArcaneCraftingTerminal.CRAFTING_GRID_TOTAL_SIZE, forRecipe );
|
||||
CRAFTING_GRID_TOTAL_SIZE, forRecipe );
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean detectAndSendChangesMP( final EntityPlayerMP playerMP )
|
||||
{
|
||||
boolean sendModeUpdate = false;
|
||||
|
||||
// Has the sorting order changed?
|
||||
if( this.cachedSortOrder != this.terminal.getSortingOrder() )
|
||||
{
|
||||
// Update
|
||||
this.cachedSortOrder = this.terminal.getSortingOrder();
|
||||
sendModeUpdate = true;
|
||||
}
|
||||
|
||||
// Has the sorting direction changed?
|
||||
if( this.cachedSortDirection != this.terminal.getSortingDirection() )
|
||||
{
|
||||
// Update
|
||||
this.cachedSortDirection = this.terminal.getSortingDirection();
|
||||
sendModeUpdate = true;
|
||||
}
|
||||
|
||||
// Has the view mode changed?
|
||||
if( this.cachedViewMode != this.terminal.getViewMode() )
|
||||
{
|
||||
// Update
|
||||
this.cachedViewMode = this.terminal.getViewMode();
|
||||
sendModeUpdate = true;
|
||||
}
|
||||
|
||||
// Send update?
|
||||
if( sendModeUpdate )
|
||||
{
|
||||
// Send the mode info
|
||||
Packet_C_ArcaneCraftingTerminal.sendModeChange( this.player,
|
||||
this.cachedSortOrder, this.cachedSortDirection, this.cachedViewMode );
|
||||
}
|
||||
|
||||
// Is the monitor null?
|
||||
if( this.monitor == null )
|
||||
{
|
||||
// Attempt to re-attach
|
||||
if( this.attachToMonitor() )
|
||||
{
|
||||
// Update the client
|
||||
this.onClientRequestFullUpdate( this.player );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the slot number belongs to the crafting matrix
|
||||
*
|
||||
@@ -888,63 +919,6 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
// Call super
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean sendUpdate = false;
|
||||
|
||||
// Has the sorting order changed?
|
||||
if( this.cachedSortOrder != this.terminal.getSortingOrder() )
|
||||
{
|
||||
// Update
|
||||
this.cachedSortOrder = this.terminal.getSortingOrder();
|
||||
sendUpdate = true;
|
||||
}
|
||||
|
||||
// Has the sorting direction changed?
|
||||
if( this.cachedSortDirection != this.terminal.getSortingDirection() )
|
||||
{
|
||||
// Update
|
||||
this.cachedSortDirection = this.terminal.getSortingDirection();
|
||||
sendUpdate = true;
|
||||
}
|
||||
|
||||
// Has the view mode changed?
|
||||
if( this.cachedViewMode != this.terminal.getViewMode() )
|
||||
{
|
||||
// Update
|
||||
this.cachedViewMode = this.terminal.getViewMode();
|
||||
sendUpdate = true;
|
||||
}
|
||||
|
||||
// Send update?
|
||||
if( sendUpdate )
|
||||
{
|
||||
// Send the mode info
|
||||
Packet_C_ArcaneCraftingTerminal.sendModeChange( this.player,
|
||||
this.cachedSortOrder, this.cachedSortDirection, this.cachedViewMode );
|
||||
}
|
||||
|
||||
// Is the monitor null?
|
||||
if( this.monitor == null )
|
||||
{
|
||||
// Attempt to re-attach
|
||||
if( this.attachToMonitor() )
|
||||
{
|
||||
// Update the client
|
||||
this.onClientRequestFullUpdate( this.player );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the aspect cost and how much is missing for the current recipe.
|
||||
*
|
||||
@@ -1081,6 +1055,10 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
cca.setItemToCraft( result );
|
||||
|
||||
// Issue update
|
||||
if( player instanceof EntityPlayerMP )
|
||||
{
|
||||
( (EntityPlayerMP)player ).isChangingQuantityOnly = false;
|
||||
}
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
@@ -1469,12 +1447,9 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
craftResult = this.findMatchingArcaneResult();
|
||||
}
|
||||
|
||||
// Get the result slot
|
||||
SlotArcaneCraftingResult resultSlot = (SlotArcaneCraftingResult)this.getSlot( this.resultSlotNumber );
|
||||
|
||||
// Set the result slot aspects and wand
|
||||
resultSlot.setResultAspects( this.requiredAspects );
|
||||
resultSlot.setWand( this.wand );
|
||||
this.resultSlot.setResultAspects( this.requiredAspects );
|
||||
this.resultSlot.setWand( this.wand );
|
||||
|
||||
// Set the result
|
||||
this.terminal.setInventorySlotContentsWithoutNotify( PartArcaneCraftingTerminal.RESULT_SLOT_INDEX, craftResult );
|
||||
@@ -1615,16 +1590,16 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
* Called when a slot is clicked by the player.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack slotClick( final int slotID, final int button, final int flag, final EntityPlayer player )
|
||||
public ItemStack slotClick( final int slotNumber, final int button, final int flag, final EntityPlayer player )
|
||||
{
|
||||
if( ( slotID == this.resultSlotNumber ) && ( button == ThEGuiHelper.MOUSE_BUTTON_RIGHT ) )
|
||||
if( ( slotNumber == this.resultSlot.slotNumber ) && ( button == ThEGuiHelper.MOUSE_BUTTON_RIGHT ) )
|
||||
{
|
||||
// If right clicking on result slot, change it to left click
|
||||
return super.slotClick( slotID, ThEGuiHelper.MOUSE_BUTTON_LEFT, flag, player );
|
||||
return super.slotClick( slotNumber, ThEGuiHelper.MOUSE_BUTTON_LEFT, flag, player );
|
||||
}
|
||||
|
||||
// Pass to super
|
||||
return super.slotClick( slotID, button, flag, player );
|
||||
return super.slotClick( slotNumber, button, flag, player );
|
||||
|
||||
}
|
||||
|
||||
@@ -1642,7 +1617,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
}
|
||||
|
||||
// Get the slot that was shift-clicked
|
||||
Slot slot = (Slot)this.inventorySlots.get( slotNumber );
|
||||
Slot slot = this.getSlotOrNull( slotNumber );
|
||||
|
||||
// Is there a valid slot with and item?
|
||||
if( ( slot != null ) && ( slot.getHasStack() ) )
|
||||
@@ -1653,7 +1628,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
ItemStack slotStack = slot.getStack();
|
||||
|
||||
// Was the slot clicked in the crafting grid or wand?
|
||||
if( ( slotNumber == this.wandSlotNumber ) || this.slotClickedWasInCraftingInventory( slotNumber ) )
|
||||
if( ( slot == this.wandSlot ) || this.slotClickedWasInCraftingInventory( slotNumber ) )
|
||||
{
|
||||
// Attempt to merge with the ME network
|
||||
didMerge = this.mergeWithMENetwork( slotStack );
|
||||
@@ -1677,10 +1652,10 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
{
|
||||
|
||||
// Is the item a valid wand?
|
||||
if( this.getSlot( this.wandSlotNumber ).isItemValid( slotStack ) )
|
||||
if( this.wandSlot.isItemValid( slotStack ) )
|
||||
{
|
||||
// Attempt to merge with the wand
|
||||
didMerge = this.mergeItemStack( slotStack, this.wandSlotNumber, this.wandSlotNumber + 1, false );
|
||||
didMerge = this.mergeItemStack( slotStack, this.wandSlot.slotNumber, this.wandSlot.slotNumber + 1, false );
|
||||
}
|
||||
|
||||
// Did we merge?
|
||||
@@ -1712,7 +1687,7 @@ public class ContainerPartArcaneCraftingTerminal
|
||||
}
|
||||
}
|
||||
// Was the slot clicked the crafting result?
|
||||
else if( slotNumber == this.resultSlotNumber )
|
||||
else if( slot == this.resultSlot )
|
||||
{
|
||||
// Start the autocrafting loop
|
||||
this.doShiftAutoCrafting( player );
|
||||
|
||||
@@ -2,13 +2,13 @@ package thaumicenergistics.common.container;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
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_EssentiaIOBus;
|
||||
import thaumicenergistics.common.parts.ThEPartEssentiaIOBus_Base;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
|
||||
/**
|
||||
@@ -50,11 +50,6 @@ public class ContainerPartEssentiaIOBus
|
||||
*/
|
||||
private final ThEPartEssentiaIOBus_Base bus;
|
||||
|
||||
/**
|
||||
* Player associated with the container
|
||||
*/
|
||||
private final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Cached isVoidAllowed
|
||||
*/
|
||||
@@ -70,12 +65,12 @@ public class ContainerPartEssentiaIOBus
|
||||
*/
|
||||
public ContainerPartEssentiaIOBus( final ThEPartEssentiaIOBus_Base part, final EntityPlayer player )
|
||||
{
|
||||
// Call super
|
||||
super( player );
|
||||
|
||||
// Set the part
|
||||
this.bus = part;
|
||||
|
||||
// Set the player
|
||||
this.player = player;
|
||||
|
||||
// Bind to the player's inventory
|
||||
this.bindPlayerInventory( player.inventory, ContainerPartEssentiaIOBus.PLAYER_INV_POSITION_Y,
|
||||
ContainerPartEssentiaIOBus.HOTBAR_INV_POSITION_Y );
|
||||
@@ -92,26 +87,8 @@ public class ContainerPartEssentiaIOBus
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
protected boolean detectAndSendChangesMP( final EntityPlayerMP playerMP )
|
||||
{
|
||||
if( this.bus != null )
|
||||
{
|
||||
return this.bus.isPartUseableByPlayer( 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() )
|
||||
{
|
||||
@@ -119,6 +96,18 @@ public class ContainerPartEssentiaIOBus
|
||||
this.isVoidAllowed = this.bus.isVoidAllowed();
|
||||
Packet_C_EssentiaIOBus.sendVoidMode( this.player, this.isVoidAllowed );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
if( this.bus != null )
|
||||
{
|
||||
return this.bus.isPartUseableByPlayer( player );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,7 +146,7 @@ public class ContainerPartEssentiaIOBus
|
||||
public ItemStack transferStackInSlot( final EntityPlayer player, final int slotNumber )
|
||||
{
|
||||
// Get the slot
|
||||
Slot slot = this.getSlot( slotNumber );
|
||||
Slot slot = this.getSlotOrNull( slotNumber );
|
||||
|
||||
// Do we have a valid slot with an item?
|
||||
if( ( slot != null ) && ( slot.getHasStack() ) )
|
||||
|
||||
+18
-23
@@ -3,6 +3,7 @@ package thaumicenergistics.common.container;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
@@ -50,11 +51,6 @@ public class ContainerPartEssentiaLevelEmitter
|
||||
*/
|
||||
private Aspect trackedAspect = null;
|
||||
|
||||
/**
|
||||
* The associated player
|
||||
*/
|
||||
private final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Create the container.
|
||||
*
|
||||
@@ -63,33 +59,20 @@ public class ContainerPartEssentiaLevelEmitter
|
||||
*/
|
||||
public ContainerPartEssentiaLevelEmitter( final PartEssentiaLevelEmitter part, final EntityPlayer player )
|
||||
{
|
||||
// Call super
|
||||
super( player );
|
||||
|
||||
// Set the 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 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
protected boolean detectAndSendChangesMP( final EntityPlayerMP playerMP )
|
||||
{
|
||||
if( this.emitter != null )
|
||||
{
|
||||
return this.emitter.isPartUseableByPlayer( player );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
// Call super
|
||||
super.detectAndSendChanges();
|
||||
|
||||
// Threshold
|
||||
if( this.thresholdLevel != this.emitter.getThresholdLevel() )
|
||||
{
|
||||
@@ -113,13 +96,25 @@ public class ContainerPartEssentiaLevelEmitter
|
||||
filter.add( this.trackedAspect );
|
||||
Packet_C_AspectSlot.setFilterList( filter, this.player );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
if( this.emitter != null )
|
||||
{
|
||||
return this.emitter.isPartUseableByPlayer( player );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot( final EntityPlayer player, final int slotNumber )
|
||||
{
|
||||
// Get the slot
|
||||
Slot slot = this.getSlot( slotNumber );
|
||||
Slot slot = this.getSlotOrNull( slotNumber );
|
||||
|
||||
if( ( slot != null ) && ( slot.getHasStack() ) )
|
||||
{
|
||||
|
||||
+17
-28
@@ -3,13 +3,13 @@ package thaumicenergistics.common.container;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
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
|
||||
@@ -39,11 +39,6 @@ public class ContainerPartEssentiaStorageBus
|
||||
*/
|
||||
private final PartEssentiaStorageBus storageBus;
|
||||
|
||||
/**
|
||||
* The associated player.
|
||||
*/
|
||||
private final EntityPlayer player;
|
||||
|
||||
/**
|
||||
* Cache of filteredAspects.
|
||||
*/
|
||||
@@ -56,8 +51,8 @@ public class ContainerPartEssentiaStorageBus
|
||||
|
||||
public ContainerPartEssentiaStorageBus( final PartEssentiaStorageBus part, final EntityPlayer player )
|
||||
{
|
||||
// Set the player
|
||||
this.player = player;
|
||||
// Call super
|
||||
super( player );
|
||||
|
||||
// Set the part
|
||||
this.storageBus = part;
|
||||
@@ -82,26 +77,8 @@ public class ContainerPartEssentiaStorageBus
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
protected boolean detectAndSendChangesMP( final EntityPlayerMP playerMP )
|
||||
{
|
||||
if( this.storageBus != null )
|
||||
{
|
||||
return this.storageBus.isPartUseableByPlayer( player );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
// Call super
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if( EffectiveSide.isClientSide() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Has the filtered list changed?
|
||||
boolean updateFilters = false;
|
||||
for( int filterIndex = 0; filterIndex < PartEssentiaStorageBus.FILTER_SIZE; ++filterIndex )
|
||||
@@ -126,6 +103,18 @@ public class ContainerPartEssentiaStorageBus
|
||||
this.isVoidAllowed = this.storageBus.isVoidAllowed();
|
||||
Packet_C_EssentiaStorageBus.sendIsVoidAllowed( this.player, this.isVoidAllowed );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer player )
|
||||
{
|
||||
if( this.storageBus != null )
|
||||
{
|
||||
return this.storageBus.isPartUseableByPlayer( player );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setFilteredAspects( final List<Aspect> filteredAspects )
|
||||
@@ -137,7 +126,7 @@ public class ContainerPartEssentiaStorageBus
|
||||
public ItemStack transferStackInSlot( final EntityPlayer player, final int slotNumber )
|
||||
{
|
||||
// Get the slot
|
||||
Slot slot = this.getSlot( slotNumber );
|
||||
Slot slot = this.getSlotOrNull( slotNumber );
|
||||
|
||||
// Do we have a valid slot with an item?
|
||||
if( ( slot != null ) && ( slot.getHasStack() ) )
|
||||
|
||||
+8
-3
@@ -2,6 +2,7 @@ package thaumicenergistics.common.container;
|
||||
|
||||
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 thaumcraft.api.aspects.Aspect;
|
||||
@@ -212,6 +213,10 @@ public class ContainerWirelessEssentiaTerminal
|
||||
cca.setItemToCraft( result );
|
||||
|
||||
// Issue update
|
||||
if( player instanceof EntityPlayerMP )
|
||||
{
|
||||
( (EntityPlayerMP)player ).isChangingQuantityOnly = false;
|
||||
}
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@@ -279,11 +284,11 @@ public class ContainerWirelessEssentiaTerminal
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick( final int slotID, final int buttonPressed, final int flag, final EntityPlayer player )
|
||||
public ItemStack slotClick( final int slotNumber, final int buttonPressed, final int flag, final EntityPlayer player )
|
||||
{
|
||||
try
|
||||
{
|
||||
Slot clickedSlot = this.getSlot( slotID );
|
||||
Slot clickedSlot = this.getSlotOrNull( slotNumber );
|
||||
// Protect the wireless terminal
|
||||
if( ( clickedSlot.inventory == this.player.inventory ) && ( clickedSlot.getSlotIndex() == this.terminalSlotIndex ) )
|
||||
{
|
||||
@@ -294,7 +299,7 @@ public class ContainerWirelessEssentiaTerminal
|
||||
{
|
||||
}
|
||||
|
||||
return super.slotClick( slotID, buttonPressed, flag, player );
|
||||
return super.slotClick( slotNumber, buttonPressed, flag, player );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,11 @@ public abstract class ContainerWithNetworkTool
|
||||
*/
|
||||
protected boolean hasNetworkTool = false;
|
||||
|
||||
public ContainerWithNetworkTool( final EntityPlayer player )
|
||||
{
|
||||
super( player );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds upgrade slots to the container.
|
||||
*
|
||||
@@ -275,13 +280,16 @@ public abstract class ContainerWithNetworkTool
|
||||
return this.hasNetworkTool;
|
||||
}
|
||||
|
||||
// Note: mergeItemStack args: ItemStack stack, int slotStart, int slotEnd(exclusive), boolean reverse
|
||||
/**
|
||||
* Checks if the shift+click happend in the network tool.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack transferStackInSlot( final EntityPlayer player, final int slotNumber )
|
||||
{
|
||||
// Note: mergeItemStack args: ItemStack stack, int slotStart, int slotEnd(exclusive), boolean reverse
|
||||
|
||||
// Get the slot that was clicked on
|
||||
Slot slot = this.getSlot( slotNumber );
|
||||
Slot slot = this.getSlotOrNull( slotNumber );
|
||||
|
||||
boolean didMerge = false;
|
||||
|
||||
|
||||
+37
-79
@@ -1,14 +1,13 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class ContainerWithPlayerInventory
|
||||
extends Container
|
||||
extends TheContainerBase
|
||||
{
|
||||
/**
|
||||
* The number of rows in the player inventory
|
||||
@@ -31,24 +30,19 @@ public abstract class ContainerWithPlayerInventory
|
||||
private static final int INVENTORY_X_OFFSET = 8;
|
||||
|
||||
/**
|
||||
* Index of the first player slot
|
||||
* Array of player hotbar slots
|
||||
*/
|
||||
private int firstPlayerSlotNumber = -1;
|
||||
private final Slot[] hotbarSlots = new Slot[COLUMNS];
|
||||
|
||||
/**
|
||||
* Index of the last player slot
|
||||
* Array of player inventory slots.
|
||||
*/
|
||||
private int lastPlayerSlotNumber = -1;
|
||||
private final Slot[] playerSlots = new Slot[COLUMNS * ROWS];
|
||||
|
||||
/**
|
||||
* Index of the first player slot
|
||||
*/
|
||||
private int firstHotbarSlotNumber = -1;
|
||||
|
||||
/**
|
||||
* Index of the last player slot
|
||||
*/
|
||||
private int lastHotbarSlotNumber = -1;
|
||||
public ContainerWithPlayerInventory( final EntityPlayer player )
|
||||
{
|
||||
super( player );
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to merge the specified slot stack with the hotbar inventory
|
||||
@@ -58,7 +52,7 @@ public abstract class ContainerWithPlayerInventory
|
||||
*/
|
||||
protected final boolean mergeSlotWithHotbarInventory( final ItemStack slotStack )
|
||||
{
|
||||
return this.mergeItemStack( slotStack, this.firstHotbarSlotNumber, this.lastHotbarSlotNumber + 1, false );
|
||||
return this.mergeItemStack( slotStack, this.hotbarSlots[0].slotNumber, this.hotbarSlots[COLUMNS - 1].slotNumber + 1, false );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +63,7 @@ public abstract class ContainerWithPlayerInventory
|
||||
*/
|
||||
protected final boolean mergeSlotWithPlayerInventory( final ItemStack slotStack )
|
||||
{
|
||||
return this.mergeItemStack( slotStack, this.firstPlayerSlotNumber, this.lastPlayerSlotNumber + 1, false );
|
||||
return this.mergeItemStack( slotStack, this.playerSlots[0].slotNumber, this.playerSlots[COLUMNS * ROWS - 1].slotNumber + 1, false );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +74,7 @@ public abstract class ContainerWithPlayerInventory
|
||||
*/
|
||||
protected final boolean slotClickedWasInHotbarInventory( final int slotNumber )
|
||||
{
|
||||
return ( slotNumber >= this.firstHotbarSlotNumber ) && ( slotNumber <= this.lastHotbarSlotNumber );
|
||||
return ( slotNumber >= this.hotbarSlots[0].slotNumber ) && ( slotNumber <= this.hotbarSlots[COLUMNS - 1].slotNumber );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +85,7 @@ public abstract class ContainerWithPlayerInventory
|
||||
*/
|
||||
protected final boolean slotClickedWasInPlayerInventory( final int slotNumber )
|
||||
{
|
||||
return ( slotNumber >= this.firstPlayerSlotNumber ) && ( slotNumber <= this.lastPlayerSlotNumber );
|
||||
return ( slotNumber >= this.playerSlots[0].slotNumber ) && ( slotNumber <= this.playerSlots[COLUMNS * ROWS - 1].slotNumber );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,57 +121,31 @@ public abstract class ContainerWithPlayerInventory
|
||||
public final void bindPlayerInventory( final IInventory playerInventory, final int inventoryOffsetY, final int hotbarPositionY )
|
||||
{
|
||||
// Hot-bar ID's 0-8
|
||||
Slot hotbarSlot = null;
|
||||
for( int column = 0; column < ContainerWithPlayerInventory.COLUMNS; column++ )
|
||||
for( int column = 0; column < COLUMNS; column++ )
|
||||
{
|
||||
// Create the slot
|
||||
hotbarSlot = new Slot( playerInventory, column, ContainerWithPlayerInventory.INVENTORY_X_OFFSET +
|
||||
( column * ContainerWithPlayerInventory.SLOT_SIZE ), hotbarPositionY );
|
||||
this.hotbarSlots[column] = new Slot( playerInventory, column, INVENTORY_X_OFFSET + ( column * SLOT_SIZE ), hotbarPositionY );
|
||||
|
||||
// Add the slot
|
||||
this.addSlotToContainer( hotbarSlot );
|
||||
|
||||
// Check first
|
||||
if( column == 0 )
|
||||
{
|
||||
this.firstHotbarSlotNumber = hotbarSlot.slotNumber;
|
||||
}
|
||||
}
|
||||
|
||||
// Set last
|
||||
if( hotbarSlot != null )
|
||||
{
|
||||
this.lastHotbarSlotNumber = hotbarSlot.slotNumber;
|
||||
this.addSlotToContainer( this.hotbarSlots[column] );
|
||||
}
|
||||
|
||||
// Main inventory ID's 9-36
|
||||
Slot inventorySlot = null;
|
||||
for( int row = 0; row < ContainerWithPlayerInventory.ROWS; row++ )
|
||||
for( int row = 0; row < ROWS; row++ )
|
||||
{
|
||||
for( int column = 0; column < ContainerWithPlayerInventory.COLUMNS; column++ )
|
||||
for( int column = 0; column < COLUMNS; column++ )
|
||||
{
|
||||
// Calculate index
|
||||
int index = column + ( row * COLUMNS );
|
||||
|
||||
// Create the slot
|
||||
inventorySlot = new Slot( playerInventory, ContainerWithPlayerInventory.COLUMNS +
|
||||
( column + ( row * ContainerWithPlayerInventory.COLUMNS ) ), ContainerWithPlayerInventory.INVENTORY_X_OFFSET +
|
||||
( column * ContainerWithPlayerInventory.SLOT_SIZE ), ( row * ContainerWithPlayerInventory.SLOT_SIZE ) +
|
||||
inventoryOffsetY );
|
||||
this.playerSlots[index] = new Slot( playerInventory, COLUMNS + index, INVENTORY_X_OFFSET + ( column * SLOT_SIZE ),
|
||||
( row * SLOT_SIZE ) + inventoryOffsetY );
|
||||
|
||||
// Add the slot
|
||||
this.addSlotToContainer( inventorySlot );
|
||||
|
||||
// Check first
|
||||
if( ( row + column ) == 0 )
|
||||
{
|
||||
this.firstPlayerSlotNumber = inventorySlot.slotNumber;
|
||||
}
|
||||
this.addSlotToContainer( this.playerSlots[index] );
|
||||
}
|
||||
}
|
||||
|
||||
// Set last
|
||||
if( inventorySlot != null )
|
||||
{
|
||||
this.lastPlayerSlotNumber = inventorySlot.slotNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,24 +153,19 @@ public abstract class ContainerWithPlayerInventory
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final List<Slot> getNonEmptySlotsFromHotbar()
|
||||
public final ArrayList<Slot> getNonEmptySlotsFromHotbar()
|
||||
{
|
||||
List<Slot> hSlots = new ArrayList<Slot>();
|
||||
ArrayList<Slot> list = new ArrayList<Slot>();
|
||||
|
||||
for( int slotNumber = this.firstHotbarSlotNumber; slotNumber <= this.lastHotbarSlotNumber; slotNumber++ )
|
||||
for( Slot slot : this.hotbarSlots )
|
||||
{
|
||||
// Get the slot
|
||||
Slot hSlot = this.getSlot( slotNumber );
|
||||
|
||||
// Is the slot not-empty
|
||||
if( hSlot.getHasStack() )
|
||||
if( slot.getHasStack() )
|
||||
{
|
||||
// Add to the list
|
||||
hSlots.add( hSlot );
|
||||
list.add( slot );
|
||||
}
|
||||
}
|
||||
|
||||
return hSlots;
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,23 +173,18 @@ public abstract class ContainerWithPlayerInventory
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final List<Slot> getNonEmptySlotsFromPlayerInventory()
|
||||
public final ArrayList<Slot> getNonEmptySlotsFromPlayerInventory()
|
||||
{
|
||||
List<Slot> pSlots = new ArrayList<Slot>();
|
||||
ArrayList<Slot> list = new ArrayList<Slot>();
|
||||
|
||||
for( int slotNumber = this.firstPlayerSlotNumber; slotNumber <= this.lastPlayerSlotNumber; slotNumber++ )
|
||||
for( Slot slot : this.playerSlots )
|
||||
{
|
||||
// Get the slot
|
||||
Slot pSlot = this.getSlot( slotNumber );
|
||||
|
||||
// Is the slot not-empty
|
||||
if( pSlot.getHasStack() )
|
||||
if( slot.getHasStack() )
|
||||
{
|
||||
// Add to the list
|
||||
pSlots.add( pSlot );
|
||||
list.add( slot );
|
||||
}
|
||||
}
|
||||
|
||||
return pSlots;
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package thaumicenergistics.common.container;
|
||||
|
||||
import java.util.HashMap;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import thaumicenergistics.common.utils.ThELog;
|
||||
|
||||
public abstract class TheContainerBase
|
||||
extends Container
|
||||
{
|
||||
/**
|
||||
* Maps slotNumber -> Slot
|
||||
*/
|
||||
private final HashMap<Integer, Slot> slotMap = new HashMap<Integer, Slot>();
|
||||
|
||||
/**
|
||||
* Set if the player is an MP player.
|
||||
*/
|
||||
private final EntityPlayerMP playerMP;
|
||||
|
||||
/**
|
||||
* The player interacting with this container.
|
||||
*/
|
||||
protected final EntityPlayer player;
|
||||
|
||||
public TheContainerBase( final EntityPlayer player )
|
||||
{
|
||||
// Set the player
|
||||
this.player = player;
|
||||
if( player instanceof EntityPlayerMP )
|
||||
{
|
||||
this.playerMP = (EntityPlayerMP)player;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.playerMP = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a slot to the container and the slot map.
|
||||
*/
|
||||
@Override
|
||||
protected Slot addSlotToContainer( @Nonnull final Slot slot )
|
||||
{
|
||||
// Call super
|
||||
super.addSlotToContainer( slot );
|
||||
|
||||
// Map the slot
|
||||
if( this.slotMap.put( slot.slotNumber, slot ) != null )
|
||||
{
|
||||
ThELog.warning( "Duplicate Slot Number Detected: %d", slot.slotNumber );
|
||||
}
|
||||
|
||||
return slot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects server side changes to send to the player.<br/>
|
||||
* When modifying slots, return true to set {@code playerMP.isChangingQuantityOnly} to {@code false},
|
||||
* or set it directly with the player argument.
|
||||
*
|
||||
* @param playerMP
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected boolean detectAndSendChangesMP( @Nonnull final EntityPlayerMP playerMP )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the slot with the specified slot number or null.
|
||||
*
|
||||
* @param slotNumber
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
protected Slot getSlotOrNull( final int slotNumber )
|
||||
{
|
||||
return this.slotMap.getOrDefault( slotNumber, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
// MP player?
|
||||
if( this.playerMP != null )
|
||||
{
|
||||
if( this.detectAndSendChangesMP( this.playerMP ) )
|
||||
{
|
||||
this.playerMP.isChangingQuantityOnly = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Call super
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use getSlotOrNull.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Slot getSlot( final int slotNumber )
|
||||
{
|
||||
return super.getSlot( slotNumber );
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the slot map.
|
||||
*/
|
||||
@Override
|
||||
public void onContainerClosed( @Nonnull final EntityPlayer player )
|
||||
{
|
||||
// Call super
|
||||
super.onContainerClosed( player );
|
||||
|
||||
// Clear the map
|
||||
this.slotMap.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -26,6 +27,7 @@ import thaumicenergistics.api.grid.IEssentiaWatcherHost;
|
||||
import thaumicenergistics.api.grid.IMEEssentiaMonitor;
|
||||
import thaumicenergistics.api.storage.IAspectStack;
|
||||
import thaumicenergistics.client.textures.BlockTextureManager;
|
||||
import thaumicenergistics.common.ThaumicEnergistics;
|
||||
import thaumicenergistics.common.registries.AEPartsEnum;
|
||||
import thaumicenergistics.common.storage.AspectStack;
|
||||
import thaumicenergistics.common.utils.EffectiveSide;
|
||||
@@ -198,6 +200,12 @@ public class PartEssentiaStorageMonitor
|
||||
*/
|
||||
private static final String NBT_KEY_LOCKED = "Locked", NBT_KEY_TRACKED_ASPECT = "TrackedAspect";
|
||||
|
||||
/***
|
||||
* Locked texture.
|
||||
*/
|
||||
private static final ResourceLocation TEXTURE_LOCKED = new ResourceLocation( ThaumicEnergistics.MOD_ID,
|
||||
"textures/blocks/parts/monitor.locked.png" );
|
||||
|
||||
/**
|
||||
* Watches the for changes in the essentia grid.
|
||||
*/
|
||||
@@ -371,6 +379,64 @@ public class PartEssentiaStorageMonitor
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the lock.
|
||||
* Note: This must come after renderAspect, as it depends on the
|
||||
* GL position state that renderAspect sets up.
|
||||
*
|
||||
* @param tessellator
|
||||
*/
|
||||
private void renderLock( final Tessellator tessellator )
|
||||
{
|
||||
// Enable blending
|
||||
GL11.glEnable( GL11.GL_BLEND );
|
||||
|
||||
// Specify the blending mode
|
||||
GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA );
|
||||
|
||||
// Set white
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 0.5f );
|
||||
|
||||
// Move to the top right corner
|
||||
GL11.glTranslatef( 0.4f, -0.06f, 0.0f );
|
||||
|
||||
// Scale
|
||||
float scale = 0.10f;
|
||||
float invScale = 1.0f / scale;
|
||||
GL11.glScalef( scale, scale, scale );
|
||||
|
||||
// Bind the block texture
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture( TEXTURE_LOCKED );
|
||||
|
||||
// Locked state
|
||||
float txUMax = 0.5f;
|
||||
float txUMin = 0.0f;
|
||||
if( !this.isLocked() )
|
||||
{
|
||||
txUMin = 0.5f;
|
||||
txUMax = 1.0f;
|
||||
}
|
||||
|
||||
// Add the vertex points
|
||||
double size = 1.0D;
|
||||
double zDepth = -0.268D * invScale;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV( 0.0D, size, zDepth, txUMin, 1.0D ); // Bottom left
|
||||
tessellator.addVertexWithUV( size, size, zDepth, txUMax, 1.0D ); // Bottom right
|
||||
tessellator.addVertexWithUV( size, 0.0D, zDepth, txUMax, 0.0D ); // Top right
|
||||
tessellator.addVertexWithUV( 0.0D, 0.0D, zDepth, txUMin, 0.0D ); // Top left
|
||||
|
||||
// Draw
|
||||
tessellator.draw();
|
||||
|
||||
// Restore
|
||||
GL11.glScalef( invScale, invScale, invScale );
|
||||
GL11.glTranslatef( -0.4f, 0.06f, 0.0f );
|
||||
|
||||
// Disable blending
|
||||
GL11.glDisable( GL11.GL_BLEND );
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the aspect and amount onto the screen.
|
||||
* Note: Method originally from Applied Energistics 2,
|
||||
@@ -382,9 +448,6 @@ public class PartEssentiaStorageMonitor
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void renderScreen( final Tessellator tessellator, final IAspectStack aspectStack )
|
||||
{
|
||||
// Push the OpenGL attributes
|
||||
//GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
|
||||
// Get the side
|
||||
ForgeDirection side = this.getSide();
|
||||
|
||||
@@ -428,9 +491,6 @@ public class PartEssentiaStorageMonitor
|
||||
|
||||
}
|
||||
|
||||
// Push the OpenGL matrix
|
||||
//GL11.glPushMatrix();
|
||||
|
||||
try
|
||||
{
|
||||
// Calculate the brightness for the lightmap
|
||||
@@ -443,14 +503,15 @@ public class PartEssentiaStorageMonitor
|
||||
|
||||
// Render the aspect
|
||||
this.renderAspect( tessellator, aspectStack.getAspect() );
|
||||
|
||||
// Render the lock
|
||||
this.renderLock( tessellator );
|
||||
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
}
|
||||
|
||||
// Pop the OpenGL matrix
|
||||
//GL11.glPopMatrix();
|
||||
|
||||
// Move below the screen image
|
||||
GL11.glTranslatef( 0.2f, 0.4f, -0.25f );
|
||||
GL11.glScalef( 1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f );
|
||||
@@ -466,9 +527,6 @@ public class PartEssentiaStorageMonitor
|
||||
|
||||
// Render the string
|
||||
fr.drawString( renderedStackSize, 0, 0, 0 );
|
||||
|
||||
// Pop the OpenGL attributes
|
||||
//GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -786,7 +844,13 @@ public class PartEssentiaStorageMonitor
|
||||
redraw |= super.readFromStream( stream );
|
||||
|
||||
// Read locked state
|
||||
this.monitorLocked = stream.readBoolean();
|
||||
boolean newLockState = stream.readBoolean();
|
||||
if( this.monitorLocked != newLockState )
|
||||
{
|
||||
// Mark for screen redraw
|
||||
redraw |= this.updateDisplayList = true;
|
||||
}
|
||||
this.monitorLocked = newLockState;
|
||||
|
||||
// Is there any tracking info to read?
|
||||
if( stream.readBoolean() )
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
Reference in new issue
Block a user