From 8fb5813807cee8532af9988cf84bfbd0994a42cb Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Mon, 25 Nov 2013 09:59:47 -0500 Subject: [PATCH] this and that --- src/dark/api/access/AccessCollection.java | 25 +++++++++++++++++++ src/dark/api/access/AccessGroup.java | 22 +++++++++++----- src/dark/api/access/ISpecialAccess.java | 5 ++-- src/dark/api/parts/ITileConnector.java | 22 +++++++++++++++- .../core/client/gui/GuiMachineContainer.java | 5 +++- src/dark/core/common/DarkMain.java | 6 ++--- src/dark/core/common/items/EnumMaterial.java | 25 +++++++++++++------ .../core/prefab/machine/TileEntityInv.java | 24 ++++++++++++------ .../prefab/machine/TileEntityMachine.java | 2 +- .../prefab/terminal/GlobalAccessManager.java | 6 +++++ 10 files changed, 113 insertions(+), 29 deletions(-) create mode 100644 src/dark/api/access/AccessCollection.java create mode 100644 src/dark/core/prefab/terminal/GlobalAccessManager.java diff --git a/src/dark/api/access/AccessCollection.java b/src/dark/api/access/AccessCollection.java new file mode 100644 index 00000000..e408e4ad --- /dev/null +++ b/src/dark/api/access/AccessCollection.java @@ -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; + } +} diff --git a/src/dark/api/access/AccessGroup.java b/src/dark/api/access/AccessGroup.java index f84d00bd..7403b641 100644 --- a/src/dark/api/access/AccessGroup.java +++ b/src/dark/api/access/AccessGroup.java @@ -30,10 +30,20 @@ public class AccessGroup extends Group @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 } } 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; } diff --git a/src/dark/api/access/ISpecialAccess.java b/src/dark/api/access/ISpecialAccess.java index 3c9d3083..88995725 100644 --- a/src/dark/api/access/ISpecialAccess.java +++ b/src/dark/api/access/ISpecialAccess.java @@ -31,7 +31,8 @@ public interface ISpecialAccess /** Get all groups linked this */ public List 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); } diff --git a/src/dark/api/parts/ITileConnector.java b/src/dark/api/parts/ITileConnector.java index 5aac4eff..1edd0c9d 100644 --- a/src/dark/api/parts/ITileConnector.java +++ b/src/dark/api/parts/ITileConnector.java @@ -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(); } } diff --git a/src/dark/core/client/gui/GuiMachineContainer.java b/src/dark/core/client/gui/GuiMachineContainer.java index 85aa7c0d..8d309404 100644 --- a/src/dark/core/client/gui/GuiMachineContainer.java +++ b/src/dark/core/client/gui/GuiMachineContainer.java @@ -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; diff --git a/src/dark/core/common/DarkMain.java b/src/dark/core/common/DarkMain.java index 137a65c4..0b5366cd 100644 --- a/src/dark/core/common/DarkMain.java +++ b/src/dark/core/common/DarkMain.java @@ -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)) diff --git a/src/dark/core/common/items/EnumMaterial.java b/src/dark/core/common/items/EnumMaterial.java index 6bc203ee..390f1a35 100644 --- a/src/dark/core/common/items/EnumMaterial.java +++ b/src/dark/core/common/items/EnumMaterial.java @@ -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); } diff --git a/src/dark/core/prefab/machine/TileEntityInv.java b/src/dark/core/prefab/machine/TileEntityInv.java index 2be1d728..22fbef95 100644 --- a/src/dark/core/prefab/machine/TileEntityInv.java +++ b/src/dark/core/prefab/machine/TileEntityInv.java @@ -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 groups = new ArrayList(); - 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 diff --git a/src/dark/core/prefab/machine/TileEntityMachine.java b/src/dark/core/prefab/machine/TileEntityMachine.java index 3caf6375..0a08c878 100644 --- a/src/dark/core/prefab/machine/TileEntityMachine.java +++ b/src/dark/core/prefab/machine/TileEntityMachine.java @@ -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))) diff --git a/src/dark/core/prefab/terminal/GlobalAccessManager.java b/src/dark/core/prefab/terminal/GlobalAccessManager.java new file mode 100644 index 00000000..959153dc --- /dev/null +++ b/src/dark/core/prefab/terminal/GlobalAccessManager.java @@ -0,0 +1,6 @@ +package dark.core.prefab.terminal; + +public class GlobalAccessManager +{ + +}