How to create a machine

  • Hey guys,


    for my mod unidye I plan on creating a machine to dye wool at a better ratio than vanilla. I have the block class and the base of a TileEntity class (using IC2 API's recommended BasicSink methods), blocks and tileentities are registered in my main class. Now how do I make it "work"? I know that's kind of a dumb question, but I don't really have a point to start. I know I will have to do checks for enough energy for the operation etc. with a couple of IC2 methods (Agkz has a tutorial on that) but how can I add a recipe or input items? Do I need a GUI for that or could it work without one?


    Block class, TileEntity class


    I could simply extend greg's tile entities or something, but I'd much rather really understand how it works and not be GT-dependant since it should run on vanilla IC2 as well.


    Hope that's not too much of a noobish question.

  • I don't do Java, but won't it be simpler to just open IC2 in JD-GUI if you're not going to edit IC2's source?

  • I decompiled it for some inspiration and now have a dummy gui that only accepts items, as well as a tileentity that stores energy but doesn't use it for anything and cannot output it.
    Now, when the chunk unloads and you go back to the placed machine, something pops up in the console:


    [Warnung] [IC2] EnergyNet.addTileEntity: phnxflms.unidye.TileEntityWoolDyer@6bbe8ba2 (phnxflms.unidye.TileEntityWoolDyer@6bbe8ba2) is conflicting with phnxflms.unidye.TileEntityWoolDyer@67530ea1 using the same position (already added, prev. te not removed, overlapping), aborting


    I am guessing I overlooked a method I should implement. This problem is only in the console, the stored items are still there and I can take them out without any problem..Before I work on actually making the GUI do stuff I would like to fix that bug before I run into more issues.

  • That seems to be terrible, because same problem have Nuc.Control and other addons for IC2 ;)

    public void getForumUserData(Signature signature, User user) { if(user.equalsTo("Cass") && user.isOnline() { Forum.Out.println("signature")})return;}

  • Well if I am not the only one..The weird thing is, everything works, just that warning pops up and makes you paranoid.


    Edit: Okay, second weird thing, this time really a problem.


    [Warnung] [IC2] EnergyTileUnloadEvent: posted for phnxflms.unidye.TileEntityWoolDyer@660ba0e5 client-side, aborting
    [Warnung] [IC2] EnergyNet.addTileEntity: phnxflms.unidye.TileEntityWoolDyer@1c29bc9e (phnxflms.unidye.TileEntityWoolDyer@1c29bc9e) is conflicting with phnxflms.unidye.TileEntityWoolDyer@781e3783 using the same position (already added, prev. te not removed, overlapping), aborting


    That happens when destroying a woolDyer block and then putting a new one on the same spot.


  • And is your event for wrench coded properly?

    public void getForumUserData(Signature signature, User user) { if(user.equalsTo("Cass") && user.isOnline() { Forum.Out.println("signature")})return;}

  • I don't think that's the issue, it's something to do with TileEntities not properly being saved or deleted when the chunk unloads.. and wrenching shouldn't interfere with that (at the moment you can use a pickaxe or the creative punch)

  • You should extend to basic sink in the api folder to make your life easier. It extends to tile entity and implements IEnergySink. It also has all of the functions you need built right in. Hmmm... Strange.... I don't have the same problem as you.... Wonder why that is?...

  • Well I guess the save bugs then are just from using an older method, will try basicsink..Oh! I should test my block without my dummy GUI in it..will do so in the afternoon!

  • Well, after all what I code ( isn't too much ), I can say then adding EU powered block is harder then code your proxies, base file and create oreWorldGen :D

    public void getForumUserData(Signature signature, User user) { if(user.equalsTo("Cass") && user.isOnline() { Forum.Out.println("signature")})return;}

  • Actually I using it for custom packages send like keyboard keys. But, actually, nothing usefull, because i plan to remove it for bugs which Im unable to resolve.


    Now I'm focusing on TileEntity render because I want use model instead of basic block. This seems to look like "hard-to-resolve" thing :D


    Also, look to me little bit harder make config file which make sense by it S: and I:, because idk if I will use Strings later for max. numbers of somethin' or not :(



    btw. how's goin' with your Wool Dyer? :) Problems resolved? :)

    public void getForumUserData(Signature signature, User user) { if(user.equalsTo("Cass") && user.isOnline() { Forum.Out.println("signature")})return;}

  • Sometime help start from nothing :) Like another shape of view to things :)


    bt. I see you join to TransofrmerConvertors too. :)


    I'm walking around mind then it need less packages :D

    public void getForumUserData(Signature signature, User user) { if(user.equalsTo("Cass") && user.isOnline() { Forum.Out.println("signature")})return;}

  • Now it gets too philosophical for me :D Either way, I will just play around with it once I have the time.


    EDIT: Now everything works, except for it blowing up when the input is too high. Do you need to implement that function yourself or will it be added when you start adding recipes and stuff to do for the machine itself?

  • Now it gets too philosophical for me :D Either way, I will just play around with it once I have the time.


    EDIT: Now everything works, except for it blowing up when the input is too high. Do you need to implement that function yourself or will it be added when you start adding recipes and stuff to do for the machine itself?


    You need to add that in yourself if I remember correctly... Also, if your machine dyes wool, it should implement IInventory. Just a heads up for you.

  • Okay, I got the GUI working except one (or two) things. (Ignore the Tank and liquid slots.)



    My machine is for dyeing wool and has two input slots: One for dyes, one for wool. There is also a variable in the TileEntity called "woolCount" - wool from the input slot are supposed to disappear and raise "woolCount" (up to a number of 8 ), this is not implemented currently but I ran into a problem before even beginning to do that:


    I have a dummy method for displaying woolCount in Chat when rightclicking the machine. When sneaking while doing so, woolCount is raised by 1. Now how can I make the GUI draw the actual value of woolCount instead of just the default value (0)?
    Since it shouldn't matter which colour the wool has and you need at least 4 wool to begin dyeing, I thought the woolCount would be a good workaround. (The conventional way, putting Wool into the input slot and then dyeing wouldn't work, if you have e.g. 1 red, 2 blue and 1 green wool but want to dye all 4 of them.)
    So how can I make the GUI display changing variables?


    Here is some of my code:


    GuiWoolDyer
    TileEntityWoolDyer
    BlockWoolDyer