this and that

This commit is contained in:
DarkGuardsman 2013-11-25 09:59:47 -05:00
parent 517a5a506d
commit 8fb5813807
10 changed files with 113 additions and 29 deletions

View file

@ -0,0 +1,25 @@
package dark.api.access;
import net.minecraft.entity.player.EntityPlayer;
/** Container of access groups that can be used by anything. Only the core machine should load/save
* global access collections to prevent conflicts.
*
* @author DarkGuardsman */
public class AccessCollection
{
/** Was created from a save within a tile entity */
public final boolean isLocal;
ISpecialAccess machine;
public AccessCollection(ISpecialAccess machine)
{
this.isLocal = true;
this.machine = machine;
}
public AccessCollection()
{
this.isLocal = false;
}
}

View file

@ -30,11 +30,21 @@ public class AccessGroup extends Group<AccessUser>
@Override
public boolean addMemeber(AccessUser obj)
{
if (obj != null)
{
for (AccessUser user : this.memebers)
{
if (user.getName().equalsIgnoreCase(obj.getName()))
{
return false;
}
}
if (super.addMemeber(obj))
{
obj.setGroup(this);
return true;
}
}
return false;
}
@ -64,14 +74,14 @@ public class AccessGroup extends Group<AccessUser>
}
}
nbt.setTag("Users", usersTag);
usersTag = new NBTTagList();
NBTTagList nodesTag = new NBTTagList();
for (String str : this.nodes)
{
NBTTagCompound accessData = new NBTTagCompound();
accessData.setString("name", str);
usersTag.appendTag(accessData);
nodesTag.appendTag(accessData);
}
nbt.setTag("nodes", usersTag);
nbt.setTag("nodes", nodesTag);
return nbt;
}

View file

@ -31,7 +31,8 @@ public interface ISpecialAccess
/** Get all groups linked this */
public List<AccessGroup> getGroups();
/** Add a group to the group list */
public void addGroup(AccessGroup group);
/** Add a group to the group list
* @return */
public boolean addGroup(AccessGroup group);
}

View file

@ -2,21 +2,41 @@ package dark.api.parts;
import net.minecraftforge.common.ForgeDirection;
/** Used on tiles that want control over what can connect to there device. It is suggest that other
* interfaces for connection be routed threw this to reduce the need to change things
*
* @author DarkGuardsman */
public interface ITileConnector
{
/** Can this tile connect on the given side */
public boolean canTileConnect(Connection type, ForgeDirection dir);
/** Types of connections */
public static enum Connection
{
/** Energy from BC, UE, IC2 */
Eletricity(),
/** Fluids from anything including BC pipes, DM pipes, Mek pipes */
FLUIDS(),
/** Force mainly from rotating rods */
FORCE(),
/** Hydraulic pressure from DM pipe */
PRESSURE(),
/** Item pipe */
ITEMS(),
/** Data line input */
DATA(),
/** Another tile entity */
TILE(),
/** Network of tile entities */
NETWORK(),
HEAT();
/** Thermal connection */
HEAT(),
/** Wire containing several wires of unknown color */
MULTI_WIRE(),
/** Bundle of pipes containing several colored pipes */
MULTI_PIPE(),
/** Device that contains several networks that can be of any type */
MULTI_NETWORK();
}
}

View file

@ -10,6 +10,9 @@ import net.minecraft.inventory.Container;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import universalelectricity.core.vector.Vector2;
import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -164,7 +164,7 @@ public class DarkMain extends ModPrefab
}
}
}
if (CoreRecipeLoader.itemParts instanceof ItemParts)
if (CoreRecipeLoader.itemParts != null)
{
for (Parts part : Parts.values())
{
@ -200,8 +200,8 @@ public class DarkMain extends ModPrefab
}
if (mat.shouldCreateItem(EnumOrePart.TUBE))
{
OreDictionary.registerOre(mat.simpleName + "tube", mat.getStack(EnumOrePart.TUBE, 1));
OreDictionary.registerOre("tube" + mat.simpleName, mat.getStack(EnumOrePart.TUBE, 1));
OreDictionary.registerOre(mat.getOreName(EnumOrePart.TUBE), mat.getStack(EnumOrePart.TUBE, 1));
OreDictionary.registerOre(mat.getOreNameReverse(EnumOrePart.TUBE), mat.getStack(EnumOrePart.TUBE, 1));
}
if (mat.shouldCreateItem(EnumOrePart.ROD))

View file

@ -140,12 +140,23 @@ public enum EnumMaterial
return null;
}
public static String getOreName(EnumMaterial mat, EnumOrePart part)
{
return mat.simpleName + part.simpleName;
}
public String getOreName(EnumOrePart part)
{
return this.simpleName + part.simpleName;
}
public String getOreNameReverse(EnumOrePart part)
{
return part.simpleName + this.simpleName;
}
public boolean shouldCreateItem(EnumOrePart part)
{
if (part == EnumOrePart.ROD || part == EnumOrePart.TUBE)
{
return false;
}
return this.unneedItems == null || !this.unneedItems.contains(part);
}

View file

@ -32,14 +32,14 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
/** A list of user access data. */
protected List<AccessGroup> groups = new ArrayList<AccessGroup>();
public TileEntityInv()
{
TerminalCommandRegistry.loadNewGroupSet(this);
}
@Override
public void initiate()
{
thisPos = new Vector3(this);
if (this.groups == null || this.groups.isEmpty())
{
TerminalCommandRegistry.loadNewGroupSet(this);
}
}
public Vector3 getThisPos()
@ -275,13 +275,21 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
}
@Override
public void addGroup(AccessGroup group)
public boolean addGroup(AccessGroup group)
{
if (!this.groups.contains(group))
{
this.groups.add(group);
for (AccessGroup g : this.groups)
{
if (group.name().equalsIgnoreCase(g.name()))
{
return false;
}
}
return this.groups.add(group);
}
return false;
}
@Override
public AccessGroup getOwnerGroup()

View file

@ -219,7 +219,7 @@ public abstract class TileEntityMachine extends TileEntityInv implements ISidedI
public void sendGUIPacket()
{
if (this.hasGUI && this.getContainer() != null && this.ticks % 5 == 0)
if (this.hasGUI && this.getContainer() != null)
{
this.playersUsingMachine = 0;
for (Object entity : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord - 10, yCoord - 10, zCoord - 10, xCoord + 10, yCoord + 10, zCoord + 10)))

View file

@ -0,0 +1,6 @@
package dark.core.prefab.terminal;
public class GlobalAccessManager
{
}