IssueRaiser

Too much like the real Terraria source code.

I was a Terraria modder and a member of the tConfig and tAPI dev teams. (I also made another modding API for 1.3, but it didn't take off.), and I can say you didn't only try to clone the game, but also the code quality of Terraria: > Blocks and items, among many other things, are represented by magic numbers instead of enums. Terraria does the exact same thing. > There are 417 lines of block comments at the top of `TerraFrame.java` that serve as manual translation tables. We (Terraria modders) had no such thing, so the table must be made manually (or rather, we used some code to generate it). Some methods exist (such as `Item.SetDefaults`) to give an Item's fields (not properties, but raw fields) the desired values. (There are no subclasses or anything, and no Item/... definition lookup tables/... .) It is an infinite sea of `if (type == foo) { init(); } ...`. Note that it uses `if` without `else` or `return`, drastically slowing it down, but it got changed to a `switch` in 1.2. (More on `SetDefaults` later.) In 1.2, a `Terraria.ID` namespace was added containing (static) classes containing constants for easy Item/... -> numerical ID lookup as well. Terraria entities also have a `netID`, which slightly differs from their `type`: entities with the same type have the same texture, but they can have differing netIDs. The latter defines the actual properties (max life, damage, ...). Thus, separate `netDefaults` methods exist as well... > So as to avoid needing to declare lo

Posted by PoroCYon on Jul 23, 2017, 4:53 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments

reliability (Other)

Too much like the real Terraria source code.

PoroCYonJul 23, 2017, 4:53 PM

I was a Terraria modder and a member of the tConfig and tAPI dev teams. (I also made another modding API for 1.3, but it didn't take off.), and I can say you didn't only try to clone the game, but also the code quality of Terraria: > Blocks and items, among many other things, are represented by magic numbers instead of enums. Terraria does the exact same thing. > There are 417 lines of block comments at the top of `TerraFrame.java` that serve as manual translation tables. We (Terraria modders) had no such thing, so the table must be made manually (or rather, we used some code to generate it). Some methods exist (such as `Item.SetDefaults`) to give an Item's fields (not properties, but raw fields) the desired values. (There are no subclasses or anything, and no Item/... definition lookup tables/... .) It is an infinite sea of `if (type == foo) { init(); } ...`. Note that it uses `if` without `else` or `return`, drastically slowing it down, but it got changed to a `switch` in 1.2. (More on `SetDefaults` later.) In 1.2, a `Terraria.ID` namespace was added containing (static) classes containing constants for easy Item/... -> numerical ID lookup as well. Terraria entities also have a `netID`, which slightly differs from their `type`: entities with the same type have the same texture, but they can have differing netIDs. The latter defines the actual properties (max life, damage, ...). Thus, separate `netDefaults` methods exist as well... > So as to avoid needing to declare lo

Comments (0)

No comments yet. Start the discussion.

Comment on this issue