Confirmedusers, editor
749
edits
m (Fix api changes →Hooking in to the world gen API) |
(Updated deprecated code, but text needs to be changed) |
||
Line 64: | Line 64: | ||
private void PlaceTreasureChestInFrontOfPlayer(IServerPlayer player, int groupId, CmdArgs args) | private void PlaceTreasureChestInFrontOfPlayer(IServerPlayer player, int groupId, CmdArgs args) | ||
{ | { | ||
ushort blockID = api.WorldManager.GetBlockId("chest-south"); | // Old, don't work on latest version | ||
Block chest = api.WorldManager.GetBlockType(blockID); | // ushort blockID = api.WorldManager.GetBlockId("chest-south"); | ||
chest.TryPlaceBlockForWorldGen(api.World.BlockAccessor, player.Entity.Pos.HorizontalAheadCopy(2).AsBlockPos, BlockFacing.UP); | // Block chest = api.WorldManager.GetBlockType(blockID); | ||
// chest.TryPlaceBlockForWorldGen(api.World.BlockAccessor, player.Entity.Pos.HorizontalAheadCopy(2).AsBlockPos, BlockFacing.UP); | |||
// New, work on latest version | |||
Block chest = api.World.GetBlock(new AssetLocation("chest-south")); | |||
chest.TryPlaceBlockForWorldGen(api.World.BlockAccessor, | |||
player.Entity.Pos.HorizontalAheadCopy(2).AsBlockPos, BlockFacing.UP, null | |||
); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 72: | Line 79: | ||
Now if you run the mod from Visual Studio by pressing "Start" at the top you should be able to execute the '''/treasure''' command in the game. Once you do that you will have a fancy new chest appear in front of you with no items. Well I guess it's time for us to add some items. | Now if you run the mod from Visual Studio by pressing "Start" at the top you should be able to execute the '''/treasure''' command in the game. Once you do that you will have a fancy new chest appear in front of you with no items. Well I guess it's time for us to add some items. | ||
== Adding items to our chest == | == Adding items to our chest == |