快乐守护者
Vintarian-
Posts
9 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
News
Store
Everything posted by 快乐守护者
-
English: Is there a way to switch directly from first-person view to third-person view? The game’s default camera is first-person view. Pressing F5 switches to second-person view, and pressing F5 again switches to third-person view. Is there any way to switch directly from first-person view to third-person view? Does the game have any in-game commands for switching camera perspectives? For example, the commands “.clientConfig musicLevel 0” and “.clientConfig musicLevel 100” can be used to disable or enable background music. If there is a command that can directly switch to third-person view, it could be bound as a hotkey using the in-game macro editor opened with “Ctrl+M”, allowing one-key switching to third-person view. 原文: 请问如何从第一人称视角直接切换到第三人称视角? 游戏默认视角是第一人称视角,按F5可以切换到第二人称视角,再按F5可以切换到第三人称视角。有没有办法直接从第一人称视角切换到第三人称视角? 游戏内有没有切换视角的指令?比如“.clientConfig musicLevel 0"和”.clientConfig musicLevel 100“指令可以开启或关闭BGM,如果有能直接切换到第三人称视角的指令,就可以通过游戏内“Ctrl+M”调出来的宏编辑器制作成快捷键,就可以一键切换到第三人称视角了。
-
English: Thank you very much! These two methods have perfectly solved my problem. Now I can generate a pot of food at the specified coordinates "512081, 112, 512051" by using the "/zuofan" command. Here is my code. 原文: 非常感谢!这两个方法完美的解决了我的问题。我现在能通过“/zuofan”指令在指定的坐标“512081, 112, 512051”上生成一锅食物了。下面是我的代码。 ———————————————————————————————————————————————————————————————— using System; using Vintagestory.API.Common; using Vintagestory.API.MathTools; using Vintagestory.API.Server; using Vintagestory.GameContent; public class ZengruiModSystem : ModSystem { private ICoreServerAPI sapi; public override void StartServerSide(ICoreServerAPI api) { sapi = api; // 指令:获取玩家脚下坐标 api.ChatCommands .Create("huodezuobiao") .WithDescription("显示玩家脚下方块的绝对坐标") .RequiresPrivilege(Privilege.chat) .HandleWith(OnGetPosition); // 指令:在固定坐标放置一锅红肉炖胡萝卜 api.ChatCommands .Create("zuofan") .WithDescription("在固定坐标放置一锅红肉炖胡萝卜(陶锅)") .RequiresPrivilege(Privilege.chat) .HandleWith(OnPlaceCookedCrock); } // -------------------------------------------------- // /huodezuobiao private TextCommandResult OnGetPosition(TextCommandCallingArgs args) { var player = args.Caller.Player; if (player == null) { return TextCommandResult.Error("未找到玩家"); } BlockPos pos = player.Entity.Pos.AsBlockPos; return TextCommandResult.Success( $"你脚下的绝对坐标为: X={pos.X}, Y={pos.Y}, Z={pos.Z}" ); } // -------------------------------------------------- // /zuofan private TextCommandResult OnPlaceCookedCrock(TextCommandCallingArgs args) { // ★ 固定坐标(你指定的) BlockPos pos = new BlockPos(512081, 112, 512051); // 确保区块已加载 sapi.World.BlockAccessor.GetChunkAtBlockPos(pos); // -------------------------------------------------- // 1. 获取“陶锅物品对应的方块” // 注意:这是陶锅“物品”,不是直接放在世界里的方块 Block crockBlock = sapi.World.GetBlock(new AssetLocation("game", "claypot-blue-cooked")); if (crockBlock == null) { return TextCommandResult.Error("未找到陶锅方块(claypot-blue-cooked)"); } // 创建一个陶锅 ItemStack ItemStack crockStack = new ItemStack(crockBlock, 1); // -------------------------------------------------- // 2. 通过 IBlockMealContainer 给陶锅“生成一锅食物” IBlockMealContainer mealContainer = crockBlock as IBlockMealContainer; if (mealContainer == null) { return TextCommandResult.Error("该方块不是食物容器(IBlockMealContainer)"); } // 获取食材物品 Item meatItem = sapi.World.GetItem(new AssetLocation("game", "redmeat-raw")); Item carrotItem = sapi.World.GetItem(new AssetLocation("game", "vegetable-carrot")); if (meatItem == null || carrotItem == null) { return TextCommandResult.Error("未能找到红肉或胡萝卜物品"); } // 创建食材 ItemStack ItemStack meatStack = new ItemStack(meatItem, 1); ItemStack carrotStack = new ItemStack(carrotItem, 1); // ★ 核心:生成一锅“红肉炖胡萝卜” // "meatystew" 是食谱代码 mealContainer.SetContents( "meatystew", crockStack, new ItemStack[] { meatStack.Clone(), meatStack.Clone(), carrotStack.Clone(), carrotStack.Clone() } ); // -------------------------------------------------- // 3. 把“装好食物的陶锅”作为物品,放进地面存放(Ground Storage) PlaceOneItemStackAsGroundStorage(crockStack, pos); return TextCommandResult.Success( $"已在 {pos.X}, {pos.Y}, {pos.Z} 放置一锅红肉炖胡萝卜" ); } // -------------------------------------------------- // 在指定坐标创建 GroundStorage,并放入一个物品 private void PlaceOneItemStackAsGroundStorage(ItemStack itemStack, BlockPos pos) { // 获取地面存放方块 Block groundStorageBlock = sapi.World.GetBlock(new AssetLocation("game", "groundstorage")); sapi.World.BlockAccessor.SetBlock(groundStorageBlock.BlockId, pos); // 获取地面存放的 BlockEntity BlockEntityGroundStorage begs = sapi.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityGroundStorage; if (begs == null) return; // 使用 DummySlot 让系统判断存放属性 ItemSlot dummySlot = new DummySlot(itemStack); begs.DetermineStorageProperties(dummySlot); // 强制应用 GroundStorage 的存放属性 CollectibleBehaviorGroundStorable behavior = itemStack.Collectible.GetBehavior<CollectibleBehaviorGroundStorable>(); if (behavior != null) { begs.ForceStorageProps(behavior.StorageProps); } // 放入物品 begs.Inventory[0].Itemstack = itemStack.Clone(); begs.Inventory[0].MarkDirty(); // 通知世界刷新 begs.MarkDirty(true); } }
-
[Community Poll] Video Tutorials for Modding Tutorials
快乐守护者 replied to Nat_VS's topic in Official Modding API/Doc Updates
English: I think videos are necessary. As a complete novice with no prior knowledge, I tried to create my first mod using "https://wiki.vintagestory.at/Modding:Code_Tutorial_Simple_Block", but even following the step-by-step instructions, I couldn't complete it because I didn't know the meanings of many specialized terms. Finally, it was with the help of ChatGPT that this module was completed. 原文: 我认为视频是必要的。我这种一点也没学过的小白,通过“https://wiki.vintagestory.at/Modding:Code_Tutorial_Simple_Block”学习制作第一个模组,跟着一步步做都做不出来,因为很多专有名词我不知道是什么意思。最后借助ChatGPT才把这个模组做出来。 -
English: Could you please tell me how to use the mod to generate a "Hefty Red meat-Carrot stew" at the coordinate position "512081, 112, 512051" with the "/zuofan" command? I have successfully generated items at the coordinate position "512081, 112, 512051" using the "/zuofan" command through "wiki.vintagestory.at and ChatGPT", but I can only generate blocks or empty "clay pots", and I can't generate a "Dark brown ceramic pot of meat stew" like a "clay pot with Hefty Red meat-Carrot stew". Here is my code. ————————————————————————————————————————————————————————————————————————————————————————————————— 中文: 请问,如何通过模组实现用“/zuofan”指令在“512081, 112, 512051”这个坐标位置生成一份"豪华红肉-胡萝卜炖"。 我通过“wiki.vintagestory.at和ChatGPT”成功实现了用“/zuofan”指令在“512081, 112, 512051”这个坐标位置生成物品,但是只能生成方块或者空的"陶锅",无法生成"装着炖肉的深棕陶锅"这种有食物的陶锅比如装着"豪华红肉-胡萝卜炖"的陶锅。下面是我的代码。 ————————————————————————————————————————————————————————————————————————————————————————————————— using System; using Vintagestory.API.Common; using Vintagestory.API.MathTools; using Vintagestory.API.Server; using Vintagestory.GameContent; public class ZengruiModSystem : ModSystem { ICoreServerAPI sapi; public override void StartServerSide(ICoreServerAPI api) { sapi = api; // 指令 1:获取玩家脚下坐标 api.ChatCommands .Create("huodezuobiao") .WithDescription("显示玩家脚下方块的绝对坐标") .RequiresPrivilege(Privilege.chat) .HandleWith(OnGetPosition); // 指令 2:在固定坐标放置陶锅,并填充食物 api.ChatCommands .Create("zuofan") .WithDescription("在固定坐标放置红肉炖胡萝卜或陶锅") .RequiresPrivilege(Privilege.chat) .HandleWith(OnPlaceFixedBlock); } // ----------------------------- // /huodezuobiao 的回调 private TextCommandResult OnGetPosition(TextCommandCallingArgs args) { var player = args.Caller.Player; if (player == null) return TextCommandResult.Error("未找到玩家。"); // 直接获取玩家所在块坐标 BlockPos pos = player.Entity.Pos.AsBlockPos; return TextCommandResult.Success($"你脚下的绝对坐标为: X={pos.X}, Y={pos.Y}, Z={pos.Z}"); } // ----------------------------- // /zengruizuorouduncai 的回调 private TextCommandResult OnPlaceFixedBlock(TextCommandCallingArgs args) { // 固定坐标 BlockPos pos = new BlockPos(512081, 112, 512051); // 强制加载区块 sapi.World.BlockAccessor.GetChunkAtBlockPos(pos); // 使用陶锅的 ID (1093) 来获取陶锅方块 Block crockBlock = sapi.World.GetBlock(1093); // 请确保陶锅的ID正确 if (crockBlock == null) { return TextCommandResult.Error("未找到陶锅方块,请检查 block id"); } // 放置陶锅(只放在目标方块上) sapi.World.BlockAccessor.SetBlock(crockBlock.BlockId, pos); // 获取该位置的 BlockEntity var be = sapi.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityCrock; if (be != null) { // 访问陶锅的 Inventory var inv = be.Inventory; if (inv != null) { // 获取 "生红肉" 和 "胡萝卜" 的物品实例 Item meatItem = sapi.World.GetItem(new AssetLocation("game", "redmeat-raw")); Item carrotItem = sapi.World.GetItem(new AssetLocation("game", "vegetable-carrot")); if (meatItem == null || carrotItem == null) { return TextCommandResult.Error("未能找到生红肉或胡萝卜的物品,请检查物品代码"); } // 创建物品堆栈,假设数量为 1(你可以根据需要调整) ItemStack meatStack = new ItemStack(meatItem, 1); ItemStack carrotStack = new ItemStack(carrotItem, 1); // 直接设置陶锅的槽位内容 inv[0].Itemstack = meatStack; // 放入红肉 inv[1].Itemstack = carrotStack; // 放入胡萝卜 // 确保 BlockEntity 更新 be.MarkDirty(true); } } return TextCommandResult.Success($"已在 {pos.X} {pos.Y} {pos.Z} 放置陶锅,并添加了红肉和胡萝卜"); } } ————————————————————————————————————————————————————————————————————————————————————————————————— English: ChatGPT said that this piece of code of mine can generate a pottery pot filled with food, but the actual result in the world is that it generates an empty pottery pot. ————————————————————————————————————————————————————————————————————————————————————————————————— 中文: ChatGPT说我这段代码可以生成装有食物的陶锅,但是实际效果是生成一个空的陶锅。