pacas00 / ModdersGearbox

A Fortresscraft Evolved Modding Library.
MIT License
1 stars 0 forks source link

Depth Based Block Replacement #7

Open ph3rr3t opened 5 years ago

ph3rr3t commented 5 years ago

So many neat things I could do with a feature like this. Sample code below, might be a few other parameters that could be added that I've not thought of;

[GenerationReplacementEntry]
    [TargetKey]DeepRock[/TargetKey]
    [ReplacementKey]NewRockOrStone[/ReplacementKey]
    [ReplacementValue]0[/ReplacementValue]  <!-- Optional, Defaults to default value, optionally, put a ValueEntry key instead of a number and have the code lookup the value -->
    [ReplacementChance]25[/ReplacementChance] <!-- Optional, 0-100 -->
    [MinDepth]-1000[/MinDepth]
    [MaxDepth]-2000[/MaxDepth]
[/GenerationReplacementEntry]
pacas00 commented 5 years ago

@ph3rr3t Do you want to be able to set a chance of this being replaced or anything?

ph3rr3t commented 5 years ago

@pacas00 YES

Adding to OP.

pacas00 commented 5 years ago

Alright, I've updated the example entry with what i feel is a cleaner set of names.

Quite likely, this will get run after the built in mod ore gen code.

If all goes well and today/tomorrows heat wave doesn't put me out of action, should be working on this on thursday.

ph3rr3t commented 5 years ago

What is the purpose of the [ReplacementValue] line?

pacas00 commented 5 years ago

To allow a value to be set on the replacement block,

For paintable or colourised blocks, it's the colour. For anything with a ValueEntry, then a specific key to use. (or number if your using vanilla cubes)

Edited the comment in the OP to reflect that keys are supported

ph3rr3t commented 5 years ago

Would that work with an ore block's value too?

pacas00 commented 5 years ago

Yes, but there is a terrain generator for mod ores already in the game

pacas00 commented 5 years ago

Though in saying so, if you wanted an ore, but random low chance single blocks and not veins, this would work for that.

ph3rr3t commented 5 years ago

You're the coder so you get to pick the tags, but I had a thought;

[BlockReplaceEntry]
  [OldKey]DeepRock[/OldKey]
  [NewKey]CustomKey[/NewKey]
  [NewValue]0[/NewValue] <!--Optional, Defaults to default value. Useful for block color or ore density.-->
     <!--Have code lookup value if ValueEntry Key is used.-->
  [NewChance]25[/NewChance] <!-- Optional, 0-100 -->
  [MinDepth]-1000[/MinDepth]
  [MaxDepth]-2000[/MaxDepth]
[/BlockReplaceEntry]
pacas00 commented 5 years ago

Please don't close this, Unless you no longer want it. Otherwise i'll forget it.

pacas00 commented 5 years ago

Generally speaking, I like the name of something to be a good reminder of what something is for. In saying so, I've made some adjustments to the names and will explain my reasoning. Because you never know, you might have a better name than me afterwards.

<TerrainGenerationBlockReplacementEntry>  <!-- Entry represents a block replacement during terrain generation -->
    <TargetKey>DeepRock</TargetKey>  <!-- The key targeted during generation -->
    <ReplacementKey>NewRockOrStone</ReplacementKey>  <!-- The key we replace it with during " -->
    <ReplacementValue>0</ReplacementValue>  <!-- The value we " -->
    <ReplacementChance>25</ReplacementChance> <!-- The chance that we replace it -->
    <MinDepth>-1000</MinDepth>  <!-- Maybe these should be renamed MinReplacementDepth or something, idk -->
    <MaxDepth>-2000</MaxDepth>
</TerrainGenerationBlockReplacementEntry>
ph3rr3t commented 5 years ago

If I closed it then I don't know how I did it. Thought you had done so. As for the tags, lets just go with the ones you put in OP.

pacas00 commented 5 years ago

Bumping this forward to v1.2, Everything below here is notes so i know where to write the implementation of this.

Todo

PerlinCache cache stores the cubes? arrays are [16,16,16] maCubes and maCubeValues

ph3rr3t commented 5 years ago

Possible addition, the ability to set just min/max depth, without target key or chance.

pacas00 commented 5 years ago

So, basically ore gen? Why not just use ore gen for that?

pacas00 commented 5 years ago

Or do you mean like biome layers?

ph3rr3t commented 5 years ago

Kinda as biome layers. Currently flatland only affects the surface. This would allow us to modify everything below ground as well.

pacas00 commented 5 years ago

19