Reduces visibility of internal fields/methods
Reduces the visibility of all fields to private and create setters/getters when necessary. Exceptions are fields with GuiSync as these need to be public. Reduces the visibility of internal methods to private/protected/default when possible.
This commit is contained in:
@@ -84,22 +84,22 @@ import appeng.util.item.AEItemStack;
|
||||
public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
|
||||
protected final InventoryPlayer invPlayer;
|
||||
protected final BaseActionSource mySrc;
|
||||
protected final HashSet<Integer> locked = new HashSet<Integer>();
|
||||
final TileEntity tileEntity;
|
||||
final IPart part;
|
||||
final IGuiItemObject obj;
|
||||
final List<PacketPartialItem> dataChunks = new LinkedList<PacketPartialItem>();
|
||||
final HashMap<Integer, SyncData> syncData = new HashMap<Integer, SyncData>();
|
||||
public boolean isContainerValid = true;
|
||||
public String customName;
|
||||
public ContainerOpenContext openContext;
|
||||
protected IMEInventoryHandler<IAEItemStack> cellInv;
|
||||
protected IEnergySource powerSrc;
|
||||
boolean sentCustomName;
|
||||
int ticksSinceCheck = 900;
|
||||
IAEItemStack clientRequestedTargetItem = null;
|
||||
private final InventoryPlayer invPlayer;
|
||||
private final BaseActionSource mySrc;
|
||||
private final HashSet<Integer> locked = new HashSet<Integer>();
|
||||
private final TileEntity tileEntity;
|
||||
private final IPart part;
|
||||
private final IGuiItemObject obj;
|
||||
private final List<PacketPartialItem> dataChunks = new LinkedList<PacketPartialItem>();
|
||||
private final HashMap<Integer, SyncData> syncData = new HashMap<Integer, SyncData>();
|
||||
private boolean isContainerValid = true;
|
||||
private String customName;
|
||||
private ContainerOpenContext openContext;
|
||||
private IMEInventoryHandler<IAEItemStack> cellInv;
|
||||
private IEnergySource powerSrc;
|
||||
private boolean sentCustomName;
|
||||
private int ticksSinceCheck = 900;
|
||||
private IAEItemStack clientRequestedTargetItem = null;
|
||||
|
||||
public AEBaseContainer( final InventoryPlayer ip, final TileEntity myTile, final IPart myPart )
|
||||
{
|
||||
@@ -277,7 +277,7 @@ public abstract class AEBaseContainer extends Container
|
||||
this.clientRequestedTargetItem = stack == null ? null : stack.copy();
|
||||
}
|
||||
|
||||
public BaseActionSource getSource()
|
||||
public BaseActionSource getActionSource()
|
||||
{
|
||||
return this.mySrc;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ public abstract class AEBaseContainer extends Container
|
||||
}
|
||||
|
||||
this.ticksSinceCheck = 0;
|
||||
this.isContainerValid = this.isContainerValid && this.hasAccess( security, requirePower );
|
||||
this.setValidContainer( this.isValidContainer() && this.hasAccess( security, requirePower ) );
|
||||
}
|
||||
|
||||
protected boolean hasAccess( final SecurityPermissions perm, final boolean requirePower )
|
||||
@@ -321,7 +321,7 @@ public abstract class AEBaseContainer extends Container
|
||||
}
|
||||
|
||||
final ISecurityGrid sg = g.getCache( ISecurityGrid.class );
|
||||
if( sg.hasPermission( this.invPlayer.player, perm ) )
|
||||
if( sg.hasPermission( this.getInventoryPlayer().player, perm ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -356,7 +356,7 @@ public abstract class AEBaseContainer extends Container
|
||||
|
||||
public InventoryPlayer getPlayerInv()
|
||||
{
|
||||
return this.invPlayer;
|
||||
return this.getInventoryPlayer();
|
||||
}
|
||||
|
||||
public TileEntity getTileEntity()
|
||||
@@ -421,7 +421,7 @@ public abstract class AEBaseContainer extends Container
|
||||
if( newSlot instanceof AppEngSlot )
|
||||
{
|
||||
final AppEngSlot s = (AppEngSlot) newSlot;
|
||||
s.myContainer = this;
|
||||
s.setContainer( this );
|
||||
return super.addSlotToContainer( newSlot );
|
||||
}
|
||||
else
|
||||
@@ -723,7 +723,7 @@ public abstract class AEBaseContainer extends Container
|
||||
@Override
|
||||
public boolean canInteractWith( final EntityPlayer entityplayer )
|
||||
{
|
||||
if( this.isContainerValid )
|
||||
if( this.isValidContainer() )
|
||||
{
|
||||
if( this.tileEntity instanceof IInventory )
|
||||
{
|
||||
@@ -737,7 +737,7 @@ public abstract class AEBaseContainer extends Container
|
||||
@Override
|
||||
public boolean canDragIntoSlot( final Slot s )
|
||||
{
|
||||
return ( (AppEngSlot) s ).isDraggable;
|
||||
return ( (AppEngSlot) s ).isDraggable();
|
||||
}
|
||||
|
||||
public void doAction( final EntityPlayerMP player, final InventoryAction action, final int slot, final long id )
|
||||
@@ -851,7 +851,7 @@ public abstract class AEBaseContainer extends Container
|
||||
switch( action )
|
||||
{
|
||||
case SHIFT_CLICK:
|
||||
if( this.powerSrc == null || this.cellInv == null )
|
||||
if( this.getPowerSource() == null || this.getCellInventory() == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -872,7 +872,7 @@ public abstract class AEBaseContainer extends Container
|
||||
ais.setStackSize( ais.getStackSize() - myItem.stackSize );
|
||||
}
|
||||
|
||||
ais = Platform.poweredExtraction( this.powerSrc, this.cellInv, ais, this.mySrc );
|
||||
ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
|
||||
if( ais != null )
|
||||
{
|
||||
adp.addItems( ais.getItemStack() );
|
||||
@@ -880,7 +880,7 @@ public abstract class AEBaseContainer extends Container
|
||||
}
|
||||
break;
|
||||
case ROLL_DOWN:
|
||||
if( this.powerSrc == null || this.cellInv == null )
|
||||
if( this.getPowerSource() == null || this.getCellInventory() == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -894,7 +894,7 @@ public abstract class AEBaseContainer extends Container
|
||||
ais.setStackSize( 1 );
|
||||
final IAEItemStack extracted = ais.copy();
|
||||
|
||||
ais = Platform.poweredInsert( this.powerSrc, this.cellInv, ais, this.mySrc );
|
||||
ais = Platform.poweredInsert( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
|
||||
if( ais == null )
|
||||
{
|
||||
final InventoryAdaptor ia = new AdaptorPlayerHand( player );
|
||||
@@ -902,7 +902,7 @@ public abstract class AEBaseContainer extends Container
|
||||
final ItemStack fail = ia.removeItems( 1, extracted.getItemStack(), null );
|
||||
if( fail == null )
|
||||
{
|
||||
this.cellInv.extractItems( extracted, Actionable.MODULATE, this.mySrc );
|
||||
this.getCellInventory().extractItems( extracted, Actionable.MODULATE, this.getActionSource() );
|
||||
}
|
||||
|
||||
this.updateHeld( player );
|
||||
@@ -912,7 +912,7 @@ public abstract class AEBaseContainer extends Container
|
||||
break;
|
||||
case ROLL_UP:
|
||||
case PICKUP_SINGLE:
|
||||
if( this.powerSrc == null || this.cellInv == null )
|
||||
if( this.getPowerSource() == null || this.getCellInventory() == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -938,7 +938,7 @@ public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
ais.setStackSize( 1 );
|
||||
ais = Platform.poweredExtraction( this.powerSrc, this.cellInv, ais, this.mySrc );
|
||||
ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
|
||||
if( ais != null )
|
||||
{
|
||||
final InventoryAdaptor ia = new AdaptorPlayerHand( player );
|
||||
@@ -946,7 +946,7 @@ public abstract class AEBaseContainer extends Container
|
||||
final ItemStack fail = ia.addItems( ais.getItemStack() );
|
||||
if( fail != null )
|
||||
{
|
||||
this.cellInv.injectItems( ais, Actionable.MODULATE, this.mySrc );
|
||||
this.getCellInventory().injectItems( ais, Actionable.MODULATE, this.getActionSource() );
|
||||
}
|
||||
|
||||
this.updateHeld( player );
|
||||
@@ -955,7 +955,7 @@ public abstract class AEBaseContainer extends Container
|
||||
}
|
||||
break;
|
||||
case PICKUP_OR_SET_DOWN:
|
||||
if( this.powerSrc == null || this.cellInv == null )
|
||||
if( this.getPowerSource() == null || this.getCellInventory() == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -966,7 +966,7 @@ public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
ais.setStackSize( ais.getItemStack().getMaxStackSize() );
|
||||
ais = Platform.poweredExtraction( this.powerSrc, this.cellInv, ais, this.mySrc );
|
||||
ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
|
||||
if( ais != null )
|
||||
{
|
||||
player.inventory.setItemStack( ais.getItemStack() );
|
||||
@@ -981,7 +981,7 @@ public abstract class AEBaseContainer extends Container
|
||||
else
|
||||
{
|
||||
IAEItemStack ais = AEApi.instance().storage().createItemStack( player.inventory.getItemStack() );
|
||||
ais = Platform.poweredInsert( this.powerSrc, this.cellInv, ais, this.mySrc );
|
||||
ais = Platform.poweredInsert( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
|
||||
if( ais != null )
|
||||
{
|
||||
player.inventory.setItemStack( ais.getItemStack() );
|
||||
@@ -995,7 +995,7 @@ public abstract class AEBaseContainer extends Container
|
||||
|
||||
break;
|
||||
case SPLIT_OR_PLACE_SINGLE:
|
||||
if( this.powerSrc == null || this.cellInv == null )
|
||||
if( this.getPowerSource() == null || this.getCellInventory() == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1007,13 +1007,13 @@ public abstract class AEBaseContainer extends Container
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
final long maxSize = ais.getItemStack().getMaxStackSize();
|
||||
ais.setStackSize( maxSize );
|
||||
ais = this.cellInv.extractItems( ais, Actionable.SIMULATE, this.mySrc );
|
||||
ais = this.getCellInventory().extractItems( ais, Actionable.SIMULATE, this.getActionSource() );
|
||||
|
||||
if( ais != null )
|
||||
{
|
||||
final long stackSize = Math.min( maxSize, ais.getStackSize() );
|
||||
ais.setStackSize( ( stackSize + 1 ) >> 1 );
|
||||
ais = Platform.poweredExtraction( this.powerSrc, this.cellInv, ais, this.mySrc );
|
||||
ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
|
||||
}
|
||||
|
||||
if( ais != null )
|
||||
@@ -1031,7 +1031,7 @@ public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
IAEItemStack ais = AEApi.instance().storage().createItemStack( player.inventory.getItemStack() );
|
||||
ais.setStackSize( 1 );
|
||||
ais = Platform.poweredInsert( this.powerSrc, this.cellInv, ais, this.mySrc );
|
||||
ais = Platform.poweredInsert( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
|
||||
if( ais == null )
|
||||
{
|
||||
final ItemStack is = player.inventory.getItemStack();
|
||||
@@ -1056,7 +1056,7 @@ public abstract class AEBaseContainer extends Container
|
||||
break;
|
||||
case MOVE_REGION:
|
||||
|
||||
if( this.powerSrc == null || this.cellInv == null )
|
||||
if( this.getPowerSource() == null || this.getCellInventory() == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1080,7 +1080,7 @@ public abstract class AEBaseContainer extends Container
|
||||
ais.setStackSize( ais.getStackSize() - myItem.stackSize );
|
||||
}
|
||||
|
||||
ais = Platform.poweredExtraction( this.powerSrc, this.cellInv, ais, this.mySrc );
|
||||
ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
|
||||
if( ais != null )
|
||||
{
|
||||
adp.addItems( ais.getItemStack() );
|
||||
@@ -1113,13 +1113,13 @@ public abstract class AEBaseContainer extends Container
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack shiftStoreItem( final ItemStack input )
|
||||
private ItemStack shiftStoreItem( final ItemStack input )
|
||||
{
|
||||
if( this.powerSrc == null || this.cellInv == null )
|
||||
if( this.getPowerSource() == null || this.getCellInventory() == null )
|
||||
{
|
||||
return input;
|
||||
}
|
||||
final IAEItemStack ais = Platform.poweredInsert( this.powerSrc, this.cellInv, AEApi.instance().storage().createItemStack( input ), this.mySrc );
|
||||
final IAEItemStack ais = Platform.poweredInsert( this.getPowerSource(), this.getCellInventory(), AEApi.instance().storage().createItemStack( input ), this.getActionSource() );
|
||||
if( ais == null )
|
||||
{
|
||||
return null;
|
||||
@@ -1133,7 +1133,7 @@ public abstract class AEBaseContainer extends Container
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
protected void sendCustomName()
|
||||
private void sendCustomName()
|
||||
{
|
||||
if( !this.sentCustomName )
|
||||
{
|
||||
@@ -1166,14 +1166,14 @@ public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
if( name.hasCustomName() )
|
||||
{
|
||||
this.customName = name.getCustomName();
|
||||
this.setCustomName( name.getCustomName() );
|
||||
}
|
||||
|
||||
if( this.customName != null )
|
||||
if( this.getCustomName() != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendTo( new PacketValueConfig( "CustomName", this.customName ), (EntityPlayerMP) this.invPlayer.player );
|
||||
NetworkHandler.instance.sendTo( new PacketValueConfig( "CustomName", this.getCustomName() ), (EntityPlayerMP) this.getInventoryPlayer().player );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
@@ -1207,12 +1207,12 @@ public abstract class AEBaseContainer extends Container
|
||||
|
||||
// can take?
|
||||
|
||||
if( isA != null && !a.canTakeStack( this.invPlayer.player ) )
|
||||
if( isA != null && !a.canTakeStack( this.getInventoryPlayer().player ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( isB != null && !b.canTakeStack( this.invPlayer.player ) )
|
||||
if( isB != null && !b.canTakeStack( this.getInventoryPlayer().player ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1279,4 +1279,59 @@ public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public IMEInventoryHandler<IAEItemStack> getCellInventory()
|
||||
{
|
||||
return this.cellInv;
|
||||
}
|
||||
|
||||
public void setCellInventory( final IMEInventoryHandler<IAEItemStack> cellInv )
|
||||
{
|
||||
this.cellInv = cellInv;
|
||||
}
|
||||
|
||||
public String getCustomName()
|
||||
{
|
||||
return this.customName;
|
||||
}
|
||||
|
||||
public void setCustomName( final String customName )
|
||||
{
|
||||
this.customName = customName;
|
||||
}
|
||||
|
||||
public InventoryPlayer getInventoryPlayer()
|
||||
{
|
||||
return this.invPlayer;
|
||||
}
|
||||
|
||||
public boolean isValidContainer()
|
||||
{
|
||||
return this.isContainerValid;
|
||||
}
|
||||
|
||||
public void setValidContainer( final boolean isContainerValid )
|
||||
{
|
||||
this.isContainerValid = isContainerValid;
|
||||
}
|
||||
|
||||
public ContainerOpenContext getOpenContext()
|
||||
{
|
||||
return this.openContext;
|
||||
}
|
||||
|
||||
public void setOpenContext( final ContainerOpenContext openContext )
|
||||
{
|
||||
this.openContext = openContext;
|
||||
}
|
||||
|
||||
public IEnergySource getPowerSource()
|
||||
{
|
||||
return this.powerSrc;
|
||||
}
|
||||
|
||||
public void setPowerSource( final IEnergySource powerSrc )
|
||||
{
|
||||
this.powerSrc = powerSrc;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user