Jump to content

TheEpicTekkit

Members
  • Posts

    361
  • Joined

  • Last visited

Everything posted by TheEpicTekkit

  1. Okay, so I have got my network to a point where it can find all nodes connected (I have tested this by making it so that when it finds a node, it sets it to stone.) Now how do I make it so that it can detect when the player removes a node? And of course, by node, I mean a block that can receive, or send energy.
  2. Oh, I just found something useful in looking for open source mods on github that do the same thing I am trying to achieve, I had a look at steves factory manager, (modjam mod) for the way vswe made the inventory cables. This is what I have found. https://github.com/Vswe/ModJam3/blob/master/src/main/java/vswe/stevesfactory/blocks/BlockCable.java
  3. Okay, I have wrote this method in the EnergyNetwork class: This method gets called from the tileentity as so: So this is designed to scan down the cable, and if it finds a tileentity that implements IEnergyHandler, it will add it to the list of nodes. Now I have noticed that the x, y, z parameters in the "tileCable.triggerSearch(x, y, z); are redundant, they arent used, because from the tileentity, it uses xCoord, yCoord zCoord instead of x, y, z. So just ignore those parameters, because I have changed it to triggerSearch();
  4. What happens if I have multiple power sources each with energy available? should it just drain the nearest one? say for example I have two blocks that can emit power, and both have power available, ideally I would like it to drain equally from both, and not just from one, so if a machine is requesting 32 Watts/t (my energy) the two blocks that can give power will each send 16 watts/t
  5. jabelar, thanks, I'll have a look into that tomorrow though, as I have to go now unfortunately (I am an hour and a half ahead of the time it says the reply was posted.) and this is what I have so far: Think I am on the right tracks now? defiantly way better than the other class I posted.
  6. Okay, two questions, one, how would I go about the shortest route calculator? I have found this. would this code work? two, the main bit I am getting stuck on is scanning down the line of cables. That is what I was trying to do in the code I posted above. but apparently... it is really bad. ps: diesieben07, I am new to ArrarLists, and this is what my code looks like when I am trying to learn something new, It is really bad, and generally doesnt work, I search on google for answers, and if nothing ask for help, and then learn what I have done wrong, and improve.
  7. woops... I have already noticed one mistake; I have fixed it by changing: if ((!nodeXpos.contains(x)) && (!nodeYpos.contains(y)) && (!nodeZpos.contains(z))) { networkNodes.add(tile); nodeXpos.add(x); nodeYpos.add(y); nodeZpos.add(z); } to: if ((!nodeXpos.contains(x))) { nodeXpos.add(x); } if ((!nodeXpos.contains(y))) { nodeXpos.add(z); } if ((!nodeXpos.contains(z))) { nodeXpos.add(z); }
  8. I have made a class called Network, and this is it so far: Now I am not sure if I am missing anything here, I do know that I dont have, and need to have a way to check if a block has been removed from the network, but this is my basic idea on how to do this, also, I am not sure how I could do that. Any suggestions on what I need to add, remove or change?
  9. Okay, what sort of list should I use to store the nodes (anything that can accept or send power that isn't a cable) Should I use a LinkedList, or an ArrayList? Or should I even use a HashMap? Also, how do I store the x, y and z coords in the list or map without having 3 seperate lists for each?
  10. Okay, thanks very much, this was very helpful, very detailed to. I'll update here how this goes, but that'll wait till tomorrow, as I am off to bed. Thanks.
  11. Okay, thanks for your help. I understand, I guess I should have worded it a bit differently, I wasn't asking for someone to give me the code, I was asking for advice on how to do this. I am not sure where to even start with this. But I guess I can also look on github at mods like mekanism or buildcraft to see how they do it. Thanks anyway.
  12. But I want the cable to send packets to a block that is requesting power, So i dont want the cables to have buffers, and the second idea seems really complicated, and not very practical. By packets I dont mean that the cable actually stores energy, and passes energy onto the next cable, I mean that the cable mearly acts as a graphical connection, and the only physical thing it does it "network" the blocks connected to it. By network, I mean that it allows the blocks connected to the cable to talk to each other, and they pretty much teleport the power to each other. And the block sending can also calculate the distance the receiving block is, and from that, can deduct a certain amount of power, as if there is some energy loss in the cables. So I would like to know How I could set up this network. Sorry, I probably should have been more specific as to what I wanted to do in my main post, Im also sorry for replying late.
  13. Hi everyone. Okay, this time, I have been working on cables for my mod, I have them connecting, the block bounds updating, them rendering the connections, but, now I would like to know how to make them send packets of energy down the line. I don't even know where to start with this. I want it to send packets of power if it finds a place to take it from, a place to put it, and if the place to put it has a block that is requesting power. Any help? Thanks.
  14. I would also like to know how to make the ItemBlock in the players inventory render the front icon, at the moment, it just renders the blockIcon icon on all sides, and in the players hand, it renders whatever face the player is mousing over.
  15. Okay. Update on my block; I Have moved the methods in the block class to the tileentity, as this class supports all my machines, I also have a tileentity that all my machines tileentitys extend, so I have moved them all to there, I have also moved the updateBlockState method to the tileentity too.
  16. Also, unrelated, but I have a question that I have been curious about for a while, what is the "private static final String __OBFID = "CL_000SomeNumberHere";" that I see in many vanilla classes?
  17. Ohh, ok, now I understand, I was thinking that because when you register the block you register it as a new block, it creates a new instance for each... ok, i get it now.
  18. Also, aren't things only shared between all instances of a class if the variable has a static modifier?
  19. So out of the variables I have in the block, which ones should I store in the tile? I know things like the modid I wouldn't, but what about things like the MachineType type variable? MachineType is an enum to store what machine this class belongs to (not needed yet, but will be useful when I have multiple machines sharing this class).
  20. Okay then... what about the vanilla furnace though? variables like these were stored in the block, not the tile... im confused now
  21. The thing is though, I really dont know where the problem is at all, so I will post my whole class (bare in mind, this class is designed to support all of my machines, it isnt just for this machine, but atm I only have this machine, I have no others) Also, I have alot of custom methods. and it is a long class (about 300 lined) UPDATE: Sorry, but I forgot to include the tileentity(s). Warning; Also messy.
  22. Okay, so the texture does now update, but with weird consequences... And this is weird because I have no static fields or methods anywhere in my tile or block. So what is happening is well, when one machine in the world is off, and another is placed, it is fine, but if a second machine is placed with the first one on, it rotates to face the direction of the first block, and both of them update to the off texture. also when I mouse over the block in the world, the texture on the block in my hand changes to the one I am looking at. Now the way I am rotating my block is just reordering the textures on the faces depending on what angle the player is at relative to the block when placed. This is actually the only way (I know of) to do this, because I dont think that the block can actually physically rotate. Any help on this?
  23. Okay, so I have updated my getIcon method to this: public IIcon getIcon(int side, int meta) { if (side == 0 || side == 1) { if (side == 0) return this.sideBottom; if (side == 1) return this.sideTop; } else { if (meta == 0 || meta == 1) { if (this.isActive) return side == 2 ? this.sideFrontOn : this.blockIcon; else return side == 2 ? this.sideFrontOff : this.blockIcon; } if (meta == 2 || meta == 3) { if (this.isActive) return side == 5 ? this.sideFrontOn : this.blockIcon; else return side == 5 ? this.sideFrontOff : this.blockIcon; } if (meta == 4 || meta == 5) { if (this.isActive) return side == 3 ? this.sideFrontOn : this.blockIcon; else return side == 3 ? this.sideFrontOff : this.blockIcon; } if (meta == 6 || meta == 7) { if (this.isActive) return side == 4 ? this.sideFrontOn : this.blockIcon; else return side == 4 ? this.sideFrontOff : this.blockIcon; } } return blockIcon; } just a note; I have 8 metadata values, 0, 2, 4, and 6 being the rotational values while off, and 1, 3, 5, and 7 being the rotational values while on. So to turn the machine on, one is added to the metadata. Should this work? I am loading my game now to find out, but it takes a while to load as I have several other mods installed.
×
×
  • Create New...

Important Information

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