Pretty much all of security minus the gui.
and all the stuff I did that i forgot to comment.
This commit is contained in:
@@ -14,9 +14,14 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
@@ -43,6 +48,53 @@ public abstract class AEBaseContainer extends Container
|
||||
|
||||
BaseActionSource mySrc;
|
||||
|
||||
int ticksSinceCheck = 900;
|
||||
|
||||
public void verifyPermissions(SecurityPermissions security, boolean requirePower)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
ticksSinceCheck++;
|
||||
if ( ticksSinceCheck < 20 )
|
||||
return;
|
||||
|
||||
ticksSinceCheck = 0;
|
||||
IActionHost host = null;
|
||||
|
||||
if ( tileEntity instanceof IActionHost )
|
||||
host = (IActionHost) tileEntity;
|
||||
if ( part instanceof IActionHost )
|
||||
host = (IActionHost) part;
|
||||
|
||||
if ( host == null )
|
||||
invPlayer.player.closeScreen();// close!
|
||||
else
|
||||
{
|
||||
IGridNode gn = host.getActionableNode();
|
||||
if ( gn != null )
|
||||
{
|
||||
IGrid g = gn.getGrid();
|
||||
if ( g != null )
|
||||
{
|
||||
if ( requirePower )
|
||||
{
|
||||
IEnergyGrid eg = g.getCache( IEnergyGrid.class );
|
||||
if ( !eg.isNetworkPowered() )
|
||||
{
|
||||
invPlayer.player.closeScreen();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ISecurityGrid sg = g.getCache( ISecurityGrid.class );
|
||||
if ( !sg.hasPermission( invPlayer.player, security ) )
|
||||
invPlayer.player.closeScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ContainerOpenContext openContext;
|
||||
|
||||
protected IMEInventoryHandler<IAEItemStack> cellInv;
|
||||
@@ -67,7 +119,7 @@ public abstract class AEBaseContainer extends Container
|
||||
invPlayer = ip;
|
||||
tileEntity = myTile;
|
||||
part = myPart;
|
||||
mySrc = new PlayerSource( ip.player, (IGridHost) (myTile instanceof IGridHost ? myTile : (myPart instanceof IGridHost ? myPart : null)) );
|
||||
mySrc = new PlayerSource( ip.player, (IActionHost) (myTile instanceof IActionHost ? myTile : (myPart instanceof IActionHost ? myPart : null)) );
|
||||
}
|
||||
|
||||
public boolean canDragIntoSlot(Slot s)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package appeng.container;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class ContainerOpenContext
|
||||
{
|
||||
|
||||
public World w;
|
||||
public int x, y, z;
|
||||
public ForgeDirection side;
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.inventory.IInventory;
|
||||
import appeng.api.config.FullnessMode;
|
||||
import appeng.api.config.OperationMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
@@ -70,6 +71,8 @@ public class ContainerIOPort extends ContainerUpgradeable
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
for (int i = 0; i < this.crafters.size(); ++i)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.container.slot.SlotNormal;
|
||||
@@ -30,4 +31,10 @@ public class ContainerInterface extends AEBaseContainer
|
||||
bindPlayerInventory( ip, 0, 211 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
@@ -80,6 +81,8 @@ public class ContainerLevelEmitter extends ContainerUpgradeable
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
for (int i = 0; i < this.crafters.size(); ++i)
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerPriority extends AEBaseContainer
|
||||
{
|
||||
|
||||
IPriorityHost priHost;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public GuiTextField textField;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setTextField(GuiTextField level)
|
||||
{
|
||||
textField = level;
|
||||
textField.setText( "" + PriorityValue );
|
||||
}
|
||||
|
||||
public ContainerPriority(InventoryPlayer ip, IPriorityHost te) {
|
||||
super( ip, (TileEntity) (te instanceof TileEntity ? te : null), (IPart) (te instanceof IPart ? te : null) );
|
||||
priHost = te;
|
||||
}
|
||||
|
||||
int PriorityValue = -1;
|
||||
|
||||
public void setPriority(int newValue, EntityPlayer player)
|
||||
{
|
||||
priHost.setPriority( newValue );
|
||||
PriorityValue = newValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
for (int i = 0; i < this.crafters.size(); ++i)
|
||||
{
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get( i );
|
||||
|
||||
if ( this.PriorityValue != priHost.getPriority() )
|
||||
{
|
||||
icrafting.sendProgressBarUpdate( this, 2, (int) priHost.getPriority() );
|
||||
}
|
||||
}
|
||||
|
||||
this.PriorityValue = (int) priHost.getPriority();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int idx, int value)
|
||||
{
|
||||
super.updateProgressBar( idx, value );
|
||||
|
||||
if ( idx == 2 )
|
||||
{
|
||||
PriorityValue = value;
|
||||
if ( textField != null )
|
||||
textField.setText( "" + PriorityValue );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.tile.misc.TileSecurity;
|
||||
|
||||
public class ContainerSecurity extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileSecurity myte;
|
||||
|
||||
public ContainerSecurity(InventoryPlayer ip, TileSecurity te) {
|
||||
super( ip, te, null );
|
||||
myte = te;
|
||||
|
||||
bindPlayerInventory( ip, 0, 199 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.SECURITY, true );
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
@@ -22,4 +23,12 @@ public class ContainerSpatialIOPort extends AEBaseContainer
|
||||
bindPlayerInventory( ip, 0, 199 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.container.slot.OptionalSlotFakeTypeOnly;
|
||||
@@ -80,6 +81,8 @@ public class ContainerStorageBus extends ContainerUpgradeable
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
for (int i = 0; i < this.crafters.size(); ++i)
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
@@ -159,6 +160,8 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
for (int i = 0; i < this.crafters.size(); ++i)
|
||||
|
||||
Reference in New Issue
Block a user