Security Block Fully Functional.
This commit is contained in:
@@ -33,12 +33,18 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
|||||||
|
|
||||||
int xoffset = 9;
|
int xoffset = 9;
|
||||||
int perRow = 9;
|
int perRow = 9;
|
||||||
|
int reservedSpace = 0;
|
||||||
|
|
||||||
int rows = 0;
|
int rows = 0;
|
||||||
int maxRows = Integer.MAX_VALUE;
|
int maxRows = Integer.MAX_VALUE;
|
||||||
|
|
||||||
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, IStorageMonitorable te) {
|
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, IStorageMonitorable te) {
|
||||||
super( new ContainerMEMonitorable( inventoryPlayer, null ) );
|
this( inventoryPlayer, te, new ContainerMEMonitorable( inventoryPlayer, null ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, IStorageMonitorable te, ContainerMEMonitorable c) {
|
||||||
|
|
||||||
|
super( c );
|
||||||
myScrollBar = new GuiScrollbar();
|
myScrollBar = new GuiScrollbar();
|
||||||
repo = new ItemRepo( myScrollBar );
|
repo = new ItemRepo( myScrollBar );
|
||||||
xSize = 195;
|
xSize = 195;
|
||||||
@@ -74,7 +80,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
|||||||
{
|
{
|
||||||
int NEI = 0;
|
int NEI = 0;
|
||||||
int top = 4;
|
int top = 4;
|
||||||
int extraSpace = height - 114 - NEI - top;
|
int extraSpace = height - 114 - NEI - top - reservedSpace;
|
||||||
|
|
||||||
rows = (int) Math.floor( extraSpace / 18 );
|
rows = (int) Math.floor( extraSpace / 18 );
|
||||||
if ( rows > maxRows )
|
if ( rows > maxRows )
|
||||||
@@ -97,7 +103,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
|||||||
// extra slots : 72
|
// extra slots : 72
|
||||||
// slot 18
|
// slot 18
|
||||||
|
|
||||||
this.ySize = 114 + rows * 18;
|
this.ySize = 114 + rows * 18 + reservedSpace;
|
||||||
this.guiTop = top;
|
this.guiTop = top;
|
||||||
|
|
||||||
buttonList.add( new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.SORT_BY, Configuration.instance.settings.getSetting( Settings.SORT_BY ) ) );
|
buttonList.add( new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.SORT_BY, Configuration.instance.settings.getSetting( Settings.SORT_BY ) ) );
|
||||||
@@ -163,7 +169,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
|||||||
for (int x = 0; x < rows; x++)
|
for (int x = 0; x < rows; x++)
|
||||||
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, xSize, 18 );
|
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, xSize, 18 );
|
||||||
|
|
||||||
this.drawTexturedModalRect( offsetX, offsetY + 16 + rows * 18, 0, 106, xSize, 98 );
|
this.drawTexturedModalRect( offsetX, offsetY + 16 + rows * 18, 0, 106, xSize, 98 + reservedSpace );
|
||||||
|
|
||||||
searchField.drawTextBox();
|
searchField.drawTextBox();
|
||||||
}
|
}
|
||||||
@@ -178,6 +184,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
|||||||
{
|
{
|
||||||
fontRenderer.drawString( myName.getLocal(), 8, 6, 4210752 );
|
fontRenderer.drawString( myName.getLocal(), 8, 6, 4210752 );
|
||||||
fontRenderer.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
fontRenderer.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||||
|
fontRenderer.drawString( GuiText.SecurityCardEditor.getLocal(), 8, ySize - 96 + 3 - reservedSpace, 4210752 );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,88 @@
|
|||||||
package appeng.client.gui.implementations;
|
package appeng.client.gui.implementations;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import appeng.api.config.SecurityPermissions;
|
||||||
import appeng.api.storage.IStorageMonitorable;
|
import appeng.api.storage.IStorageMonitorable;
|
||||||
|
import appeng.client.gui.widgets.GuiToggleButton;
|
||||||
|
import appeng.container.implementations.ContainerSecurity;
|
||||||
|
import appeng.core.sync.packets.PacketValueConfig;
|
||||||
|
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||||
|
|
||||||
public class GuiSecurity extends GuiMEMonitorable
|
public class GuiSecurity extends GuiMEMonitorable
|
||||||
{
|
{
|
||||||
|
|
||||||
public GuiSecurity(InventoryPlayer inventoryPlayer, IStorageMonitorable te) {
|
public GuiSecurity(InventoryPlayer inventoryPlayer, IStorageMonitorable te) {
|
||||||
super( inventoryPlayer, te );
|
super( inventoryPlayer, te, new ContainerSecurity( inventoryPlayer, te ) );
|
||||||
perRow = 5;
|
reservedSpace = 32;
|
||||||
xoffset = 81;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GuiToggleButton inject, extract, craft, build, security;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui()
|
||||||
|
{
|
||||||
|
super.initGui();
|
||||||
|
|
||||||
|
int top = this.guiTop + this.ySize - 114;
|
||||||
|
buttonList.add( inject = new GuiToggleButton( this.guiLeft + 56 + 18 * 0, top, 11 * 16 + 0, 12 * 16 + 0, SecurityPermissions.INJECT
|
||||||
|
.getUnlocalizedName(), SecurityPermissions.INJECT.getUnlocalizedTip() ) );
|
||||||
|
|
||||||
|
buttonList.add( extract = new GuiToggleButton( this.guiLeft + 56 + 18 * 1, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT
|
||||||
|
.getUnlocalizedName(), SecurityPermissions.EXTRACT.getUnlocalizedTip() ) );
|
||||||
|
|
||||||
|
buttonList.add( craft = new GuiToggleButton( this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, SecurityPermissions.CRAFT.getUnlocalizedName(),
|
||||||
|
SecurityPermissions.CRAFT.getUnlocalizedTip() ) );
|
||||||
|
|
||||||
|
buttonList.add( build = new GuiToggleButton( this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, SecurityPermissions.BUILD.getUnlocalizedName(),
|
||||||
|
SecurityPermissions.BUILD.getUnlocalizedTip() ) );
|
||||||
|
|
||||||
|
buttonList.add( security = new GuiToggleButton( this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY
|
||||||
|
.getUnlocalizedName(), SecurityPermissions.SECURITY.getUnlocalizedTip() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void actionPerformed(net.minecraft.client.gui.GuiButton btn)
|
||||||
|
{
|
||||||
|
super.actionPerformed( btn );
|
||||||
|
|
||||||
|
SecurityPermissions toggleSetting = null;
|
||||||
|
|
||||||
|
if ( btn == inject )
|
||||||
|
toggleSetting = SecurityPermissions.INJECT;
|
||||||
|
if ( btn == extract )
|
||||||
|
toggleSetting = SecurityPermissions.EXTRACT;
|
||||||
|
if ( btn == craft )
|
||||||
|
toggleSetting = SecurityPermissions.CRAFT;
|
||||||
|
if ( btn == build )
|
||||||
|
toggleSetting = SecurityPermissions.BUILD;
|
||||||
|
if ( btn == security )
|
||||||
|
toggleSetting = SecurityPermissions.SECURITY;
|
||||||
|
|
||||||
|
if ( toggleSetting != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PacketDispatcher.sendPacketToServer( (new PacketValueConfig( "TileSecurity.ToggleOption", toggleSetting.name() )).getPacket() );
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
protected String getBackground()
|
protected String getBackground()
|
||||||
{
|
{
|
||||||
|
ContainerSecurity cs = (ContainerSecurity) inventorySlots;
|
||||||
|
|
||||||
|
inject.setState( (cs.security & (1 << SecurityPermissions.INJECT.ordinal())) > 0 );
|
||||||
|
extract.setState( (cs.security & (1 << SecurityPermissions.EXTRACT.ordinal())) > 0 );
|
||||||
|
craft.setState( (cs.security & (1 << SecurityPermissions.CRAFT.ordinal())) > 0 );
|
||||||
|
build.setState( (cs.security & (1 << SecurityPermissions.BUILD.ordinal())) > 0 );
|
||||||
|
security.setState( (cs.security & (1 << SecurityPermissions.SECURITY.ordinal())) > 0 );
|
||||||
|
|
||||||
return "guis/security.png";
|
return "guis/security.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
package appeng.client.gui.widgets;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import appeng.client.texture.ExtraTextures;
|
||||||
|
|
||||||
|
public class GuiToggleButton extends GuiButton implements ITooltip
|
||||||
|
{
|
||||||
|
|
||||||
|
int iconIdxOn;
|
||||||
|
int iconIdxOff;
|
||||||
|
|
||||||
|
String Name;
|
||||||
|
String Hint;
|
||||||
|
|
||||||
|
boolean on;
|
||||||
|
|
||||||
|
public void setState(boolean isOn)
|
||||||
|
{
|
||||||
|
on = isOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVisibility(boolean vis)
|
||||||
|
{
|
||||||
|
drawButton = vis;
|
||||||
|
enabled = vis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GuiToggleButton(int x, int y, int on, int off, String Name, String Hint) {
|
||||||
|
super( 0, 0, 16, "" );
|
||||||
|
iconIdxOn = on;
|
||||||
|
iconIdxOff = off;
|
||||||
|
this.Name = Name;
|
||||||
|
this.Hint = Hint;
|
||||||
|
xPosition = x;
|
||||||
|
yPosition = y;
|
||||||
|
width = 16;
|
||||||
|
height = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisible()
|
||||||
|
{
|
||||||
|
return drawButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
|
||||||
|
{
|
||||||
|
if ( this.drawButton )
|
||||||
|
{
|
||||||
|
int iconIndex = getIconIndex();
|
||||||
|
|
||||||
|
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||||
|
par1Minecraft.renderEngine.bindTexture( ExtraTextures.GuiTexture( "guis/states.png" ) );
|
||||||
|
this.field_82253_i = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
|
||||||
|
|
||||||
|
int uv_y = (int) Math.floor( iconIndex / 16 );
|
||||||
|
int uv_x = iconIndex - uv_y * 16;
|
||||||
|
|
||||||
|
this.drawTexturedModalRect( this.xPosition, this.yPosition, 256 - 16, 256 - 16, 16, 16 );
|
||||||
|
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16 );
|
||||||
|
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getIconIndex()
|
||||||
|
{
|
||||||
|
return on ? iconIdxOn : iconIdxOff;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMsg()
|
||||||
|
{
|
||||||
|
String DisplayName = Name;
|
||||||
|
String DisplayValue = Hint;
|
||||||
|
|
||||||
|
if ( DisplayName != null )
|
||||||
|
{
|
||||||
|
String Name = StatCollector.translateToLocal( DisplayName );
|
||||||
|
String Value = StatCollector.translateToLocal( DisplayValue );
|
||||||
|
|
||||||
|
if ( Name == null || Name.equals( "" ) )
|
||||||
|
Name = DisplayName;
|
||||||
|
if ( Value == null || Value.equals( "" ) )
|
||||||
|
Value = DisplayValue;
|
||||||
|
|
||||||
|
Value = Value.replace( "\\n", "\n" );
|
||||||
|
StringBuilder sb = new StringBuilder( Value );
|
||||||
|
|
||||||
|
int i = sb.lastIndexOf( "\n" );
|
||||||
|
if ( i <= 0 )
|
||||||
|
i = 0;
|
||||||
|
while (i + 30 < sb.length() && (i = sb.lastIndexOf( " ", i + 30 )) != -1)
|
||||||
|
{
|
||||||
|
sb.replace( i, i + 1, "\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return Name + "\n" + sb.toString();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int xPos()
|
||||||
|
{
|
||||||
|
return xPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int yPos()
|
||||||
|
{
|
||||||
|
return yPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWidth()
|
||||||
|
{
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeight()
|
||||||
|
{
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -34,10 +34,10 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
|
|||||||
final IMEMonitor<IAEItemStack> monitor;
|
final IMEMonitor<IAEItemStack> monitor;
|
||||||
final IItemList<IAEItemStack> items = new ItemList<IAEItemStack>();
|
final IItemList<IAEItemStack> items = new ItemList<IAEItemStack>();
|
||||||
|
|
||||||
protected ContainerMEMonitorable(InventoryPlayer ip, IStorageMonitorable montiorable, boolean isServer) {
|
protected ContainerMEMonitorable(InventoryPlayer ip, IStorageMonitorable montiorable, boolean bindInventory) {
|
||||||
super( ip, montiorable instanceof TileEntity ? (TileEntity) montiorable : null, montiorable instanceof IPart ? (IPart) montiorable : null );
|
super( ip, montiorable instanceof TileEntity ? (TileEntity) montiorable : null, montiorable instanceof IPart ? (IPart) montiorable : null );
|
||||||
|
|
||||||
if ( isServer )
|
if ( Platform.isServer() )
|
||||||
{
|
{
|
||||||
monitor = montiorable.getItemInventory();
|
monitor = montiorable.getItemInventory();
|
||||||
monitor.addListener( this, null );
|
monitor.addListener( this, null );
|
||||||
@@ -62,11 +62,12 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
|
|||||||
else
|
else
|
||||||
monitor = null;
|
monitor = null;
|
||||||
|
|
||||||
bindPlayerInventory( ip, 0, 0 );
|
if ( bindInventory )
|
||||||
|
bindPlayerInventory( ip, 0, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerMEMonitorable(InventoryPlayer ip, IStorageMonitorable montiorable) {
|
public ContainerMEMonitorable(InventoryPlayer ip, IStorageMonitorable montiorable) {
|
||||||
this( ip, montiorable, Platform.isServer() );
|
this( ip, montiorable, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,14 +1,58 @@
|
|||||||
package appeng.container.implementations;
|
package appeng.container.implementations;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.inventory.ICrafting;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import appeng.api.config.SecurityPermissions;
|
import appeng.api.config.SecurityPermissions;
|
||||||
|
import appeng.api.implementations.items.IBiometricCard;
|
||||||
import appeng.api.storage.IStorageMonitorable;
|
import appeng.api.storage.IStorageMonitorable;
|
||||||
|
import appeng.container.slot.SlotNormal;
|
||||||
|
import appeng.tile.misc.TileSecurity;
|
||||||
|
import appeng.util.Platform;
|
||||||
|
|
||||||
public class ContainerSecurity extends ContainerMEMonitorable
|
public class ContainerSecurity extends ContainerMEMonitorable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
SlotNormal configSlot;
|
||||||
|
|
||||||
public ContainerSecurity(InventoryPlayer ip, IStorageMonitorable montiorable) {
|
public ContainerSecurity(InventoryPlayer ip, IStorageMonitorable montiorable) {
|
||||||
super( ip, montiorable );
|
super( ip, montiorable, false );
|
||||||
|
|
||||||
|
addSlotToContainer( configSlot = new SlotNormal( ((TileSecurity) montiorable).configSlot, 0, 37, -32 ) );
|
||||||
|
|
||||||
|
bindPlayerInventory( ip, 0, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int security = 0;
|
||||||
|
|
||||||
|
public void toggleSetting(String value, EntityPlayer player)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SecurityPermissions permission = SecurityPermissions.valueOf( value );
|
||||||
|
|
||||||
|
ItemStack a = configSlot.getStack();
|
||||||
|
if ( a != null && a.getItem() instanceof IBiometricCard )
|
||||||
|
{
|
||||||
|
IBiometricCard bc = (IBiometricCard) a.getItem();
|
||||||
|
if ( bc.hasPermission( a, permission ) )
|
||||||
|
bc.removePermission( a, permission );
|
||||||
|
else
|
||||||
|
bc.addPermission( a, permission );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (EnumConstantNotPresentException ex)
|
||||||
|
{
|
||||||
|
// :(
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateProgressBar(int key, int value)
|
||||||
|
{
|
||||||
|
if ( key == 0 )
|
||||||
|
security = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -16,6 +60,33 @@ public class ContainerSecurity extends ContainerMEMonitorable
|
|||||||
{
|
{
|
||||||
verifyPermissions( SecurityPermissions.SECURITY, true );
|
verifyPermissions( SecurityPermissions.SECURITY, true );
|
||||||
|
|
||||||
|
int newSecurity = 0;
|
||||||
|
|
||||||
|
ItemStack a = configSlot.getStack();
|
||||||
|
if ( a != null && a.getItem() instanceof IBiometricCard )
|
||||||
|
{
|
||||||
|
IBiometricCard bc = (IBiometricCard) a.getItem();
|
||||||
|
|
||||||
|
for (SecurityPermissions sp : bc.getPermissions( a ))
|
||||||
|
newSecurity = newSecurity | (1 << sp.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( newSecurity != security )
|
||||||
|
{
|
||||||
|
if ( Platform.isServer() )
|
||||||
|
{
|
||||||
|
for (int i = 0; i < this.crafters.size(); ++i)
|
||||||
|
{
|
||||||
|
ICrafting icrafting = (ICrafting) this.crafters.get( i );
|
||||||
|
|
||||||
|
icrafting.sendProgressBarUpdate( this, 0, newSecurity );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
security = newSecurity;
|
||||||
|
}
|
||||||
|
|
||||||
super.detectAndSendChanges();
|
super.detectAndSendChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ public enum GuiText
|
|||||||
|
|
||||||
StorageBus, Priority, Security, Encoded, Blank, Unlinked, Linked,
|
StorageBus, Priority, Security, Encoded, Blank, Unlinked, Linked,
|
||||||
|
|
||||||
|
SecurityCardEditor, NoPermissions,
|
||||||
|
|
||||||
METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel;
|
METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel;
|
||||||
|
|
||||||
String root;
|
String root;
|
||||||
|
|||||||
+100
-20
@@ -8,11 +8,17 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import appeng.api.config.SecurityPermissions;
|
||||||
import appeng.api.exceptions.AppEngException;
|
import appeng.api.exceptions.AppEngException;
|
||||||
import appeng.api.implementations.IUpgradeableHost;
|
import appeng.api.implementations.IUpgradeableHost;
|
||||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||||
|
import appeng.api.networking.IGrid;
|
||||||
|
import appeng.api.networking.IGridNode;
|
||||||
|
import appeng.api.networking.energy.IEnergyGrid;
|
||||||
|
import appeng.api.networking.security.IActionHost;
|
||||||
|
import appeng.api.networking.security.ISecurityGrid;
|
||||||
import appeng.api.parts.IPart;
|
import appeng.api.parts.IPart;
|
||||||
import appeng.api.parts.IPartHost;
|
import appeng.api.parts.IPartHost;
|
||||||
import appeng.api.storage.IStorageMonitorable;
|
import appeng.api.storage.IStorageMonitorable;
|
||||||
@@ -42,6 +48,7 @@ import appeng.helpers.IInterfaceHost;
|
|||||||
import appeng.helpers.IPriorityHost;
|
import appeng.helpers.IPriorityHost;
|
||||||
import appeng.parts.automation.PartLevelEmitter;
|
import appeng.parts.automation.PartLevelEmitter;
|
||||||
import appeng.parts.misc.PartStorageBus;
|
import appeng.parts.misc.PartStorageBus;
|
||||||
|
import appeng.server.AccessType;
|
||||||
import appeng.tile.grindstone.TileGrinder;
|
import appeng.tile.grindstone.TileGrinder;
|
||||||
import appeng.tile.misc.TileCellWorkbench;
|
import appeng.tile.misc.TileCellWorkbench;
|
||||||
import appeng.tile.misc.TileCondenser;
|
import appeng.tile.misc.TileCondenser;
|
||||||
@@ -59,47 +66,48 @@ public enum GuiBridge implements IGuiHandler
|
|||||||
{
|
{
|
||||||
GUI_Handler(),
|
GUI_Handler(),
|
||||||
|
|
||||||
GUI_GRINDER(ContainerGrinder.class, TileGrinder.class, false),
|
GUI_GRINDER(ContainerGrinder.class, TileGrinder.class, false, null),
|
||||||
|
|
||||||
GUI_QNB(ContainerQNB.class, TileQuantumBridge.class, false),
|
GUI_QNB(ContainerQNB.class, TileQuantumBridge.class, false, SecurityPermissions.BUILD),
|
||||||
|
|
||||||
GUI_CHEST(ContainerChest.class, TileChest.class, false),
|
GUI_CHEST(ContainerChest.class, TileChest.class, false, SecurityPermissions.BUILD),
|
||||||
|
|
||||||
GUI_ME(ContainerMEMonitorable.class, IStorageMonitorable.class, false),
|
GUI_ME(ContainerMEMonitorable.class, IStorageMonitorable.class, false, null),
|
||||||
|
|
||||||
GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, true),
|
GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, true, null),
|
||||||
|
|
||||||
GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, true),
|
GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, true, null),
|
||||||
|
|
||||||
GUI_NETWORK_TOOL(ContainerNetworkTool.class, INetworkTool.class, true),
|
GUI_NETWORK_TOOL(ContainerNetworkTool.class, INetworkTool.class, true, null),
|
||||||
|
|
||||||
GUI_DRIVE(ContainerDrive.class, TileDrive.class, false),
|
GUI_DRIVE(ContainerDrive.class, TileDrive.class, false, SecurityPermissions.BUILD),
|
||||||
|
|
||||||
GUI_VIBRATIONCHAMBER(ContainerVibrationChamber.class, TileVibrationChamber.class, false),
|
GUI_VIBRATIONCHAMBER(ContainerVibrationChamber.class, TileVibrationChamber.class, false, null),
|
||||||
|
|
||||||
GUI_CONDENSER(ContainerCondenser.class, TileCondenser.class, false),
|
GUI_CONDENSER(ContainerCondenser.class, TileCondenser.class, false, null),
|
||||||
|
|
||||||
GUI_INTERFACE(ContainerInterface.class, IInterfaceHost.class, false),
|
GUI_INTERFACE(ContainerInterface.class, IInterfaceHost.class, false, SecurityPermissions.BUILD),
|
||||||
|
|
||||||
GUI_BUS(ContainerUpgradeable.class, IUpgradeableHost.class, false),
|
GUI_BUS(ContainerUpgradeable.class, IUpgradeableHost.class, false, SecurityPermissions.BUILD),
|
||||||
|
|
||||||
GUI_IOPORT(ContainerIOPort.class, TileIOPort.class, false),
|
GUI_IOPORT(ContainerIOPort.class, TileIOPort.class, false, SecurityPermissions.BUILD),
|
||||||
|
|
||||||
GUI_STORAGEBUS(ContainerStorageBus.class, PartStorageBus.class, false),
|
GUI_STORAGEBUS(ContainerStorageBus.class, PartStorageBus.class, false, SecurityPermissions.BUILD),
|
||||||
|
|
||||||
GUI_PRIORITY(ContainerPriority.class, IPriorityHost.class, false),
|
GUI_PRIORITY(ContainerPriority.class, IPriorityHost.class, false, SecurityPermissions.BUILD),
|
||||||
|
|
||||||
GUI_SECURITY(ContainerSecurity.class, TileSecurity.class, false),
|
GUI_SECURITY(ContainerSecurity.class, TileSecurity.class, false, SecurityPermissions.SECURITY),
|
||||||
|
|
||||||
// extends (Container/Gui) + Bus
|
// extends (Container/Gui) + Bus
|
||||||
GUI_LEVELEMITTER(ContainerLevelEmitter.class, PartLevelEmitter.class, false),
|
GUI_LEVELEMITTER(ContainerLevelEmitter.class, PartLevelEmitter.class, false, SecurityPermissions.BUILD),
|
||||||
|
|
||||||
GUI_CELLWORKBENCH(ContainerCellWorkbench.class, TileCellWorkbench.class, false);
|
GUI_CELLWORKBENCH(ContainerCellWorkbench.class, TileCellWorkbench.class, false, null);
|
||||||
|
|
||||||
private Class Tile;
|
private Class Tile;
|
||||||
private Class Gui;
|
private Class Gui;
|
||||||
private Class Container;
|
private Class Container;
|
||||||
private boolean isItem;
|
private boolean isItem;
|
||||||
|
private SecurityPermissions requiredPermission;
|
||||||
|
|
||||||
private GuiBridge() {
|
private GuiBridge() {
|
||||||
Tile = null;
|
Tile = null;
|
||||||
@@ -125,13 +133,15 @@ public enum GuiBridge implements IGuiHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GuiBridge(Class _Container) {
|
private GuiBridge(Class _Container, SecurityPermissions requiredPermission) {
|
||||||
|
this.requiredPermission = requiredPermission;
|
||||||
Container = _Container;
|
Container = _Container;
|
||||||
Tile = null;
|
Tile = null;
|
||||||
getGui();
|
getGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
private GuiBridge(Class _Container, Class _Tile, boolean isItem) {
|
private GuiBridge(Class _Container, Class _Tile, boolean isItem, SecurityPermissions requiredPermission) {
|
||||||
|
this.requiredPermission = requiredPermission;
|
||||||
Container = _Container;
|
Container = _Container;
|
||||||
this.isItem = isItem;
|
this.isItem = isItem;
|
||||||
Tile = _Tile;
|
Tile = _Tile;
|
||||||
@@ -270,4 +280,74 @@ public enum GuiBridge implements IGuiHandler
|
|||||||
return new GuiNull( new ContainerNull() );
|
return new GuiNull( new ContainerNull() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasPermissions(TileEntity te, int x, int y, int z, ForgeDirection side, EntityPlayer player)
|
||||||
|
{
|
||||||
|
World w = player.getEntityWorld();
|
||||||
|
|
||||||
|
if ( Platform.hasPermissions( x, y, z, player, AccessType.BLOCK_ACCESS ) )
|
||||||
|
{
|
||||||
|
if ( isItem() )
|
||||||
|
{
|
||||||
|
ItemStack it = player.inventory.getCurrentItem();
|
||||||
|
if ( it != null && it.getItem() instanceof IGuiItem )
|
||||||
|
{
|
||||||
|
Object myItem = ((IGuiItem) it.getItem()).getGuiObject( it, w, x, y, z );
|
||||||
|
if ( CorrectTileOrPart( myItem ) )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TileEntity TE = w.getBlockTileEntity( x, y, z );
|
||||||
|
if ( TE instanceof IPartHost )
|
||||||
|
{
|
||||||
|
((IPartHost) TE).getPart( side );
|
||||||
|
IPart part = ((IPartHost) TE).getPart( side );
|
||||||
|
if ( CorrectTileOrPart( part ) )
|
||||||
|
return securityCheck( part, player );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( CorrectTileOrPart( TE ) )
|
||||||
|
return securityCheck( TE, player );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean securityCheck(Object te, EntityPlayer player)
|
||||||
|
{
|
||||||
|
if ( te instanceof IActionHost && requiredPermission != null )
|
||||||
|
{
|
||||||
|
boolean requirePower = false;
|
||||||
|
|
||||||
|
IGridNode gn = ((IActionHost) te).getActionableNode();
|
||||||
|
if ( gn != null )
|
||||||
|
{
|
||||||
|
IGrid g = gn.getGrid();
|
||||||
|
if ( g != null )
|
||||||
|
{
|
||||||
|
if ( requirePower )
|
||||||
|
{
|
||||||
|
IEnergyGrid eg = g.getCache( IEnergyGrid.class );
|
||||||
|
if ( !eg.isNetworkPowered() )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ISecurityGrid sg = g.getCache( ISecurityGrid.class );
|
||||||
|
if ( sg.hasPermission( player, requiredPermission ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import appeng.api.config.FuzzyMode;
|
|||||||
import appeng.container.implementations.ContainerCellWorkbench;
|
import appeng.container.implementations.ContainerCellWorkbench;
|
||||||
import appeng.container.implementations.ContainerLevelEmitter;
|
import appeng.container.implementations.ContainerLevelEmitter;
|
||||||
import appeng.container.implementations.ContainerPriority;
|
import appeng.container.implementations.ContainerPriority;
|
||||||
|
import appeng.container.implementations.ContainerSecurity;
|
||||||
import appeng.core.sync.AppEngPacket;
|
import appeng.core.sync.AppEngPacket;
|
||||||
|
|
||||||
public class PacketValueConfig extends AppEngPacket
|
public class PacketValueConfig extends AppEngPacket
|
||||||
@@ -31,7 +32,13 @@ public class PacketValueConfig extends AppEngPacket
|
|||||||
{
|
{
|
||||||
Container c = player.openContainer;
|
Container c = player.openContainer;
|
||||||
|
|
||||||
if ( Name.equals( "PriorityHost.Priority" ) && c instanceof ContainerPriority )
|
if ( Name.equals( "TileSecurity.ToggleOption" ) && c instanceof ContainerSecurity )
|
||||||
|
{
|
||||||
|
ContainerSecurity sc = (ContainerSecurity) c;
|
||||||
|
sc.toggleSetting( Value, player );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if ( Name.equals( "PriorityHost.Priority" ) && c instanceof ContainerPriority )
|
||||||
{
|
{
|
||||||
ContainerPriority pc = (ContainerPriority) c;
|
ContainerPriority pc = (ContainerPriority) c;
|
||||||
pc.setPriority( Integer.parseInt( Value ), player );
|
pc.setPriority( Integer.parseInt( Value ), player );
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
|||||||
@Override
|
@Override
|
||||||
public String getItemDisplayName(ItemStack is)
|
public String getItemDisplayName(ItemStack is)
|
||||||
{
|
{
|
||||||
String username = getUserName( is );
|
String username = getUsername( is );
|
||||||
return username.length() > 0 ? super.getItemDisplayName( is ) + " - " + GuiText.Encoded.getLocal() : super.getItemDisplayName( is );
|
return username.length() > 0 ? super.getItemDisplayName( is ) + " - " + GuiText.Encoded.getLocal() : super.getItemDisplayName( is );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,24 +64,41 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
|||||||
|
|
||||||
private void encode(ItemStack is, EntityPlayer p)
|
private void encode(ItemStack is, EntityPlayer p)
|
||||||
{
|
{
|
||||||
NBTTagCompound tag = Platform.openNbtData( is );
|
String username = getUsername( is );
|
||||||
String username = tag.getString( "username" );
|
|
||||||
if ( p.username.equals( username ) )
|
if ( p.username.equals( username ) )
|
||||||
is.setTagCompound( null );
|
setUsername( is, "" );
|
||||||
else
|
else
|
||||||
tag.setString( "username", p.username );
|
setUsername( is, p.username );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack is, EntityPlayer p, List l, boolean b)
|
public void addInformation(ItemStack is, EntityPlayer p, List l, boolean b)
|
||||||
{
|
{
|
||||||
String username = getUserName( is );
|
String username = getUsername( is );
|
||||||
if ( username.length() > 0 )
|
if ( username.length() > 0 )
|
||||||
l.add( username );
|
l.add( username );
|
||||||
|
|
||||||
|
EnumSet<SecurityPermissions> perms = getPermissions( is );
|
||||||
|
if ( perms.isEmpty() )
|
||||||
|
l.add( GuiText.NoPermissions.getLocal() );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String msg = null;
|
||||||
|
|
||||||
|
for (SecurityPermissions sp : perms)
|
||||||
|
{
|
||||||
|
if ( msg == null )
|
||||||
|
msg = Platform.gui_localize( sp.getUnlocalizedName() );
|
||||||
|
else
|
||||||
|
msg = msg + ", " + Platform.gui_localize( sp.getUnlocalizedName() );
|
||||||
|
}
|
||||||
|
l.add( msg );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUserName(ItemStack is)
|
public String getUsername(ItemStack is)
|
||||||
{
|
{
|
||||||
NBTTagCompound tag = Platform.openNbtData( is );
|
NBTTagCompound tag = Platform.openNbtData( is );
|
||||||
return tag.getString( "username" );
|
return tag.getString( "username" );
|
||||||
@@ -109,4 +126,26 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
|||||||
return tag.getBoolean( permission.name() );
|
return tag.getBoolean( permission.name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUsername(ItemStack itemStack, String username)
|
||||||
|
{
|
||||||
|
NBTTagCompound tag = Platform.openNbtData( itemStack );
|
||||||
|
tag.setString( "username", username );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removePermission(ItemStack itemStack, SecurityPermissions permission)
|
||||||
|
{
|
||||||
|
NBTTagCompound tag = Platform.openNbtData( itemStack );
|
||||||
|
if ( tag.hasKey( permission.name() ) )
|
||||||
|
tag.removeTag( permission.name() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addPermission(ItemStack itemStack, SecurityPermissions permission)
|
||||||
|
{
|
||||||
|
NBTTagCompound tag = Platform.openNbtData( itemStack );
|
||||||
|
tag.setBoolean( permission.name(), true );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,11 +96,11 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
|||||||
throw new RuntimeException( "Invalid Access to Networked Storage API detected." );
|
throw new RuntimeException( "Invalid Access to Networked Storage API detected." );
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean testPermission(BaseActionSource src, SecurityPermissions inject)
|
private boolean testPermission(BaseActionSource src, SecurityPermissions permission)
|
||||||
{
|
{
|
||||||
if ( src.isPlayer() )
|
if ( src.isPlayer() )
|
||||||
{
|
{
|
||||||
if ( !security.hasPermission( ((PlayerSource) src).player, SecurityPermissions.INJECT ) )
|
if ( !security.hasPermission( ((PlayerSource) src).player, permission ) )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ( src.isMachine() )
|
else if ( src.isMachine() )
|
||||||
@@ -119,7 +119,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
|||||||
ISecurityGrid sg = gn.getCache( ISecurityGrid.class );
|
ISecurityGrid sg = gn.getCache( ISecurityGrid.class );
|
||||||
playerID = sg.getOwner();
|
playerID = sg.getOwner();
|
||||||
|
|
||||||
if ( !security.hasPermission( playerID, SecurityPermissions.INJECT ) )
|
if ( !security.hasPermission( playerID, permission ) )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import appeng.api.AEApi;
|
|||||||
import appeng.api.config.AccessRestriction;
|
import appeng.api.config.AccessRestriction;
|
||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
import appeng.api.config.SecurityPermissions;
|
import appeng.api.config.SecurityPermissions;
|
||||||
|
import appeng.api.implementations.items.IBiometricCard;
|
||||||
import appeng.api.networking.security.BaseActionSource;
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.networking.security.PlayerSource;
|
import appeng.api.networking.security.PlayerSource;
|
||||||
import appeng.api.storage.IMEInventoryHandler;
|
import appeng.api.storage.IMEInventoryHandler;
|
||||||
@@ -45,8 +46,7 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
|||||||
{
|
{
|
||||||
if ( hasPermission( src ) && AEApi.instance().items().itemBiometricCard.sameAs( input.getItemStack() ) )
|
if ( hasPermission( src ) && AEApi.instance().items().itemBiometricCard.sameAs( input.getItemStack() ) )
|
||||||
{
|
{
|
||||||
IAEItemStack stored = storedItems.findPrecise( input );
|
if ( canAccept( input ) )
|
||||||
if ( stored == null || !stored.isMeaninful() )
|
|
||||||
{
|
{
|
||||||
if ( type == Actionable.SIMULATE )
|
if ( type == Actionable.SIMULATE )
|
||||||
return null;
|
return null;
|
||||||
@@ -110,7 +110,24 @@ public class SecurityInventory implements IMEInventoryHandler<IAEItemStack>
|
|||||||
@Override
|
@Override
|
||||||
public boolean canAccept(IAEItemStack input)
|
public boolean canAccept(IAEItemStack input)
|
||||||
{
|
{
|
||||||
return AEApi.instance().items().itemBiometricCard.sameAs( input.getItemStack() );
|
if ( input.getItem() instanceof IBiometricCard )
|
||||||
|
{
|
||||||
|
IBiometricCard tbc = (IBiometricCard) input.getItem();
|
||||||
|
String newUser = tbc.getUsername( input.getItemStack() );
|
||||||
|
|
||||||
|
for (IAEItemStack ais : storedItems)
|
||||||
|
{
|
||||||
|
if ( ais.isMeaninful() )
|
||||||
|
{
|
||||||
|
String thisUser = tbc.getUsername( ais.getItemStack() );
|
||||||
|
if ( thisUser.equals( newUser ) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -80,6 +80,14 @@ public class BusCollisionHelper implements IPartCollsionHelper
|
|||||||
return !isVisual;
|
return !isVisual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pretty much useless...
|
||||||
|
*/
|
||||||
|
public Entity getEntity()
|
||||||
|
{
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
|
public void addBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
|||||||
|
|
||||||
public void activate(EntityPlayer player)
|
public void activate(EntityPlayer player)
|
||||||
{
|
{
|
||||||
if ( !Platform.hasPermissions( this, player, AccessType.BLOCK_ACCESS ) )
|
if ( !Platform.hasPermissions( xCoord, yCoord, zCoord, player, AccessType.BLOCK_ACCESS ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ItemStack myItem = getStackInSlot( 0 );
|
ItemStack myItem = getStackInSlot( 0 );
|
||||||
|
|||||||
@@ -3,12 +3,15 @@ package appeng.tile.misc;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.config.SecurityPermissions;
|
import appeng.api.config.SecurityPermissions;
|
||||||
@@ -32,10 +35,13 @@ import appeng.me.storage.SecurityInventory;
|
|||||||
import appeng.tile.events.AETileEventHandler;
|
import appeng.tile.events.AETileEventHandler;
|
||||||
import appeng.tile.events.TileEventType;
|
import appeng.tile.events.TileEventType;
|
||||||
import appeng.tile.grid.AENetworkTile;
|
import appeng.tile.grid.AENetworkTile;
|
||||||
|
import appeng.tile.inventory.AppEngInternalInventory;
|
||||||
|
import appeng.tile.inventory.IAEAppEngInventory;
|
||||||
|
import appeng.tile.inventory.InvOperation;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.item.AEItemStack;
|
import appeng.util.item.AEItemStack;
|
||||||
|
|
||||||
public class TileSecurity extends AENetworkTile implements IStorageMonitorable
|
public class TileSecurity extends AENetworkTile implements IStorageMonitorable, IAEAppEngInventory
|
||||||
{
|
{
|
||||||
|
|
||||||
private static int diffrence = 0;
|
private static int diffrence = 0;
|
||||||
@@ -47,6 +53,21 @@ public class TileSecurity extends AENetworkTile implements IStorageMonitorable
|
|||||||
|
|
||||||
public long securityKey;
|
public long securityKey;
|
||||||
|
|
||||||
|
public AppEngInternalInventory configSlot = new AppEngInternalInventory( this, 1 );
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getDrops(World w, int x, int y, int z, ArrayList<ItemStack> drops)
|
||||||
|
{
|
||||||
|
for (IAEItemStack ais : inventory.storedItems)
|
||||||
|
drops.add( ais.getItemStack() );
|
||||||
|
}
|
||||||
|
|
||||||
IMEInventoryHandler<IAEItemStack> getSecurityInventory()
|
IMEInventoryHandler<IAEItemStack> getSecurityInventory()
|
||||||
{
|
{
|
||||||
return inventory;
|
return inventory;
|
||||||
@@ -100,6 +121,8 @@ public class TileSecurity extends AENetworkTile implements IStorageMonitorable
|
|||||||
public void writeToNBT(NBTTagCompound data)
|
public void writeToNBT(NBTTagCompound data)
|
||||||
{
|
{
|
||||||
data.setLong( "securityKey", securityKey );
|
data.setLong( "securityKey", securityKey );
|
||||||
|
configSlot.writeToNBT( data, "config" );
|
||||||
|
|
||||||
NBTTagCompound storedItems = new NBTTagCompound();
|
NBTTagCompound storedItems = new NBTTagCompound();
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
@@ -117,6 +140,8 @@ public class TileSecurity extends AENetworkTile implements IStorageMonitorable
|
|||||||
public void readFromNBT(NBTTagCompound data)
|
public void readFromNBT(NBTTagCompound data)
|
||||||
{
|
{
|
||||||
securityKey = data.getLong( "securityKey" );
|
securityKey = data.getLong( "securityKey" );
|
||||||
|
configSlot.readFromNBT( data, "config" );
|
||||||
|
|
||||||
NBTTagCompound storedItems = data.getCompoundTag( "storedItems" );
|
NBTTagCompound storedItems = data.getCompoundTag( "storedItems" );
|
||||||
for (Object obj : storedItems.getTags())
|
for (Object obj : storedItems.getTags())
|
||||||
{
|
{
|
||||||
@@ -153,7 +178,7 @@ public class TileSecurity extends AENetworkTile implements IStorageMonitorable
|
|||||||
if ( i instanceof IBiometricCard )
|
if ( i instanceof IBiometricCard )
|
||||||
{
|
{
|
||||||
IBiometricCard bc = (IBiometricCard) i;
|
IBiometricCard bc = (IBiometricCard) i;
|
||||||
playerPerms.put( pr.getID( bc.getUserName( is ) ), bc.getPermissions( is ) );
|
playerPerms.put( pr.getID( bc.getUsername( is ) ), bc.getPermissions( is ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-12
@@ -278,29 +278,33 @@ public class Platform
|
|||||||
return FMLCommonHandler.instance().getEffectiveSide().isServer();
|
return FMLCommonHandler.instance().getEffectiveSide().isServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasPermissions(TileEntity myTile, EntityPlayer player, AccessType blockAccess)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void openGUI(EntityPlayer p, TileEntity tile, ForgeDirection side, GuiBridge type)
|
public static void openGUI(EntityPlayer p, TileEntity tile, ForgeDirection side, GuiBridge type)
|
||||||
{
|
{
|
||||||
if ( isClient() )
|
if ( isClient() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( type.isItem() || hasPermissions( tile, p, AccessType.BLOCK_ACCESS ) )
|
int x = (int) p.posX, y = (int) p.posY, z = (int) p.posZ;
|
||||||
|
if ( tile != null )
|
||||||
|
{
|
||||||
|
x = tile.xCoord;
|
||||||
|
y = tile.yCoord;
|
||||||
|
z = tile.zCoord;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( type.isItem() || type.hasPermissions( tile, x, y, z, side, p ) )
|
||||||
{
|
{
|
||||||
if ( tile == null )
|
if ( tile == null )
|
||||||
{
|
p.openGui( AppEng.instance, type.ordinal() << 3, p.getEntityWorld(), x, y, z );
|
||||||
p.openGui( AppEng.instance, type.ordinal() << 3, p.getEntityWorld(), (int) p.posX, (int) p.posY, (int) p.posZ );
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
p.openGui( AppEng.instance, type.ordinal() << 3 | (side.ordinal()), tile.worldObj, x, y, z );
|
||||||
p.openGui( AppEng.instance, type.ordinal() << 3 | (side.ordinal()), tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasPermissions(int x, int y, int z, EntityPlayer player, AccessType blockAccess)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checks to see if a block is air?
|
* Checks to see if a block is air?
|
||||||
*/
|
*/
|
||||||
@@ -1468,4 +1472,5 @@ public class Platform
|
|||||||
|
|
||||||
return !gs.hasPermission( playerID, SecurityPermissions.BUILD );
|
return !gs.hasPermission( playerID, SecurityPermissions.BUILD );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user