PC [Project] Mechmod - A T-MEC community mod

So is mechmod still alive and well? I've been out of the loop for half a year, and now with 1.3.4 just being released, perhaps I'll get back to Terraria engineering :).

Uhm, sadly, no.
@five--three seems to be gone
@someOthePeople aren't around either to help with coding
@stefnotch (me) is rather busy with school and some coding projects.

Also, Terraria's constant updates make it a bit hard to keep to mod up to date.
(I can't decompile Terraria, because my laptop isn't up to the task. It always decides that it doesn't have enough RAM and crashes.)
 
Not what I expected, (I expected a mod that was mechanical) but will be use full when I make contraptions.
 
@stefnotch, given the challenges of keep this up to date, is there any chance you would release the source under a license that allows reuse such as MIT, so that we could reuse some of the magic in other places? I'm specifically interested in the dummy ghost visibility toggle, but other parts are also rather cool, and knowing how they were done would certainly be interesting if not directly useful.
 
@stefnotch, given the challenges of keep this up to date, is there any chance you would release the source under a license that allows reuse such as MIT, so that we could reuse some of the magic in other places? I'm specifically interested in the dummy ghost visibility toggle, but other parts are also rather cool, and knowing how they were done would certainly be interesting if not directly useful.
Oh, yeah, the source is on a private gitlab repository. I'm willing to provide the source and @five--three probably also is willing to release it.
@five--three Can you confirm this?

So, about making the source public, I am not sure what the Terraria devs think about this. Who should I ping/ask? And, can/should I release everything or only the relevant/changed files? (Or should I release .patch files?)


Here is a public but rather outdated version of Mechmod: https://gitlab.com/mechmod/MechmodPublic


And here is @five--three 's dummy ghost drawing magic:

Code:
public static void drawDummyGhosts()
        {
            if (!showDummyGhosts)
                return;

            foreach (TileEntity tentity in TETrainingDummy.ByID.Values) //All the dummies.
            {

                TETrainingDummy dummy = null;
                try
                {
                    if (tentity is TETrainingDummy)
                        dummy = (TETrainingDummy)tentity;
                    else
                        continue;
                }
                catch { }
                if (dummy != null)
                {
                    try
                    {
                        if (Main.npc[dummy.npc].active)
                        {
                            Vector2 offset = new Vector2(0, 0);
                            SpriteEffects flip;
                            if (Main.tile[dummy.Position.X, dummy.Position.Y].frameX == 0)
                            {
                                flip = SpriteEffects.None;
                            }
                            else
                            {
                                flip = SpriteEffects.FlipHorizontally;
                            }
                            Vector2 flooredPos = Main.npc[dummy.npc].position.Floor();

                            Rectangle sourceRect = new Rectangle(0, 0, 36, 72); //frameX
                            sourceRect.X += (Main.dummyAnimationCounter / Main.dummyAnimationTime) * 38;
                            sourceRect.Y += Main.npc[dummy.npc].frame.Y * 74/50;
                           

                            /*get light color of npc pos*/
                            Color dummyColor = Main.buffColor( (Main.dummyGhostBright ?  Color.White : Lighting.GetColor((int)flooredPos.X / 16, (int)flooredPos.Y / 16)) , Main.dummyGhostBrightness, Main.dummyGhostBrightness, Main.dummyGhostBrightness, Main.dummyGhostBrightness);
                            /*draw ghost texture*/
                            Main.spriteBatch.Draw(Main.dummyGhostTexture, (flooredPos - Main.screenPosition - new Vector2(8, 8)) + offset, sourceRect, dummyColor, 0f, default(Vector2), 1f, flip, 0f);
                            /*draw outline*/
                            if(Main.dummyGhostOutline)
                            {
                                Rectangle sourceRect2 = new Rectangle(304, 0, 35, 50);
                                Main.spriteBatch.Draw(Main.dummyGhostTexture, flooredPos - Main.screenPosition - offset - new Vector2(5, 5), sourceRect2, Color.White);
                            }
                            /*draw ID*/
                            if (showDummyID)
                            {
                                Vector2 position = flooredPos - Main.screenPosition - new Vector2(8, 8);
                                string id = (dummy.npc - 100).ToString();
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position + new Vector2(-1, 0), Color.Black);
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position + new Vector2(1, 0), Color.Black);
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position + new Vector2(0, -1), Color.Black);
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position + new Vector2(0, 1), Color.Black);
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position, dummyColor);
                            }
                            /*else
                            {
                                Vector2 position = flooredPos - Main.screenPosition - new Vector2(8, 8);
                                string id = Main.tile[dummy.Position.X, dummy.Position.Y].frameX.ToString() + "," + Main.tile[dummy.Position.X, dummy.Position.Y].frameY.ToString() + "\n" + Main.npc[dummy.npc].frame.ToString();
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position + new Vector2(-1, 0), Color.Black);
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position + new Vector2(1, 0), Color.Black);
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position + new Vector2(0, -1), Color.Black);
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position + new Vector2(0, 1), Color.Black);
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position, dummyColor);
                            }*/
                            /*tile pos*/
                            Rectangle rect = new Rectangle(dummy.Position.X*16, dummy.Position.Y*16, 0, 0);
                            rect.Inflate(128, 128);
                            /* if the npc is 4 tiles away*/
                            if (!Main.npc[dummy.npc].getRect().Intersects(rect)) //!intersects?
                            {
                                /*draw ID on tile loc*/
                                Vector2 position = new Vector2(dummy.Position.X, dummy.Position.Y) * 16 - Main.screenPosition;
                                string id = (dummy.npc - 100).ToString();
                                Color lightTile = Main.buffColor((Main.dummyGhostBright ? Color.White : Lighting.GetColor((int)dummy.Position.X, (int)dummy.Position.Y)), Main.dummyGhostBrightness, Main.dummyGhostBrightness, Main.dummyGhostBrightness, Main.dummyGhostBrightness);
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position + new Vector2(-1, 0), Color.Black);
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position + new Vector2(1, 0), Color.Black);
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position + new Vector2(0, -1), Color.Black);
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position + new Vector2(0, 1), Color.Black);
                                Main.spriteBatch.DrawString(Main.fontItemStack, id, position, lightTile);

                            }
                        }
                    }

                    catch {    }

                }
            }

            foreach (SpritebatchQueue gonnaDraw in SpritebatchQueue.queue)
            {
                if (gonnaDraw.type == "texture")
                {
                    Main.spriteBatch.Draw(gonnaDraw.t, gonnaDraw.v, gonnaDraw.c);
                }
                else if (gonnaDraw.type == "string")
                {
                    Main.spriteBatch.DrawString(gonnaDraw.s, gonnaDraw.x, gonnaDraw.v, gonnaDraw.c);
                }
            }
            SpritebatchQueue.queue.Clear();


            //YES. DONE.

        }
 
Last edited:
Oh, yeah, the source is on a private gitlab repository. I'm willing to provide the source and @five--three probably also is willing to release it.
@five--three Can you confirm this?

So, about making the source public, I am not sure what the Terraria devs think about this. Who should I ping/ask? And, can/should I release everything or only the relevant/changed files? (Or should I release .patch files?)

Just the patch files; they would strongly prefer the decompiled source is not available. That is going to be pretty awkward for people to directly pick up and use, but it's the least worst choice here. It'll at least be clear what is going on in the added code and all, and we can map the context manually.

"Just release patches", incidentally, is how tModLoader does their source release, so it's blessed enough by the devs. :)

PS: please don't forget to include an appropriate LICENSE file in the source release, if you don't mind, covering your patches. Without one, at least I won't touch the code because while your intent is clear, I'm paranoid about licensing stuff. :)

PPS: clever way to draw those ghosts!
 
Just the patch files; they would strongly prefer the decompiled source is not available. That is going to be pretty awkward for people to directly pick up and use, but it's the least worst choice here. It'll at least be clear what is going on in the added code and all, and we can map the context manually.

"Just release patches", incidentally, is how tModLoader does their source release, so it's blessed enough by the devs. :)

PS: please don't forget to include an appropriate LICENSE file in the source release, if you don't mind, covering your patches. Without one, at least I won't touch the code because while your intent is clear, I'm paranoid about licensing stuff. :)

PPS: clever way to draw those ghosts!


Ok! (Oh, yay, I get to fight with git again! Maintaining the .patch/public repository was something that @five--three did. Though, I have no clue where he went since last summer.)

I just checked, the .patch repository has an MIT license https://gitlab.com/mechmod/MechmodPublic/blob/master/LICENSE :D
(And, being paranoid about license stuff isn't a bad idea)


If you want, I can add you to the private repository.
 
Ok! (Oh, yay, I get to fight with git again! Maintaining the .patch/public repository was something that @five--three did. Though, I have no clue where he went since last summer.)

I just checked, the .patch repository has an MIT license https://gitlab.com/mechmod/MechmodPublic/blob/master/LICENSE :D
(And, being paranoid about license stuff isn't a bad idea)


If you want, I can add you to the private repository.

You should be able to do a one-shot publication by:
  1. Check in the clean, decompiled source you based your work on into one branch.
  2. git diff your head against the head of that branch.
  3. publish the result.
Not necessarily the nicest thing in the world, but that is a public-world-suitable version of the changes with minimal effort on your part.

I'm also fine with just being added to the private repo, if you prefer. I definitely don't want to cause you trouble or extra effort, even if I do port some of the code y'all wrote over to a tModLoader compatible mod. (In which case I will absolutely be giving credit to y'all, by the way. I'm not looking for your glory, just, honestly, to be able to see where the dang dummy ghosts are while I'm building machines.)
 
You should be able to do a one-shot publication by:
  1. Check in the clean, decompiled source you based your work on into one branch.
  2. git diff your head against the head of that branch.
  3. publish the result.
Not necessarily the nicest thing in the world, but that is a public-world-suitable version of the changes with minimal effort on your part.

I'm also fine with just being added to the private repo, if you prefer. I definitely don't want to cause you trouble or extra effort, even if I do port some of the code y'all wrote over to a tModLoader compatible mod. (In which case I will absolutely be giving credit to y'all, by the way. I'm not looking for your glory, just, honestly, to be able to see where the dang dummy ghosts are while I'm building machines.)


Oh, thank you very much for those instructions!

I guess I'm going to do both? (Publish the code & add you to the git repo) Let's continue this in a private chat?
[doublepost=1501317177,1501171846][/doublepost]@SlippyCheeze
Ok, I managed to create a .diff file: https://gitlab.com/mechmod/MechmodPublic/blob/master/mechmodChanges.diff
 
I wish it could be a .tmod file, that way I could also use it with hero's mod.
I also would like to make this a tModLoader mod. However, from what I have seen, tModLoader mods can't really modify the Terraria source code.
[doublepost=1502561723,1502305729][/doublepost]Ok, I've decided to bring Mechmod back to life! :D

@Smiffy @SlippyCheeze @five--three Do you guys feel like lending a hand? :D
 
I also would like to make this a tModLoader mod. However, from what I have seen, tModLoader mods can't really modify the Terraria source code.
[doublepost=1502561723,1502305729][/doublepost]Ok, I've decided to bring Mechmod back to life! :D

@Smiffy @SlippyCheeze @five--three Do you guys feel like lending a hand? :D

I would love to see this happen and be compatible with the newest version of Terraria. right now I've been using TerraPatcher and that works, but then after a certain point I have to know the internal name of items and they tend to not always be what they are actually called. So recalling items by ID is a chore.
 
Hey,can you make an tModLoader version of this mod?

Well, theoretically speaking, the answer would be: "yes, maybe, kinda".
I can't make a tModLoader mod because the tModLoader API isn't that powerful. However, I should be able to make a version of this mod that has tModLoader built in.


Also, quick update for everybody: Currently, I'm still working on decompiling Terraria. I am cooperating with one of the tModLoader guys to automate the decompilation task. The big advantage of an automated decompiler is that it will be a lot easier to keep up with the Terraria updates.
 
I dont want to ask something in my first post, but i dont know what happens, when i try 2 open the app Mechmod my computer pops up this window.
Thanks for reading itThanks for reading it.
Quesette.PNG
 
I dont want to ask something in my first post, but i dont know what happens, when i try 2 open the app Mechmod my computer pops up this window.
Thanks for reading itThanks for reading it. View attachment 185954

Which Mechmod version did you download? Chances are that by now, the older version of Mechmod doesn't work anymore. :/
 
Back
Top Bottom