Jump to content

I cant generate blocks under the water


Vintagebob
 Share

Recommended Posts

I asked this allready, but in the wrong forum, now again in the Modding questions ūüôā

Hello, im programming a Vintage Story mod and want do add hydrothermal vents to the game. The block itself works perfectly, but i can't generate these vents under the water :(.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Here is my programm code in the .cs file:

 

using System;
using Vintagestory.API.Common;
using Vintagestory.API.Common.Entities;
using Vintagestory.API.MathTools;

namespace omniummod
{
    public class Omniummod : ModSystem
    {

        public override void Start(ICoreAPI api)
        {
            base.Start(api);
            api.RegisterBlockClass("hydrothermal_vent", typeof(hydrothermal_vent));
        }
    }

    public class hydrothermal_vent : Block
    {
        Random random = new Random();
        Block[] blocks;

        public override bool TryPlaceBlockForWorldGen(IBlockAccessor blockAccessor, BlockPos pos, BlockFacing onBlockFace, LCGRandom worldGenRand)
        {
            BlockPos belowPos = pos.DownCopy();

            Block block = blockAccessor.GetBlock(belowPos);
            if (block.LiquidCode != "water") return false;

            int depth = 1;
            while (depth < 100)
            {
                belowPos.Down();
                block = blockAccessor.GetBlock(belowPos);

                if (block.Fertility >= 0)
                {
                    belowPos.Up();
                    PlaceVent(blockAccessor, belowPos, depth);
                    return true;
                }
                else
                {
                    if (!block.IsLiquid()) return false;
                }

                depth++;
            }

            return false;

        }

        private void PlaceVent(IBlockAccessor blockAccessor, BlockPos pos, int depth)
        {
            int height = Math.Min(depth - 1, 1 + random.Next(3) + random.Next(3));
            AssetLocation assetl = new AssetLocation("omniummod", "blocktypes/deepwaterblocks/hydrothermal_vent");
            blockAccessor.SetBlock(blockAccessor.GetBlock(assetl).BlockId, pos);
        }
    }
}

(some parts I copied from the Seaweed class :D)

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Here is the .json file of the hydrothermal vent, if the problem ist not in the code but in the block:

{
    code: "hydrothermal_vent",
    entityClass: "hydrothermal_vent",    
    creativeinventory: { "general": ["*"] },
    blockmaterial: "Stone",
    drawtype: "json",
    shape: { 
        base: "block/deepwaterblocks/hydrothermal_vent*",
    },
    storageFlags: 257,        
    lightAbsorption: 0,
    sidesolid: {
        all: "false"
    },
    sideopaque: {
        all: "false"
    },
    resistance: 2.0,
    sounds: {
        "place": "game:block/stone",
        "walk": "game:block/stone"
    },
    particleProperties: [
        {
            hsvaColor: [{ avg: 0, var: 1 }, { avg: 0, var: 1 }, { avg: 0, var: 1 },  { avg: 0, var: 1 }],
            gravityEffect: { avg: -0.02, var: 0.01 },
            posOffset: [ { avg: 0, var: 0.1 }, { avg: 0.5, var: 0.1 }, { avg: 0, var: 0.1 }],
            velocity: [ { avg: 0, var: 0.25 }, { avg: 0.1, var: 0.1 }, { avg: 0, var: 0.25 }],
            quantity: { avg: 1, var: 1 },
            size: { avg: 5, var: 1 },
            sizeEvolve: { transform: "quadratic", factor: 0.5 },
            lifeLength: { avg: 3, var: 1 },
            vertexFlags: 128
        }
    ],
    guiTransform: {
        rotation: { x: -22.6, y: -145, z: 0 }
    },
    tpHandTransform: {
        translation: { x: -2.1, y: -1.4, z: -1.5 },
        rotation: { x: 0, y: 17, z: -88 }
    },
    groundTransform: {
        translation: { x: 0, y: 0, z: 0 },
        rotation: { x: -58, y: -45, z: 0 },
        origin: { x: 0.5, y: 0, z: 0.5 },
        scale: 1.5
    }
}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

And here is the .json worldgen file, where I make the hydrothermal vent - blockpatch:

{
    chanceMultiplier: { dist: "uniform", avg: 2.5, var: 2 },
    patches: [
        {
            comment: "Large patches of hydrothermal vent",
            blockCodes: ["hydrothermal_vent"],
            quantity: { avg: 25, var: 15 },
            offsetX: { avg: 0, var: 12 },
            offsetZ: { avg: 0, var: 12 },
            chance: 1,
            minWaterDepth: 1,
            placement: "UnderWater"
        },
    ]
}

 

its copied from the Seaweed blockpatch...

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I hope someone will be able to help me

and thank you in advance :D

Edited by Vintagebob
Link to comment
Share on other sites

 Share

√ó
√ó
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.