Jump to content

TheEpicTekkit

Members
  • Posts

    361
  • Joined

  • Last visited

Everything posted by TheEpicTekkit

  1. Anyway.... Yeah, I can add cool functionality with my network. And as I said before, no other mods that I know of do this. So the way I see it working, is a bit like Applied Energistics, my fuse box is like the me controller. (Okay, I just contradicted myself, apparently I can think of a mod that does something similar ) So, the player connects a wire from a network of machines they have to the fuse box, and they can all communicate with each other. So I have another problem. So the way this pathfinding library works is the pathfinder (it comes witn 4 different algorithms that I can use; A-Star, Depth First Search (DFS) Breadth First Search (BFS) and Dijkstra) the pathfinder works by a target node id (the node it will try to find a route to) and a start node (the node that it will start from). The problem is how do I assign and manage these IDs? No two machines in the world can have the same node ID, otherwise the new node ID will overwrite the old one. And, how do I make the machine that is requesting power choose a node ID that is in the same network as it is in without already having done a scan of the network (which then would be impossible as no node IDs are known).
  2. There's a page 2? Well, this is embarrassing... ...... Well, I know that now...
  3. I dont know if anyone can see this reply... but... I have no idea why this happens, if it is a glitch on the website, or intentional for some reason, and it has happened to several of my posts. After 24 replies, I cant see any after that. I can see replies after #24 in the post reply page though. But in the actual main thread, the last reply I can see is 24. So, I am going to start a new thread continuing this one. New topic: CONTINUED
  4. This is a continuation of my previous topic; Trigger a search down a line of blocks.
  5. Hmm... actually, I will do a fuse box. I guess it makes logical sense, I mean in real life, you wouldn't really have an electrical network without a fuse box, would you. It is also unique as no other mods I know of do that.
  6. Hello everyone. So, I am trying to give my block not a custom render (already done) but custom rendered block bounds. Or even just the block bounds change depending on what part of the block you look at. I am trying to achieve what Buildcraft pipes, and thermal expansions conduits do, if you look at the connected part, the bounding box is seperate. The reason I want to do this is because I want to be able to disconnect a connected part of my cable with a wrench, and I want the player to be able to see what part of the block it will effect. I am assuming that this would have to be done with getSelectedBoundingBoxFromPool(...). Thanks.
  7. So would this work? public ForgeDirection[] connections = new ForgeDirection[6]; //This is the array that stores the connected sides. //Some irrelevant code here... public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); for (int i = 0; i < connections.length; i++) { this.connections[i] = nbt.getInteger("connections_" + i); } } public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); for (int i = 0; i < connections.length; i++) { nbt.setInteger("connections_" + i, connections[i].ordinal()); } } @Override public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); this.writeToNBT(tag); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { this.readFromNBT(packet.func_148857_g()); }
  8. Hello Everyone. So I have been experiencing some lag issues with my mod, and have tracked it down to my cables constantly updating their connections and block bounds every tick (I was doing this in updateEntity()) So what I have done, is in the block class, I have changed it to update in onNeighborBlockChange(...). Now with this, when I reload the world, all the connections are gone, and each cable has to be updated. So my question is how can I write a ForgeDirection array to NBT?
  9. So, Hugo, your idea is basically to make it like a multiblock, and the fuse box is the controller? I thought of this before, but not too sure about it. TGG's idea I think is better.
  10. Okay, so I have came across an interesting problem that I didn't think of before. How do I store all the data in the network? I can't have each block store the network, because they each would have a seperate instance of the network, and this would cause problems with node ids (the nodes in the network are assigned an ID, this is what the pathfinder uses to know what node it is going from, and what node it is going to.) So how would I store the network data as one object? I cant use static fields, because there can be multiple networkes in the world at the same time, and they will most likely each be different.
  11. Maybe, if a new cable, emitter, or requester is added, and it connects to a cable in the network, that cable will be the one that realizes that the network is not up to date (can use onNeighborBlockChange(...) {...} method to detect this), and so will trigger a refresh of the network. So, what I plan to do, is have every block in the network (including the cables) remember the coordinates of all the other blocks in the network. So with this, if a cable realizes that the network is not up to date, it will notify the rest of the network. Also, maybe every so often (probably every minute, possibly every 20 seconds, depending on how much lag a refresh causes), the network automatically refreshes itself. This is because other mods mechanics such as blockbreakers may not trigger a block update for some strange reason, or maybe just a sync glitch may cause it not to realize that the network has changed.
  12. Also.... By "each route" do you mean a junction in the cable? or separate cable networks on different sides of the block? Well, I guess, either way, it will use whatever emitter it finds first. So if there is a junction, it will split at the junction, and go down each route at the same time, and use whatever it finds first. and the same with the separate network on different sides of the block.
  13. Sure. I would show you my power grid code when I have got it working. My main challenge now though is integrating this to work with the mc world. I have done a bit of research on A-Star, and when looking for a free library, I came across other people looking for a library too, and one thing I read is that pathfinding libraries are rare because they really have to be built around the environment you are using it in. So I was lucky to find the one I did, and I was even more lucky as it is built to work with 2D environments and 3D environments, and most pathfinding algorithms I have found are designed for 2D only.
  14. I have found a free pathfinding library, and it seems to be designed for 3D, which is just what I need. I haven't looked at this in detail, only a brief look.
  15. I would have thought that A-Star wouldn't have a problem with this. A path like this for example, 'c' being a cable, 'R' being a requesting machine, and 'E' being an emitter, A-Star wouldn't have a problem with, or really, shouldn't have a problem with. I could specify that all the blank spaces in this example are places that the pathfinder cant scan, so in all the 2d examples of A-Star, the blank spaces are the walls. So that means that the cables are pretty much the only path A-Star is allowed to scan. Does this make sense?
  16. What if I were to use an A-Star path finding algorithm? Something that actually has tutorials. Currently, this energy grid system has no tutorials. So with A-Star, I could restrict it to the cables. Think this will work?
  17. What if I were to use an A-Star path finding algorithm? Something that actually has tutorials. Currently, this energy grid system has no tutorials. So with A-Star, I could restrict it to the cables. Think this will work? Well... This is awkward. Wrong topic I accidently clicked on the wrong faverouts tab as I save my posts to faverouts. This was ment to be in my scanning down a line of blocks topic. Ignore this.
  18. Wow.... Thanks for this. You really spend a lot of time trying to help me get this working. I really appreciate that.
  19. also, this is my location class: package generator.net.theepictekkit.generator.common.energy; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class NodeLocation { public static int instances = 0; public int x, y, z, range; public Block block; public TileEntity tile; public World world; public NodeLocation(int x, int y, int z, Block block) { this.x = x; this.y = y; this.z = z; this.block = block; this.instances = this.instances + 1; } public NodeLocation(int x, int y, int z, TileEntity tile) { this.x = x; this.y = y; this.z = z; this.tile = tile; this.instances = this.instances + 1; } public NodeLocation(int x, int y, int z, int range) { this.x = x; this.y = y; this.z = z; this.range = range; this.instances = this.instances + 1; } public World getWorld() { return this.world; } public void setWorld(World world) { this.world = world; } public boolean hasWorld() { return this.world != null; } public int getX() { return this.x; } public int getY() { return this.y; } public int getZ() { return this.z; } public int getRange() { return this.range; } public TileEntity getTile() { return this.tile != null ? this.tile : (this.hasWorld() ? this.getWorld().getTileEntity(x, y, z) : null); } public Block getBlock() { return this.block != null ? this.block : (this.hasWorld() ? this.getWorld().getBlock(x, y, z) : null); } @Override public String toString() { if (block != null && tile == null) { return "X:" + x + "Y:" + y + "Z:" + z + "_" + block.getUnlocalizedName() + "_" + this.instances; } if (tile != null && block == null) { return "X:" + x + "Y:" + y + "Z:" + z + "_" + tile.getWorldObj().getBlock(x, y, z).getUnlocalizedName() + "_" + this.instances; } return "X: " + x + "Y: " + y + "Z: " + z + "_null_" + this.instances; } }
  20. Okay, so you're saying that I shouldn't be making the cables do the work, I should be making the machine requesting do all the work? Also, I am looking at buildcrafts source, and I am looking for the way they handle their power net. Any help on locating this method? (Currently looking at: this) Also, another interesting thing I found on github is this from steves factory manager. I am looking at the updateInventories method.
  21. Okay, I think that the most flexible option would to make a cable scan the six blocks around it, and if one is a cable, trigger a search from that cable, and in my logic, that will go down the path of cables, but also, there are some problems. First, if a cable (cable 1) scans all six sides around it, and finds another cable (cable 2) and triggers a search from that cable, cable 2 would find cable 1 again, and then cable 1 would find cable 2, and they would be stuck in a loop of finding each other, and undoubtedly this would cause a lot of lag. So I would need a way to mark a cable as scanned. Secondly, if the cables find an energy emitter that can supply the machine, how will they send the location of the emitter to the machine, because the way I want to do it, is the machine just has the coordinates of the emitter, and pretty much teleports the power over. Thirdly, how would I make it detect if a block has been removed, or added to the network? because if the cable finds an emitter, and the machine knows the location of it, and is drawing power from it, if the player removes it during this process, it would crash the game with a NullPointerException, or a ClassCastException because the machine is doing something to a block that doesn't exist. Bye the way, by emitter, I mean a machine that can output power, not just generators that produce power.
  22. The thing is though; redstone can only travel 15 blocks, I want my energy to be able to travel about 60 blocks. I do want a limit for two reasons; one, to reduce lag, not that there will be much, but it'll help. Two, I want this to be the maximum, other cables will have a lesser range. The problem with this though, I cant have more than 16 metadata sub blocks. The cables updating themselves is what I have already been trying, but without success.
  23. Hello everyone. So, I am working on a cable, and I have all but finding power emitters working. So what I need to do, is if a machine is requesting power, it will search for a cable on any of its six sides, if it finds one, one of three things (I am not sure which would be best) would happen. One, the only thing the block does is trigger a search on the cable, and from there the cable scans down any other cables connected, remembering the location of the requesting block, and passing it to each cable, then if the cable locates a power emitter, will send its location back to the requesting block, and then the requesting block draws power from the emitter. Two, the cables act as a guide for the requesting block, and a graphical connection for the player. What I mean by guide is the requesting block does all the searching, and the cables are what it follows. So first it will scan for cables immediately adjacent to it, then if it finds one, will search for cables immediately adjacent to that cable, and if it finds a cable immediately adjacent to that one, it will scan for cables around it, etc, until it finds an energy emitter. If the requesting machine finds a cable with more than one cable attached to it, it will scan around all of them (same for if it finds more that one cable directly adjacent to it) and will choose the energy emitter that it finds first. Three, there is no scanning being done, each cable has an internal buffer of power, and it just passes that power onto the next cable. (I really dont want to do this one, but if it comes to it, I will. This method doesn't seem very flexible with what I can do with the energy) Currently I have been working on the first option, but it is proving more difficult than I expected. Either, the cable doesnt actually scan down the line, and can only detect blocks directly attached to the cable, or I get a stackOverflowError because the cable searches, finds a cable adjacent, triggers a method in the tileentity of the found cable that then restarts the method that found that cable in the first place, thus getting stuck in a loop, and crashing. So, my question is which one of these methods would be the best choice? and how would I go about doing the best method? Thanks for the help.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.