rvandoosselaer / Blocks

A block (voxel) engine for jMonkeyEngine
BSD 3-Clause "New" or "Revised" License
42 stars 14 forks source link

Chunk should have a public constructor so that it supports inheritance #48

Closed Igrium closed 4 years ago

Igrium commented 4 years ago

In my project, I'm trying to resolve a compatibility issue between two systems, and the best way I can think to do this was by making a child class of Chunk, but I can't because it has a private constructor.

I don't understand why it has to have a private constructor though, because you could just make the constructor have all the code from createAt and re-write createAt to just feed the location into the constructor for backward compatibility.

So why don't you do that?

rvandoosselaer commented 4 years ago

Hi Sam,

the reason to not have a pubic constructor with the location is for readability purposes only. Chunk.createAt(new Vec3i(0, 0, 0)); describes better the function/goal of the passed vector parameter then new Chunk(new Vec3i(0, 0, 0));.

The downside of this is that it doesn't support inheritance. I'll create a hotfix PR to support both ways on the last stable release.

rvandoosselaer commented 4 years ago

Feature available in release v1.5.1

Igrium commented 4 years ago

Thanks!