[Mod] Better Fences [better_fences]

Post Reply
User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

[Mod] Better Fences [better_fences]

by ChimneySwift » Post

Better Fences

A Minetest mod which solves the fence connection problem.

Recently I was building a house and was quite frustrated that my fence nodes wouldn't connect to the mossy cobblestone:

Image

So, I submitted a PR to make fences connect to all nodes, and it was promptly closed because running fences along a cobble wall would look terrible. This made total sense, but it was still frustrating because the only 2 options (fences that connect to all nodes and fences that connect to only fences) both look terrible in some situations.

My Solution

Better fences overrides default fences and walls and replaces them with 2 fence types, one which connects to all nodes and one which only connects to other fences and walls.

Whenever you place or dig a fence, this mod will determine if the fence you just placed will connect to 2 or more adjacent fences or walls, if it will it places the fence which only connects to fences, otherwise it places the fence which connects to all nodes. Every dig and place will result in the surrounding 4 fences (if they exist) being checked and updated if necessary as well.

This behaviour results in only the fences at the end of a line of fences connecting to all nodes:

Image

So you get the best of both worlds, ability to connect to nodes like stone, and also to not have a line of fences running along a wall look like trash:

Image

Code License: LGPL 2.1+

Dependencies: default

Optional Dependencies: walls

GitHub
Download
A spoon is basically a tiny bowl with a stick on it

User avatar
sorcerykid
Member
Posts: 1841
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Better Fences [better_fences]

by sorcerykid » Post

Finally! This should be included in the official game!

User avatar
Stix
Member
Posts: 1385
Joined: Fri Aug 04, 2017 14:19
IRC: nil
In-game: Stix [+alts]
Location: USA

Re: [Mod] Better Fences [better_fences]

by Stix » Post

sorcerykid wrote:Finally! This should be included in the official game!
Agreed! I've been waiting for years for something like this.
Hey, what can i say? I'm the bad guy.

User avatar
v-rob
Developer
Posts: 970
Joined: Thu Mar 24, 2016 03:19
GitHub: v-rob
IRC: v-rob
Location: Right behind you.

Re: [Mod] Better Fences [better_fences]

by v-rob » Post

Nice! This is ingenious! We've always needed something like this.
Core Developer | My Best Mods: Bridger - Slats - Stained Glass

User avatar
Beerholder
Member
Posts: 199
Joined: Wed Aug 03, 2016 20:23
GitHub: evrooije
In-game: Beerholder

Re: [Mod] Better Fences [better_fences]

by Beerholder » Post

Something so simple (albeit 280 LoC O_o), yet so awesome! :D +1000

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: [Mod] Better Fences [better_fences]

by ChimneySwift » Post

Thanks all!
Beerholder wrote:Something so simple (albeit 280 LoC O_o), yet so awesome! :D +1000
Agreed, I didn't bother to do too much tidying up tbh... but there's a lot of duplicate code at the bottom where the nodes and stuff are registered so I intend to fix that.
A spoon is basically a tiny bowl with a stick on it

User avatar
Hume2
Member
Posts: 709
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

Re: [Mod] Better Fences [better_fences]

by Hume2 » Post

Nice mod!
There should be a way to distinguish these two fences in the inventory, for example a small overlaying icon.
If you lack the reality, go on a trip or find a job.

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: [Mod] Better Fences [better_fences]

by ChimneySwift » Post

Hume2 wrote:There should be a way to distinguish these two fences in the inventory, for example a small overlaying icon.
The mod will automatically decide which fence to place and update the surrounding ones, only one fence should come up in your inventory when you dig it and in creative inventory. It should also unregister default fences and walls.

Are you seeing multiple by chance?
A spoon is basically a tiny bowl with a stick on it

User avatar
Linuxdirk
Member
Posts: 3217
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Better Fences [better_fences]

by Linuxdirk » Post

ChimneySwift wrote:The mod will automatically decide …
Never a good idea. The decision might be different from what the player wants.

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: [Mod] Better Fences [better_fences]

by ChimneySwift » Post

Linuxdirk wrote:Never a good idea. The decision might be different from what the player wants.
Then don't install this mod and use the default fences which are even less likely to connect the way the player wants:

Image
Image

This mod definitely fails in some circumstances, but the way it handles connections is much more realistic than default fences (IMO), and default fences also fail in those same areas.

I could make the fences separate, and it would be trivial to modify default to just have 2 different fence types (not to mention much more boring), but the ease of use gained from using an automated method like this vastly outweighs the ability to cover a couple of niche uses for fences where the mod fails. In fact the only time so far that I found a connection related problem was using fences to create a medieval-style skylight, where default fails already too, by the way.

and at least in this mod I didn't override default, because apparently that's also never a good idea.
A spoon is basically a tiny bowl with a stick on it

User avatar
Pyrollo
Developer
Posts: 385
Joined: Mon Jan 08, 2018 15:14
GitHub: pyrollo
In-game: Naj
Location: Paris

Re: [Mod] Better Fences [better_fences]

by Pyrollo » Post

ChimneySwift maybe you could solve the choice issue by adding something like: punching the fence makes it switch to the other style node.
[ Display Modpack ] - [ Digiterms ] - [ Crater MG ] - [ LATE ]

todada
New member
Posts: 5
Joined: Sat Mar 18, 2017 18:49
GitHub: todada

Re: [Mod] Better Fences [better_fences]

by todada » Post

...or use the screwdriver.
Hmmmm.....

User avatar
sorcerykid
Member
Posts: 1841
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Better Fences [better_fences]

by sorcerykid » Post

I too considered the screwdriver. But the API requires a paramtype2 of "facedir", which fence nodes do not have.

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: [Mod] Better Fences [better_fences]

by ChimneySwift » Post

Update:
  • Right click will now toggle the fence type, note that manual changes might revert if you place a fence next to the fence you manually adjusted)
  • Security fixes for protector mod (woops! sorry, forgot protector checks, verified and working for both right click, dig and placement on tenplus1's protector mod this time)
  • Bug fixes - nodes can only be placed in nodes which are buildable_to (like air, grass, etc, before you could override solid nodes...)
  • Cody tidy up (the 62 lines for unregistering default fences and re-registering new ones was reduced from 62 lines to 14 lines. Code redundancy for re-registering walls was also removed)
A spoon is basically a tiny bowl with a stick on it

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [Mod] Better Fences [better_fences]

by Sokomine » Post

My xconnected mod also has fences of this type. Punching a middle fence will alternate between a post placed there and no post (bars just going through).
A list of my mods can be found here.

User avatar
pampogokiraly
Member
Posts: 293
Joined: Wed Jan 08, 2020 22:21
In-game: i_love_mesecon

Re: [Mod] Better Fences [better_fences]

by pampogokiraly » Post

I have found a little bug with your last update :/
I can craft a fence easily with only two sticks:

Code: Select all

nothing, stick, nothing,
nothing, stick, nothing.
And it also works if i throw some wood into the crafting grid (replacing the nothing with them)
Can you fix this please? I really want to use this mod because this method is much better than the default placement :D
All praise the Bacon God! The one and only god in MineTest

User avatar
techniX
Member
Posts: 27
Joined: Sun Dec 08, 2019 20:55
GitHub: technix
In-game: techniX

Re: [Mod] Better Fences [better_fences]

by techniX » Post

We fixed this on our server, you can use better_fences from our repo:
https://github.com/minestead/minestead_ ... ter_fences
Also, we fixed the issue with item placement on top of the fence. Now the connection are switched when you punch the fence instead of right-click.

User avatar
pampogokiraly
Member
Posts: 293
Joined: Wed Jan 08, 2020 22:21
In-game: i_love_mesecon

Re: [Mod] Better Fences [better_fences]

by pampogokiraly » Post

Sorry for asking a stupid question.
How can i download your version?
All praise the Bacon God! The one and only god in MineTest

User avatar
techniX
Member
Posts: 27
Joined: Sun Dec 08, 2019 20:55
GitHub: technix
In-game: techniX

Re: [Mod] Better Fences [better_fences]

by techniX » Post

You can download the whole repository, just go here: https://github.com/minestead/minestead_mods, then click green button 'Clone or download', then click 'Download ZIP'. Unzip the downloaded archive and copy content of the mod folder.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 20 guests