mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-27 15:23:16 +00:00
Start integrating security into all machinery. This is a very rough implementation, there's gonna be a lot of balance and corrections to make before release
This commit is contained in:
1 parent
9c480954e3
commit
f904c8b80c
58 files changed
+700
-1822
No files matched your search
@@ -13,6 +13,7 @@ import mekanism.api.Coord4D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.chunkloading.IChunkLoader;
|
||||
import mekanism.common.frequency.Frequency;
|
||||
@@ -21,6 +22,8 @@ import mekanism.common.frequency.IFrequencyHandler;
|
||||
import mekanism.common.integration.IComputerIntegration;
|
||||
import mekanism.common.network.PacketPortalFX.PortalFXMessage;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -44,7 +47,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityTeleporter extends TileEntityElectricBlock implements IComputerIntegration, IChunkLoader, IFrequencyHandler
|
||||
public class TileEntityTeleporter extends TileEntityElectricBlock implements IComputerIntegration, IChunkLoader, IFrequencyHandler, IRedstoneControl, ISecurityTile
|
||||
{
|
||||
private MinecraftServer server = MinecraftServer.getServer();
|
||||
|
||||
@@ -58,8 +61,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
|
||||
public boolean prevShouldRender;
|
||||
|
||||
public String owner;
|
||||
|
||||
public Frequency frequency;
|
||||
|
||||
public List<Frequency> publicCache = new ArrayList<Frequency>();
|
||||
@@ -69,11 +70,17 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
|
||||
/** This teleporter's current status. */
|
||||
public byte status = 0;
|
||||
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileComponentSecurity securityComponent;
|
||||
|
||||
public TileEntityTeleporter()
|
||||
{
|
||||
super("Teleporter", MachineType.TELEPORTER.baseEnergy);
|
||||
inventory = new ItemStack[1];
|
||||
|
||||
securityComponent = new TileComponentSecurity(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,12 +115,12 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
{
|
||||
if(frequency != null && !frequency.valid)
|
||||
{
|
||||
frequency = manager.validateFrequency(owner, Coord4D.get(this), frequency);
|
||||
frequency = manager.validateFrequency(getSecurity().getOwner(), Coord4D.get(this), frequency);
|
||||
}
|
||||
|
||||
if(frequency != null)
|
||||
{
|
||||
frequency = manager.update(owner, Coord4D.get(this), frequency);
|
||||
frequency = manager.update(getSecurity().getOwner(), Coord4D.get(this), frequency);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -122,7 +129,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
|
||||
status = canTeleport();
|
||||
|
||||
if(status == 1 && teleDelay == 0)
|
||||
if(MekanismUtils.canFunction(this) && status == 1 && teleDelay == 0)
|
||||
{
|
||||
teleport();
|
||||
}
|
||||
@@ -179,7 +186,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
}
|
||||
}
|
||||
|
||||
Frequency freq = new Frequency(name, owner).setPublic(publicFreq);
|
||||
Frequency freq = new Frequency(name, getSecurity().getOwner()).setPublic(publicFreq);
|
||||
freq.activeCoords.add(Coord4D.get(this));
|
||||
manager.addFrequency(freq);
|
||||
frequency = freq;
|
||||
@@ -189,7 +196,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
|
||||
public FrequencyManager getManager(Frequency freq)
|
||||
{
|
||||
if(owner == null || freq == null)
|
||||
if(getSecurity().getOwner() == null || freq == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -199,14 +206,14 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
return Mekanism.publicTeleporters;
|
||||
}
|
||||
else {
|
||||
if(!Mekanism.privateTeleporters.containsKey(owner))
|
||||
if(!Mekanism.privateTeleporters.containsKey(getSecurity().getOwner()))
|
||||
{
|
||||
FrequencyManager manager = new FrequencyManager(Frequency.class, owner);
|
||||
Mekanism.privateTeleporters.put(owner, manager);
|
||||
FrequencyManager manager = new FrequencyManager(Frequency.class, getSecurity().getOwner());
|
||||
Mekanism.privateTeleporters.put(getSecurity().getOwner(), manager);
|
||||
manager.createOrLoad(worldObj);
|
||||
}
|
||||
|
||||
return Mekanism.privateTeleporters.get(owner);
|
||||
return Mekanism.privateTeleporters.get(getSecurity().getOwner());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,10 +545,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
if(nbtTags.hasKey("owner"))
|
||||
{
|
||||
owner = nbtTags.getString("owner");
|
||||
}
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
|
||||
if(nbtTags.hasKey("frequency"))
|
||||
{
|
||||
@@ -555,10 +559,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
if(owner != null)
|
||||
{
|
||||
nbtTags.setString("owner", owner);
|
||||
}
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
|
||||
if(frequency != null)
|
||||
{
|
||||
@@ -591,7 +592,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
|
||||
if(manager != null)
|
||||
{
|
||||
manager.remove(freq, owner);
|
||||
manager.remove(freq, getSecurity().getOwner());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -600,14 +601,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
owner = PacketHandler.readString(dataStream);
|
||||
}
|
||||
else {
|
||||
owner = null;
|
||||
}
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
frequency = new Frequency(dataStream);
|
||||
@@ -618,6 +611,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
|
||||
status = dataStream.readByte();
|
||||
shouldRender = dataStream.readBoolean();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
|
||||
publicCache.clear();
|
||||
privateCache.clear();
|
||||
@@ -642,15 +636,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
if(owner != null)
|
||||
{
|
||||
data.add(true);
|
||||
data.add(owner);
|
||||
}
|
||||
else {
|
||||
data.add(false);
|
||||
}
|
||||
|
||||
if(frequency != null)
|
||||
{
|
||||
data.add(true);
|
||||
@@ -662,6 +647,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
|
||||
data.add(status);
|
||||
data.add(shouldRender);
|
||||
data.add(controlType.ordinal());
|
||||
|
||||
data.add(Mekanism.publicTeleporters.getFrequencies().size());
|
||||
|
||||
@@ -757,4 +743,28 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
chunkTicket = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
return controlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlType(RedstoneControl type)
|
||||
{
|
||||
controlType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPulse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentSecurity getSecurity()
|
||||
{
|
||||
return securityComponent;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user