public override void StartServerSide(ICoreServerAPI api) { this.api = api; api.RegisterTreeGenerator(new AssetLocation("immersion:palm"), new PalmTreeGenerator(api, "palm")); api.RegisterTreeGenerator(new AssetLocation("immersion:palmcoconut"), new PalmTreeGenerator(api, "palmcoconut")); api.RegisterTreeGenerator(new AssetLocation("immersion:palmbanana"), new PalmTreeGenerator(api, "palmbanana")); api.RegisterCommand("genpalm", "genpalm", "", (p, g, a) => { var pos = p.CurrentBlockSelection?.Position?.AddCopy(0, 1, 0); if (sNoise == null) { SetupPalm(api.World.BlockAccessor.GetBlock(new AssetLocation("immersion:palmlog-bottom-grown"))); } if (pos != null) { GenPalmTree(api.World.BlockAccessor, pos); } }, Privilege.ban); if (!ImmersionWorldgenConfig.GenPalms) { return; } chunksize = api.WorldManager.ChunkSize; api.Event.ChunkColumnGeneration(OnChunkColumnGen, EnumWorldGenPass.Vegetation, "standard"); api.Event.InitWorldGenerator(() => SetupPalm(api.World.BlockAccessor.GetBlock(new AssetLocation("immersion:palmlog-bottom-grown"))), "standard"); api.Event.GetWorldgenBlockAccessor(c => blockAccessor = c.GetBlockAccessor(true)); }
public override void OnLoaded(ICoreAPI api) { ICoreServerAPI sapi = api as ICoreServerAPI; if (sapi != null) { if (Code.Path.Equals("bamboo-grown-green-segment1")) { sapi.RegisterTreeGenerator(new AssetLocation("bamboo-grown-green"), this); } if (Code.Path.Equals("bamboo-grown-brown-segment1")) { sapi.RegisterTreeGenerator(new AssetLocation("bamboo-grown-brown"), this); } } if (greenSeg1 == null) { IBlockAccessor blockAccess = api.World.BlockAccessor; greenSeg1 = blockAccess.GetBlock(new AssetLocation("bamboo-grown-green-segment1")); greenSeg2 = blockAccess.GetBlock(new AssetLocation("bamboo-grown-green-segment2")); greenSeg3 = blockAccess.GetBlock(new AssetLocation("bamboo-grown-green-segment3")); brownSeg1 = blockAccess.GetBlock(new AssetLocation("bamboo-grown-brown-segment1")); brownSeg2 = blockAccess.GetBlock(new AssetLocation("bamboo-grown-brown-segment2")); brownSeg3 = blockAccess.GetBlock(new AssetLocation("bamboo-grown-brown-segment3")); leaves = blockAccess.GetBlock(new AssetLocation("bambooleaves-grown")); } }
public override void OnLoaded(ICoreAPI api) { base.OnLoaded(api); ICoreServerAPI sapi = api as ICoreServerAPI; if (sapi != null) { if (Code.Path.Equals("bamboo-grown-green-segment1")) { sapi.RegisterTreeGenerator(new AssetLocation("bamboo-grown-green"), this); } if (Code.Path.Equals("bamboo-grown-brown-segment1")) { sapi.RegisterTreeGenerator(new AssetLocation("bamboo-grown-brown"), this); } } if (greenSeg1 == null) { IBlockAccessor blockAccess = api.World.BlockAccessor; greenSeg1 = blockAccess.GetBlock(new AssetLocation("bamboo-grown-green-segment1")); greenSeg2 = blockAccess.GetBlock(new AssetLocation("bamboo-grown-green-segment2")); greenSeg3 = blockAccess.GetBlock(new AssetLocation("bamboo-grown-green-segment3")); brownSeg1 = blockAccess.GetBlock(new AssetLocation("bamboo-grown-brown-segment1")); brownSeg2 = blockAccess.GetBlock(new AssetLocation("bamboo-grown-brown-segment2")); brownSeg3 = blockAccess.GetBlock(new AssetLocation("bamboo-grown-brown-segment3")); brownLeaves = blockAccess.GetBlock(new AssetLocation("bambooleaves-brown-grown")); greenLeaves = blockAccess.GetBlock(new AssetLocation("bambooleaves-green-grown")); greenShootBlock = blockAccess.GetBlock(new AssetLocation("sapling-greenbambooshoots-free")); brownShootBlock = blockAccess.GetBlock(new AssetLocation("sapling-brownbambooshoots-free")); } if (RandomDrawOffset > 0) { JsonObject overrider = Attributes?["overrideRandomDrawOffset"]; if (overrider?.Exists == true) { this.RandomDrawOffset = overrider.AsInt(1); } } isSegmentWithLeaves = LastCodePart() == "segment2" || LastCodePart() == "segment3"; }
public override void OnLoaded(ICoreAPI api) { base.OnLoaded(api); ICoreServerAPI sapi = api as ICoreServerAPI; if (sapi != null) { if (Code.Path.Equals("ferntree-normal-trunk")) { sapi.RegisterTreeGenerator(new AssetLocation("ferntree-normal-trunk"), this); } } if (trunk == null) { IBlockAccessor blockAccess = api.World.BlockAccessor; trunk = blockAccess.GetBlock(new AssetLocation("ferntree-normal-trunk")); trunkTopYoung = blockAccess.GetBlock(new AssetLocation("ferntree-normal-trunk-top-young")); trunkTopMedium = blockAccess.GetBlock(new AssetLocation("ferntree-normal-trunk-top-medium")); trunkTopOld = blockAccess.GetBlock(new AssetLocation("ferntree-normal-trunk-top-old")); foliage = blockAccess.GetBlock(new AssetLocation("ferntree-normal-foliage")); } }
public void LoadTreeGenerators() { Dictionary <AssetLocation, TreeGenConfig> TreeGenModelsByTree = sapi.Assets.GetMany <TreeGenConfig>(sapi.Server.Logger, "worldgen/treegen"); string names = ""; foreach (var val in TreeGenModelsByTree) { AssetLocation name = val.Key.Clone(); if (names.Length > 0) { names += ", "; } names += name; name.Path = val.Key.Path.Substring("worldgen/treegen/".Length); name.RemoveEnding(); val.Value.Init(val.Key, sapi.Server.Logger); sapi.RegisterTreeGenerator(name, new TreeGen(val.Value, sapi.WorldManager.Seed)); val.Value.treeBlocks.ResolveBlockNames(sapi); } sapi.Server.LogNotification("Reloaded {0} tree generators", TreeGenModelsByTree.Count); }
public void LoadTreeGenerators() { Dictionary <AssetLocation, TreeGenConfig> TreeGenModelsByTree = sapi.Assets.GetMany <TreeGenConfig>(sapi.Server.Logger, "worldgen/treegen"); var worldprops = sapi.Assets.Get <WoodWorldProperty>(new AssetLocation("worldproperties/block/wood.json")); Dictionary <string, EnumTreeType> treetypes = new Dictionary <string, EnumTreeType>(); foreach (var val in worldprops.Variants) { treetypes[val.Code.Path] = val.TreeType; } string names = ""; foreach (var val in TreeGenModelsByTree) { AssetLocation name = val.Key.Clone(); if (names.Length > 0) { names += ", "; } names += name; name.Path = val.Key.Path.Substring("worldgen/treegen/".Length); name.RemoveEnding(); val.Value.Init(val.Key, sapi.Server.Logger); sapi.RegisterTreeGenerator(name, new TreeGen(val.Value, sapi.WorldManager.Seed, forestFloorSystem)); val.Value.treeBlocks.ResolveBlockNames(sapi, name.Path); treetypes.TryGetValue(sapi.World.GetBlock(val.Value.treeBlocks.logBlockId).Variant["wood"], out val.Value.Treetype); } sapi.Server.LogNotification("Reloaded {0} tree generators", TreeGenModelsByTree.Count); }