this and that
This commit is contained in:
parent
517a5a506d
commit
8fb5813807
10 changed files with 113 additions and 29 deletions
25
src/dark/api/access/AccessCollection.java
Normal file
25
src/dark/api/access/AccessCollection.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,11 +30,21 @@ public class AccessGroup extends Group<AccessUser>
|
||||||
@Override
|
@Override
|
||||||
public boolean addMemeber(AccessUser obj)
|
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))
|
if (super.addMemeber(obj))
|
||||||
{
|
{
|
||||||
obj.setGroup(this);
|
obj.setGroup(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,14 +74,14 @@ public class AccessGroup extends Group<AccessUser>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nbt.setTag("Users", usersTag);
|
nbt.setTag("Users", usersTag);
|
||||||
usersTag = new NBTTagList();
|
NBTTagList nodesTag = new NBTTagList();
|
||||||
for (String str : this.nodes)
|
for (String str : this.nodes)
|
||||||
{
|
{
|
||||||
NBTTagCompound accessData = new NBTTagCompound();
|
NBTTagCompound accessData = new NBTTagCompound();
|
||||||
accessData.setString("name", str);
|
accessData.setString("name", str);
|
||||||
usersTag.appendTag(accessData);
|
nodesTag.appendTag(accessData);
|
||||||
}
|
}
|
||||||
nbt.setTag("nodes", usersTag);
|
nbt.setTag("nodes", nodesTag);
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ public interface ISpecialAccess
|
||||||
/** Get all groups linked this */
|
/** Get all groups linked this */
|
||||||
public List<AccessGroup> getGroups();
|
public List<AccessGroup> getGroups();
|
||||||
|
|
||||||
/** Add a group to the group list */
|
/** Add a group to the group list
|
||||||
public void addGroup(AccessGroup group);
|
* @return */
|
||||||
|
public boolean addGroup(AccessGroup group);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,41 @@ package dark.api.parts;
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
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
|
public interface ITileConnector
|
||||||
{
|
{
|
||||||
/** Can this tile connect on the given side */
|
/** Can this tile connect on the given side */
|
||||||
public boolean canTileConnect(Connection type, ForgeDirection dir);
|
public boolean canTileConnect(Connection type, ForgeDirection dir);
|
||||||
|
|
||||||
|
/** Types of connections */
|
||||||
public static enum Connection
|
public static enum Connection
|
||||||
{
|
{
|
||||||
|
/** Energy from BC, UE, IC2 */
|
||||||
Eletricity(),
|
Eletricity(),
|
||||||
|
/** Fluids from anything including BC pipes, DM pipes, Mek pipes */
|
||||||
FLUIDS(),
|
FLUIDS(),
|
||||||
|
/** Force mainly from rotating rods */
|
||||||
FORCE(),
|
FORCE(),
|
||||||
|
/** Hydraulic pressure from DM pipe */
|
||||||
PRESSURE(),
|
PRESSURE(),
|
||||||
|
/** Item pipe */
|
||||||
ITEMS(),
|
ITEMS(),
|
||||||
|
/** Data line input */
|
||||||
DATA(),
|
DATA(),
|
||||||
|
/** Another tile entity */
|
||||||
TILE(),
|
TILE(),
|
||||||
|
/** Network of tile entities */
|
||||||
NETWORK(),
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@ import net.minecraft.inventory.Container;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.opengl.GL12;
|
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.client.FMLClientHandler;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
|
@ -164,7 +164,7 @@ public class DarkMain extends ModPrefab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CoreRecipeLoader.itemParts instanceof ItemParts)
|
if (CoreRecipeLoader.itemParts != null)
|
||||||
{
|
{
|
||||||
for (Parts part : Parts.values())
|
for (Parts part : Parts.values())
|
||||||
{
|
{
|
||||||
|
@ -200,8 +200,8 @@ public class DarkMain extends ModPrefab
|
||||||
}
|
}
|
||||||
if (mat.shouldCreateItem(EnumOrePart.TUBE))
|
if (mat.shouldCreateItem(EnumOrePart.TUBE))
|
||||||
{
|
{
|
||||||
OreDictionary.registerOre(mat.simpleName + "tube", mat.getStack(EnumOrePart.TUBE, 1));
|
OreDictionary.registerOre(mat.getOreName(EnumOrePart.TUBE), mat.getStack(EnumOrePart.TUBE, 1));
|
||||||
OreDictionary.registerOre("tube" + mat.simpleName, mat.getStack(EnumOrePart.TUBE, 1));
|
OreDictionary.registerOre(mat.getOreNameReverse(EnumOrePart.TUBE), mat.getStack(EnumOrePart.TUBE, 1));
|
||||||
|
|
||||||
}
|
}
|
||||||
if (mat.shouldCreateItem(EnumOrePart.ROD))
|
if (mat.shouldCreateItem(EnumOrePart.ROD))
|
||||||
|
|
|
@ -140,12 +140,23 @@ public enum EnumMaterial
|
||||||
return null;
|
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)
|
public boolean shouldCreateItem(EnumOrePart part)
|
||||||
{
|
{
|
||||||
if (part == EnumOrePart.ROD || part == EnumOrePart.TUBE)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return this.unneedItems == null || !this.unneedItems.contains(part);
|
return this.unneedItems == null || !this.unneedItems.contains(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,14 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
|
||||||
/** A list of user access data. */
|
/** A list of user access data. */
|
||||||
protected List<AccessGroup> groups = new ArrayList<AccessGroup>();
|
protected List<AccessGroup> groups = new ArrayList<AccessGroup>();
|
||||||
|
|
||||||
public TileEntityInv()
|
@Override
|
||||||
{
|
|
||||||
TerminalCommandRegistry.loadNewGroupSet(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initiate()
|
public void initiate()
|
||||||
{
|
{
|
||||||
thisPos = new Vector3(this);
|
thisPos = new Vector3(this);
|
||||||
|
if (this.groups == null || this.groups.isEmpty())
|
||||||
|
{
|
||||||
|
TerminalCommandRegistry.loadNewGroupSet(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 getThisPos()
|
public Vector3 getThisPos()
|
||||||
|
@ -275,13 +275,21 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addGroup(AccessGroup group)
|
public boolean addGroup(AccessGroup group)
|
||||||
{
|
{
|
||||||
if (!this.groups.contains(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
|
@Override
|
||||||
public AccessGroup getOwnerGroup()
|
public AccessGroup getOwnerGroup()
|
||||||
|
|
|
@ -219,7 +219,7 @@ public abstract class TileEntityMachine extends TileEntityInv implements ISidedI
|
||||||
|
|
||||||
public void sendGUIPacket()
|
public void sendGUIPacket()
|
||||||
{
|
{
|
||||||
if (this.hasGUI && this.getContainer() != null && this.ticks % 5 == 0)
|
if (this.hasGUI && this.getContainer() != null)
|
||||||
{
|
{
|
||||||
this.playersUsingMachine = 0;
|
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)))
|
for (Object entity : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord - 10, yCoord - 10, zCoord - 10, xCoord + 10, yCoord + 10, zCoord + 10)))
|
||||||
|
|
6
src/dark/core/prefab/terminal/GlobalAccessManager.java
Normal file
6
src/dark/core/prefab/terminal/GlobalAccessManager.java
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
package dark.core.prefab.terminal;
|
||||||
|
|
||||||
|
public class GlobalAccessManager
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue