-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TileID.Sets.PlanterBoxes #4061
base: 1.4.4
Are you sure you want to change the base?
TileID.Sets.PlanterBoxes #4061
Conversation
Allows for easy implementation of modded planter boxes. This covers everything from generating grass to tile framing. An example is provided within.
I forgor an ! (also fixed the amoungus reference)
Co-authored-by: BasicallyIAmFox <65787578+BasicallyIAmFox@users.noreply.github.com>
TileObjectData.newTile.AnchorAlternateTiles = new int[] { | ||
TileID.ClayPot, | ||
TileID.PlanterBox | ||
TileID.PlanterBox, | ||
ModContent.TileType<ExamplePlanterBox>() | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit tricky because ideally it should include all modded planter boxes, not just vanillas + the one from the same mod. I'm not sure what the solution here would be except manually change the tileobjectdata somewhere around TileLoader.PostSetupTileMerge
(when every mod has populated TileID.Sets.PlanterBoxes
) for every modded tile that has TileID.PlanterBox
in its AnchorAlternateTiles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would require redoing everything that uses AnchorAlternateTiles or making a wrapper class that overrides equality comparison with ints, but making AnchorAlternateTiles support sets (or adding a separate field for sets) would solve this issue and potentially future ones.
do modded planter boxes now allow torches to be placed on them? |
What is the new feature?
TileID.Sets.PlanterBoxes is a TileID set for all Planter Boxes. This allows any mod to add
TileID.Sets.PlanterBoxes[Type] = true;
and their tile will behave similar to vanilla planter boxes.These changes include:
Smart Cursor
Herb and Grass growth/placement
Tile Framing
AnchorType.PlanterBox
Grass and Dirt spreading through tiles
Skeletron Prime bombs not falling through
This allows for quite easy implementation of the modder's own planter box for their herb and allows for a bunch of vanilla code to run for their tile.
Why should this be part of tModLoader?
You need to make 10-12 different IL edits to get a perfectly working planter box. This is not an option for some modders that either don't want to use IL edits or are too new to modding/C# to know how to make an IL edit, this isn't even to mention the amount of IL edits needed or how big some of them would be.
This also allows for modded planter boxes to merge together as currently only modded ones can merge with vanilla planter boxes.
Are there alternative designs?
To my knowledge no, I do think this is the best way of adding support for modded planter boxes. Adding planter boxes to the herb anchor in TileObjectData and referencing that for PlantAlch in WorldGen.cs would be a alternate approach to the herb placement issue if we don't need a whole TileID Set for this.
Sample usage for the new feature
ExampleMod updates
Added Example Planter Box (Item and Tile),
This will show new modders how to easily add a planter box alongside their own herb.