TerrainControl icon indicating copy to clipboard operation
TerrainControl copied to clipboard

Enable BO3 trees to be generated at different heights

Open hexosse opened this issue 7 years ago • 6 comments

This enable to generate trees at different heights when SpawnHeightOffset and SpawnHeightVariance in BO3.

hexosse avatar May 31 '17 19:05 hexosse

Nice idea, but I think the implementation could be better. You now have lots of blocks like this:

                 if(tree instanceof BO3) 
                 { 
                    if(((BO3) tree).spawn(world, random, spawnX, spawnZ)) 
                    { 
                        // Success! 
                        return true; 
                    } 
                 } 
                else 
                { 
                    if (tree.spawnForced(world, random, rotation, spawnX, y, spawnZ)) 
                    { 
                        // Success! 
                        return true; 
                    } 
                } 

How about adding spawn(world, random, spawnX, spawnZ) to the CustomObject interface instead? Then you don't need to cast to a BO3 first. (A better name for this method would probably be spawnInColumn.)

rutgerkok avatar Jun 03 '17 07:06 rutgerkok

Hi @hexosse can you compile the plugin for me with this feature? i have TerrainControl 2.7.2

agusztin avatar Jun 04 '17 23:06 agusztin

@rutgerkok : I didn't want to change the CustomObject interface in a first place. This would have an impact on all generated structures? I'll try and propose a new commit to this PR.

@agusztin : which version of bukkit is 2.7.2

hexosse avatar Jun 06 '17 08:06 hexosse

It will not affect other structures if the code in the new spawn method is equivalent to the old code that was outside the method. It requires some care, but it results in much cleaner code.

If you're having trouble, just leave a message here, and I'll see what I can do.

rutgerkok avatar Jun 06 '17 19:06 rutgerkok

@hexosse Server version: This server is running CraftBukkit version git-Spigot-21fe707-e1ebe52 (MC: 1.8.8) (Implementing API version 1.8.8-R0.1-SNAPSHOT) TerrainControl Version: 2.7.2

agusztin avatar Jun 06 '17 22:06 agusztin

I don't find a good way to do it. In fact, I don't understand few parts of the code yet. The process function could be used for it, but it use frequency and rarity which should be ignored for Tree(..), Sapling(..) and CustomStructure(..) I don't think that adding a new function is a good point as there is already many spawn functions (spawn, spawnInChunk, process)

hexosse avatar Jun 07 '17 20:06 hexosse