More secure logic.
This commit is contained in:
parent
2d1e11fc81
commit
47a4c58052
|
@ -4,8 +4,8 @@ import net.minecraft.src.EntityPlayer;
|
|||
|
||||
public interface IOwnable {
|
||||
|
||||
boolean isSecure();
|
||||
String getOwnerName();
|
||||
|
||||
void setOwner(EntityPlayer player);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package net.minecraft.src.buildcraft.core.utils;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.buildcraft.api.ISpecialInventory;
|
||||
import net.minecraft.src.buildcraft.api.Orientations;
|
||||
|
||||
public interface ISecuredInventory extends ISpecialInventory {
|
||||
|
||||
public String getOwnerName();
|
||||
public boolean addItem (ItemStack stack, boolean doAdd, Orientations from, String owner);
|
||||
public ItemStack extractItem(boolean doRemove, Orientations from, String owner);
|
||||
|
||||
}
|
|
@ -142,6 +142,10 @@ public class Pipe extends PersistentTile implements IPipe, IDropControlInventory
|
|||
updateSignalState();
|
||||
}
|
||||
|
||||
/// OWNERSHIP
|
||||
public boolean isSecure() { return logic.isSecure(); }
|
||||
|
||||
/// CONNECTING
|
||||
public boolean isPipeConnected(TileEntity tile) {
|
||||
return logic.isPipeConnected(tile) && transport.isPipeConnected (tile);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,9 @@ public class PipeLogic implements IDropControlInventory {
|
|||
return false;
|
||||
}
|
||||
|
||||
/// OWNERSHIP
|
||||
public boolean isSecure() { return false; }
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package net.minecraft.src.buildcraft.transport;
|
||||
|
||||
public class PipeLogicSteel extends PipeLogic {
|
||||
|
||||
@Override public boolean isSecure() { return true; }
|
||||
}
|
||||
|
|
|
@ -5,21 +5,36 @@ import net.minecraft.src.TileEntity;
|
|||
import net.minecraft.src.buildcraft.api.IPipeEntry;
|
||||
import net.minecraft.src.buildcraft.core.IMachine;
|
||||
import net.minecraft.src.buildcraft.core.utils.IOwnable;
|
||||
import net.minecraft.src.buildcraft.core.utils.ISecuredInventory;
|
||||
|
||||
public class PipeTransportSecure extends PipeTransportItems {
|
||||
|
||||
@Override
|
||||
public boolean isPipeConnected(TileEntity tile) {
|
||||
if(!(tile instanceof IOwnable))
|
||||
return false;
|
||||
|
||||
IOwnable ownable = (IOwnable)tile;
|
||||
return ownable.getOwnerName().equals(container.getOwnerName());
|
||||
if(tile instanceof IOwnable) {
|
||||
IOwnable ownable = (IOwnable)tile;
|
||||
if(ownable.isSecure())
|
||||
return ownable.getOwnerName().equals(container.getOwnerName());
|
||||
}
|
||||
|
||||
if(tile instanceof ISecuredInventory) {
|
||||
ISecuredInventory inventory = (ISecuredInventory)tile;
|
||||
return inventory.getOwnerName().equals(container.getOwnerName());
|
||||
}
|
||||
|
||||
System.out.println("isPipeConnected returning false.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowsConnect(PipeTransport with) {
|
||||
return with instanceof PipeTransportSecure;
|
||||
|
||||
if(with instanceof PipeTransportSecure)
|
||||
return true;
|
||||
|
||||
System.out.println("allowsConnect returning false.");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -120,6 +120,13 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor,
|
|||
/// OWNERSHIP
|
||||
private String owner;
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
if(pipe != null)
|
||||
return pipe.isSecure();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public String getOwnerName() {
|
||||
return owner;
|
||||
|
|
Loading…
Reference in a new issue