From ee495f88aca2be190eff6cfbe55f06fe2e718686 Mon Sep 17 00:00:00 2001 From: melchior Date: Tue, 16 Feb 2021 21:07:04 -0500 Subject: [PATCH] W.I.P. some more things done, for VS API change --- Assorted/Assorted.csproj | 9 ++- .../BlockBehaviorFreeReinforcement.cs | 18 +++-- Assorted/BlockClasses/CollapsingBlock.cs | 66 ++++--------------- .../BoltableDoorBlockEntity.cs | 4 +- .../blocktypes/wood/false_floor.json | 34 ++++------ .../defensive/recipes/grid/false_floor.json | 18 ++--- Assorted/modinfo.json | 1 + 7 files changed, 52 insertions(+), 98 deletions(-) diff --git a/Assorted/Assorted.csproj b/Assorted/Assorted.csproj index 67939b8..078655b 100644 --- a/Assorted/Assorted.csproj +++ b/Assorted/Assorted.csproj @@ -76,7 +76,6 @@ - @@ -85,6 +84,8 @@ + + @@ -181,6 +182,12 @@ Always + + Always + + + Always + \ No newline at end of file diff --git a/Assorted/BlockBehaviors/BlockBehaviorFreeReinforcement.cs b/Assorted/BlockBehaviors/BlockBehaviorFreeReinforcement.cs index 2aa0fbb..6375d7a 100644 --- a/Assorted/BlockBehaviors/BlockBehaviorFreeReinforcement.cs +++ b/Assorted/BlockBehaviors/BlockBehaviorFreeReinforcement.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Vintagestory.API; using Vintagestory.API.Common; using Vintagestory.API.Config; using Vintagestory.API.MathTools; @@ -19,16 +20,21 @@ namespace FirstMachineAge private ModSystemBlockReinforcement ReinforcementSystem; - private uint Howmuch + public uint Howmuch { - get - { - return properties[_howmuchKey].AsType(1u); - } + get; private set; } + public override void Initialize(JsonObject properties) + { + base.Initialize(properties); + + Howmuch = properties[_howmuchKey].AsType(1u); + } + public BlockBehaviorFreeReinforcement(Block block) : base(block) { + } public override void OnLoaded(ICoreAPI api) @@ -47,7 +53,7 @@ namespace FirstMachineAge { handling = EnumHandling.PassThrough; if (world.Api.Side.IsServer( )) { - world.Api.Event.RegisterCallback((elapse) => { PostPlacementReinforce(elapse, blockSel.Position.Copy( ), byPlayer, this.Howmuch); }, 64); + world.Api.Event.RegisterCallback((elapse) => { PostPlacementReinforce(elapse, blockSel.Position.Copy( ), byPlayer, this.Howmuch); }, 256); } return true; } diff --git a/Assorted/BlockClasses/CollapsingBlock.cs b/Assorted/BlockClasses/CollapsingBlock.cs index e72175c..04e4207 100644 --- a/Assorted/BlockClasses/CollapsingBlock.cs +++ b/Assorted/BlockClasses/CollapsingBlock.cs @@ -10,34 +10,11 @@ using Vintagestory.GameContent; namespace FirstMachineAge { - public class CollapsingBlock : Block, ITexPositionSource + public class CollapsingBlock : Block { - internal const string CamoKey = @"camo"; - internal const string WoodKey = @"wood"; - - #region ITexPositionSource - internal string camoMaterial; - public Size2i AtlasSize { get; private set; } - private ITexPositionSource camoTextureSource; - private ITexPositionSource woodTextureSource; - private ITexPositionSource defaultTextureSource; - - public TextureAtlasPosition this[string textureCode] { - get - { - if (camoTextureSource == null ) camoTextureSource = ClientAPI.Tesselator.GetTexSource(this);//How to PRESET?? - if (woodTextureSource == null) woodTextureSource = ClientAPI.Tesselator.GetTexSource(this); - if (defaultTextureSource == null) defaultTextureSource = ClientAPI.Tesselator.GetTexSource(this); + - if (textureCode == CamoKey) return camoTextureSource[CamoKey]; - if (textureCode == WoodKey) return woodTextureSource[WoodKey]; - - return defaultTextureSource[textureCode]; - } - } - - #endregion /* EntityPlayer : EntityHumanoid EntityHumanoid : EntityAgent @@ -55,19 +32,7 @@ namespace FirstMachineAge get { return this.api as ICoreClientAPI; } } - internal CollapsingBlockEntity Entity(BlockPos here) - { - var collapseBlockEntity = api.World.BlockAccessor.GetBlockEntity(here) as CollapsingBlockEntity; - if (collapseBlockEntity == null) { - #if DEBUG - api.World.Logger.Warning($"CollapsingBlockEntity [{here}]: BlockEntity NULL! (regenerating)"); - #endif - api.World.BlockAccessor.SpawnBlockEntity(AssortedModSystems.CollapsingBlockEntityNameKey, here); - } - - return collapseBlockEntity; - } //TODO: Fall apart if player tries to 'Hoe' 'Dig' or mess with block in any way, or even place things on top of it... @@ -80,17 +45,15 @@ namespace FirstMachineAge public override void OnEntityCollide(IWorldAccessor world, Entity entity, BlockPos pos, BlockFacing facing, Vec3d collideSpeed, bool isImpact) { - //Start to shake...with particles , dust + //Start to shake...with particles , dust, creaking sounds api.World.Logger.VerboseDebug($"OnEntityCollide ({entity.Code}) of [{entity.GetType( ).Name}] @ {pos} impact: {isImpact}"); - //Check 'Volumne' of Bounding box; large ones - cause collapse... + //Tick Callback; in 200ms... + api.Event.RegisterCallback(CheckOwnVolume, pos ,200); } public override string GetPlacedBlockName(IWorldAccessor world, BlockPos pos) { - if (this.AltCover == @"soil") { - return Lang.Get(GlobalConstants.DefaultDomain + ":block-soil-verylow-none"); - } if (!String.IsNullOrEmpty(this.Cover) && !String.IsNullOrEmpty(this.Material)) { return Lang.Get(GlobalConstants.DefaultDomain + $":block-{this.Cover}-{this.Material}" ); @@ -99,6 +62,13 @@ namespace FirstMachineAge return @"Error?"; } + private void CheckOwnVolume(IWorldAccessor localAcc, BlockPos here, float delay) + { + //Check 'Volumne' of Bounding box; any 'large' entity still standing here is going to be surprised! + + + } + private string Material { @@ -125,16 +95,6 @@ namespace FirstMachineAge } } - private string AltCover { - /* - { code: "cover", states: [ "sand","gravel" ] }, - { code: "material", loadFromProperties: "block/rock", combine: "SelectiveMultiply", onVariant: "cover" }, - { code: "alt_cover", states: [ "soil" ], combine: "Add" }, - */ - get - { - return this.Variant[@"alt_cover"]; - } - } + } } \ No newline at end of file diff --git a/Assorted/BlockEntityClasses/BoltableDoorBlockEntity.cs b/Assorted/BlockEntityClasses/BoltableDoorBlockEntity.cs index d98d30b..8332b4d 100644 --- a/Assorted/BlockEntityClasses/BoltableDoorBlockEntity.cs +++ b/Assorted/BlockEntityClasses/BoltableDoorBlockEntity.cs @@ -27,9 +27,9 @@ namespace FirstMachineAge get { return this.Block as BoltableDoor; } } - public override void FromTreeAtributes(ITreeAttribute tree, IWorldAccessor worldAccessForResolve) + public override void FromTreeAttributes(ITreeAttribute tree, IWorldAccessor worldAccessForResolve) { - base.FromTreeAtributes(tree, worldAccessForResolve); + base.FromTreeAttributes(tree, worldAccessForResolve); this.Bolted = tree.GetBool(_boltedKey, false); } diff --git a/Assorted/assets/defensive/blocktypes/wood/false_floor.json b/Assorted/assets/defensive/blocktypes/wood/false_floor.json index 16e5ba3..d0612c0 100644 --- a/Assorted/assets/defensive/blocktypes/wood/false_floor.json +++ b/Assorted/assets/defensive/blocktypes/wood/false_floor.json @@ -2,29 +2,20 @@ code: "false_floor", class: "CollapsingBlock", variantgroups: [ - { code: "cover", states: [ "sand","gravel" ] }, - { code: "material", combine: "SelectiveMultiply", onVariant: "cover", states: ["andesite", "chalk", "chert", "conglomerate", "limestone", "claystone", "granite", "sandstone", "shale", "basalt", "peridotite", "phyllite", "slate"] }, - { code: "alt_cover", states: [ "soil" ], combine: "Add" }, + { code: "cover", states: [ "cobblestone","stonebricks" ] }, + { code: "material", loadFromProperties: "block/rock" }, ], creativeinventory: { "general": ["*"], "terrain": ["*"] }, shape: { base: "block/wood/false_floor" }, - blockmaterialByType: { - "*-soil": "Soil", - "*-sand-*": "Sand", - "*-gravel-*": "Gravel", - }, - texturesByType: { - "*-soil": { + blockmaterial: "Stone", + texturesByType: { + "*-cobblestone-*": { "wood": { base: "game:block/plant/bamboo/stem-brown" }, - "camo": { base: "game:block/soil/fertverylow" } + "camo": { base: "game:block/stone/cobblestone/{material}1" } }, - "*-sand-*": { + "*-stonebricks-*": { "wood": { base: "game:block/plant/bamboo/stem-brown" }, - "camo": { base: "game:block/stone/sand/{material}" } - }, - "*-gravel-*": { - "wood": { base: "game:block/plant/bamboo/stem-brown" }, - "camo": { base: "game:block/stone/gravel/{material}" } + "camo": { base: "game:block/stone/brick/{material}1" } }, }, attributes: { @@ -38,13 +29,12 @@ all: false , top: true }, replaceable: 600, - fertility: 1, resistance: 2.0, sounds: { - place: "block/sand", - break: "block/sand", - hit: "block/sand", - walk: "walk/sand" + "walk": "walk/stone", + byTool: { + "Pickaxe": { hit: "block/rock-hit-pickaxe", break: "block/rock-break-pickaxe" } + } }, heldTpIdleAnimation: "holdbothhandslarge", heldTpUseAnimation: "twohandplaceblock", tpHandTransform: { diff --git a/Assorted/assets/defensive/recipes/grid/false_floor.json b/Assorted/assets/defensive/recipes/grid/false_floor.json index 5832055..51015a2 100644 --- a/Assorted/assets/defensive/recipes/grid/false_floor.json +++ b/Assorted/assets/defensive/recipes/grid/false_floor.json @@ -2,31 +2,21 @@ { ingredientPattern: "_S_ BBB", ingredients: { - "S": { type: "block", code: "game:sand-*", quantity: 1, name: "sand", allowedVariants: ["andesite", "chalk", "chert", "conglomerate", "limestone", "claystone", "granite", "sandstone", "shale", "basalt", "peridotite", "phyllite", "slate"] }, + "S": { type: "block", code: "game:cobblestoneslab-*", quantity: 1, name: "cobblestone", allowedVariants: ["andesite", "chalk", "chert", "conglomerate", "limestone", "claystone", "granite", "sandstone", "shale", "basalt", "peridotite", "phyllite", "slate"] }, "B": { type: "item", code: "game:bamboostakes" }, }, width: 3, height: 2, - output: { type: "block", code: "false_floor-sand-{sand}", quantity: 1 } + output: { type: "block", code: "false_floor-cobblestone-{cobblestone}", quantity: 1 } }, { ingredientPattern: "_G_ BBB", ingredients: { - "G": { type: "block", code: "game:gravel-*", quantity: 1, name: "gravel", allowedVariants: ["andesite", "chalk", "chert", "conglomerate", "limestone", "claystone", "granite", "sandstone", "shale", "basalt", "peridotite", "phyllite", "slate"] }, + "G": { type: "block", code: "game:stonebrickslab-*", quantity: 1, name: "brick", allowedVariants: ["andesite", "chalk", "chert", "conglomerate", "limestone", "claystone", "granite", "sandstone", "shale", "basalt", "peridotite", "phyllite", "slate"] }, "B": { type: "item", code: "game:bamboostakes" }, }, width: 3, height: 2, - output: { type: "block", code: "false_floor-gravel-{gravel}", quantity: 1 } + output: { type: "block", code: "false_floor-brick-{brick}", quantity: 1 } }, - { - ingredientPattern: "_D_ BBB", - ingredients: { - "D": { type: "block", code: "game:soil-low-*", quantity: 1 }, - "B": { type: "item", code: "game:bamboostakes" }, - }, - width: 3, - height: 2, - output: { type: "block", code: "false_floor-soil", quantity: 1 } - } ] \ No newline at end of file diff --git a/Assorted/modinfo.json b/Assorted/modinfo.json index bdb93d2..03d11ce 100644 --- a/Assorted/modinfo.json +++ b/Assorted/modinfo.json @@ -4,6 +4,7 @@ "description" : "Defensive structures and emplacements, ideal for castles...", "authors": ["Melchior"], "version": "0.1.3", + "ModID":"defensive", "dependencies": { "game": "1.12.0", "survival": ""