Added 4 View Cell Slots.
Multiple View Cells now sum together to allow more customization. View Cells are now protected by Build Security. Meteorite Compass now renders correctly in other peoples hands.
This commit is contained in:
@@ -70,6 +70,11 @@ public abstract class AEBaseContainer extends Container
|
||||
return;
|
||||
|
||||
ticksSinceCheck = 0;
|
||||
isContainerValid = isContainerValid && hasAccess( security, requirePower );
|
||||
}
|
||||
|
||||
protected boolean hasAccess(SecurityPermissions perm, boolean requirePower)
|
||||
{
|
||||
IActionHost host = null;
|
||||
|
||||
if ( tileEntity instanceof IActionHost )
|
||||
@@ -77,11 +82,7 @@ public abstract class AEBaseContainer extends Container
|
||||
if ( part instanceof IActionHost )
|
||||
host = (IActionHost) part;
|
||||
|
||||
if ( host == null )
|
||||
{
|
||||
isContainerValid = false;
|
||||
}
|
||||
else
|
||||
if ( host != null )
|
||||
{
|
||||
IGridNode gn = host.getActionableNode();
|
||||
if ( gn != null )
|
||||
@@ -93,18 +94,17 @@ public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
IEnergyGrid eg = g.getCache( IEnergyGrid.class );
|
||||
if ( !eg.isNetworkPowered() )
|
||||
{
|
||||
isContainerValid = false;
|
||||
return;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ISecurityGrid sg = g.getCache( ISecurityGrid.class );
|
||||
if ( !sg.hasPermission( invPlayer.player, security ) )
|
||||
isContainerValid = false;
|
||||
if ( sg.hasPermission( invPlayer.player, perm ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public ContainerOpenContext openContext;
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
@@ -31,7 +32,6 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigureableObject;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
||||
import appeng.core.AELog;
|
||||
@@ -51,7 +51,8 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
||||
IConfigManager serverCM;
|
||||
IConfigManager clientCM;
|
||||
|
||||
public AppEngSlot cellView;
|
||||
public boolean canAccessViewCells = false;
|
||||
public SlotRestrictedInput cellView[] = new SlotRestrictedInput[5];
|
||||
|
||||
public IConfigManagerHost gui;
|
||||
|
||||
@@ -96,8 +97,16 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
||||
else
|
||||
monitor = null;
|
||||
|
||||
canAccessViewCells = false;
|
||||
if ( montiorable instanceof IViewCellStorage )
|
||||
addSlotToContainer( cellView = new SlotRestrictedInput( PlaceableItemType.VIEWCELL, ((IViewCellStorage) montiorable).getViewCellStorage(), 0, 205, 7 ) );
|
||||
{
|
||||
for (int y = 0; y < 5; y++)
|
||||
{
|
||||
cellView[y] = new SlotRestrictedInput( PlaceableItemType.VIEWCELL, ((IViewCellStorage) montiorable).getViewCellStorage(), y, 206, y * 18 + 8 );
|
||||
cellView[y].allowEdit = canAccessViewCells;
|
||||
addSlotToContainer( cellView[y] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( bindInventory )
|
||||
bindPlayerInventory( ip, 0, 0 );
|
||||
@@ -171,6 +180,23 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
||||
}
|
||||
}
|
||||
|
||||
boolean oldCanAccessViewCells = canAccessViewCells;
|
||||
canAccessViewCells = hasAccess( SecurityPermissions.BUILD, false );
|
||||
if ( canAccessViewCells != oldCanAccessViewCells )
|
||||
{
|
||||
for (int y = 0; y < 5; y++)
|
||||
{
|
||||
if ( cellView[y] != null )
|
||||
cellView[y].allowEdit = canAccessViewCells;
|
||||
}
|
||||
|
||||
for (Object c : this.crafters)
|
||||
{
|
||||
if ( c instanceof ICrafting )
|
||||
((ICrafting) c).sendProgressBarUpdate( this, 99, canAccessViewCells ? 1 : 0 );
|
||||
}
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
@@ -212,6 +238,19 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int idx, int value)
|
||||
{
|
||||
super.updateProgressBar( idx, value );
|
||||
|
||||
if ( idx == 99 )
|
||||
canAccessViewCells = value == 1;
|
||||
|
||||
for (int y = 0; y < 5; y++)
|
||||
if ( cellView[y] != null )
|
||||
cellView[y].allowEdit = canAccessViewCells;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package appeng.container.slot;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -54,8 +55,15 @@ public class SlotRestrictedInput extends AppEngSlot
|
||||
}
|
||||
|
||||
public PlaceableItemType which;
|
||||
public boolean allowEdit = true;
|
||||
public int stackLimit = -1;
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return allowEdit;
|
||||
}
|
||||
|
||||
public Slot setStackLimit(int i)
|
||||
{
|
||||
stackLimit = i;
|
||||
@@ -98,6 +106,10 @@ public class SlotRestrictedInput extends AppEngSlot
|
||||
return false;
|
||||
|
||||
IAppEngApi api = AEApi.instance();
|
||||
|
||||
if ( !allowEdit )
|
||||
return false;
|
||||
|
||||
switch (which)
|
||||
{
|
||||
case VALID_ENCODED_PATTERN_W_OUPUT:
|
||||
|
||||
Reference in New Issue
Block a user