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,10 +30,20 @@ public class AccessGroup extends Group<AccessUser>
@Override
public boolean addMemeber(AccessUser obj)
{
if (super.addMemeber(obj))
if (obj != null)
{
obj.setGroup(this);
return true;
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;
@ -28,7 +31,7 @@ public abstract class GuiMachineContainer extends GuiContainer
public GuiMachineContainer(Object mod, Container container, InventoryPlayer inventoryPlayer, TileEntityMachine tileEntity)
{
super(container);
super(container);
this.tileEntity = tileEntity;
this.entityPlayer = inventoryPlayer.player;
this.ySize = 380 / 2;

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

@ -12,8 +12,8 @@ import cpw.mods.fml.relauncher.SideOnly;
import dark.core.common.CoreRecipeLoader;
/** Class for storing materials, there icon names, sub items to be made from them or there sub ores
*
*
*
*
* @author DarkGuardsman */
public enum EnumMaterial
{
@ -75,7 +75,7 @@ public enum EnumMaterial
/** Creates a new item stack using material and part given. Uses a preset length of 50 for parts
* enum so to prevent any unwanted changes in loading of itemStacks metadata.
*
*
* @param mat - material
* @param part - part
* @return new ItemStack created from the two enums as long as everything goes right */
@ -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

@ -21,7 +21,7 @@ import dark.core.prefab.terminal.TerminalCommandRegistry;
import dark.core.prefab.tilenetwork.NetworkTileEntities;
/** Prefab for simple object who only need basic inv support and nothing more
*
*
* @author Darkguardsman */
public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, ISidedInventory, ISpecialAccess
{
@ -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,12 +275,20 @@ 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

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
{
}