205
edits
m (typo) |
|||
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"); | |||
Block chest = api.WorldManager.GetBlockType(blockID); | |||
chest.TryPlaceBlockForWorldGen(api.World.BlockAccessor, player.Entity.Pos.HorizontalAheadCopy(2).AsBlockPos, BlockFacing.UP); | |||
chest.TryPlaceBlockForWorldGen(api.World.BlockAccessor, | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 79: | Line 72: | ||
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 == | ||
Line 219: | Line 213: | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
BlockPos pos = player.Entity.Pos.HorizontalAheadCopy(2).AsBlockPos; | BlockPos pos = player.Entity.Pos.HorizontalAheadCopy(2).AsBlockPos; | ||
chest.TryPlaceBlockForWorldGen(api.World.BlockAccessor, pos, BlockFacing.UP | chest.TryPlaceBlockForWorldGen(api.World.BlockAccessor, pos, BlockFacing.UP); | ||
IBlockEntityContainer chestEntity = (IBlockEntityContainer)api.World.BlockAccessor.GetBlockEntity(pos); | IBlockEntityContainer chestEntity = (IBlockEntityContainer)api.World.BlockAccessor.GetBlockEntity(pos); | ||
AddItemStacks(chestEntity, MakeItemStacks()); | AddItemStacks(chestEntity, MakeItemStacks()); | ||
Line 232: | Line 226: | ||
Add the following to '''StartServerSide''' | Add the following to '''StartServerSide''' | ||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
this.api.Event.ChunkColumnGeneration(OnChunkColumnGeneration, EnumWorldGenPass.Vegetation, " | this.api.Event.ChunkColumnGeneration(OnChunkColumnGeneration, EnumWorldGenPass.Vegetation, "standard"); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
edits