Modding:World Access: Difference between revisions

From Vintage Story Wiki
(Marked this version for translation)
m (Updated to 1.19.3.)
Line 1: Line 1:
{{GameVersion|1.15}}
{{GameVersion|1.19.3}}
<languages/>
<languages/>
<translate>
<translate>
Line 75: Line 75:
         {
         {
             Block firebrickblock = api.World.GetBlock(new AssetLocation("claybricks-fire"));
             Block firebrickblock = api.World.GetBlock(new AssetLocation("claybricks-fire"));
             ushort blockId = firebrickblock.BlockId;
             int blockId = firebrickblock.BlockId;
         }
         }
</syntaxhighlight>
</syntaxhighlight>
Line 104: Line 104:
                     for (int z = -3; z <= 3; z++)
                     for (int z = -3; z <= 3; z++)
                     {
                     {
                         Block block = api.World.BlockAccessor.GetBlock(plrpos.X + x, plrpos.Y + y, plrpos.Z + z);
                         Block block = api.World.BlockAccessor.GetBlock(new BlockPos(plrpos.X + x, plrpos.Y + y, plrpos.Z + z, plrpos.dimension));
 
                       
                         <!--T:23-->
                         if (block.Code.Path.Contains("log"))
if (block.Code.Path.Contains("log"))
                         {
                         {
                             quantityLogs++;
                             quantityLogs++;
Line 115: Line 114:
             }
             }


             <!--T:24-->
             byPlayer.SendMessage(GlobalConstants.GeneralChatGroup, "You have " + quantityLogs + " logs nearby you", EnumChatType.Notification);
byPlayer.SendMessage(GlobalConstants.GeneralChatGroup, "You have " + quantityLogs + " logs nearby you", EnumChatType.Notification);
</syntaxhighlight>
</syntaxhighlight>


Line 129: Line 127:
                 plrpos.AddCopy(-3, -3, -3),  
                 plrpos.AddCopy(-3, -3, -3),  
                 plrpos.AddCopy(3, 3, 3),  
                 plrpos.AddCopy(3, 3, 3),  
                 (block, pos) => quantityLogs += block.Code.Path.Contains("log") ? 1 : 0
                 (block, x, y, z) => quantityLogs += block.Code.Path.Contains("log") ? 1 : 0
             );
             );


Line 143: Line 141:
         private void OnPlayerJoin(IServerPlayer byPlayer)
         private void OnPlayerJoin(IServerPlayer byPlayer)
         {
         {
            Block firebrickblock = api.World.GetBlock(new AssetLocation("claybricks-fire"));
            int blockId = firebrickblock.BlockId;
             BlockPos plrpos = byPlayer.Entity.Pos.AsBlockPos;
             BlockPos plrpos = byPlayer.Entity.Pos.AsBlockPos;
            <!--T:30-->
Block firebrickblock = api.World.GetBlock(new AssetLocation("claybricks-fire"));
            ushort blockId = firebrickblock.BlockId;
             api.World.BlockAccessor.SetBlock(blockId, plrpos.DownCopy());
             api.World.BlockAccessor.SetBlock(blockId, plrpos.DownCopy());


             <!--T:31-->
             // Check a 7x7x7 area for logs
// Check a 7x7x7 area for logs
             int quantityLogs = 0;
             int quantityLogs = 0;
             api.World.BlockAccessor.WalkBlocks(
             api.World.BlockAccessor.WalkBlocks(
                 plrpos.AddCopy(-3, -3, -3),  
                 plrpos.AddCopy(-3, -3, -3),
                 plrpos.AddCopy(3, 3, 3),  
                 plrpos.AddCopy(3, 3, 3),
                 (block, pos) => quantityLogs += block.Code.Path.Contains("log") ? 1 : 0
                 (block, x, y, z) => quantityLogs += block.Code.Path.Contains("log") ? 1 : 0
             );
             );


             <!--T:32-->
             byPlayer.SendMessage(GlobalConstants.GeneralChatGroup, "You have " + quantityLogs + " logs nearby you", EnumChatType.Notification);
byPlayer.SendMessage(GlobalConstants.GeneralChatGroup, "You have " + quantityLogs + " logs nearby you", EnumChatType.Notification);
 
         }
         }
</syntaxhighlight>
</syntaxhighlight>