当前位置: 首页>>代码示例>>C#>>正文


C# IWorld.SetTileEntity方法代码示例

本文整理汇总了C#中IWorld.SetTileEntity方法的典型用法代码示例。如果您正苦于以下问题:C# IWorld.SetTileEntity方法的具体用法?C# IWorld.SetTileEntity怎么用?C# IWorld.SetTileEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IWorld的用法示例。


在下文中一共展示了IWorld.SetTileEntity方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BlockMined

 public override void BlockMined(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     var entity = world.GetTileEntity(descriptor.Coordinates);
     if (entity != null)
     {
         foreach (var item in (NbtList)entity["Items"])
         {
             var manager = user.Server.GetEntityManagerForWorld(world);
             var slot = ItemStack.FromNbt((NbtCompound)item);
             manager.SpawnEntity(new ItemEntity(descriptor.Coordinates + new Vector3(0.5), slot));
         }
         world.SetTileEntity(descriptor.Coordinates, null);
     }
     base.BlockMined(descriptor, face, world, user);
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:15,代码来源:FurnaceBlock.cs

示例2: BlockRightClicked

        public override bool BlockRightClicked(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
        {
            var adjacent = -Coordinates3D.One; // -1, no adjacent chest
            var self = descriptor.Coordinates;
            for (int i = 0; i < AdjacentBlocks.Length; i++)
            {
                var test = self + AdjacentBlocks[i];
                if (world.GetBlockID(test) == ChestBlock.BlockID)
                {
                    adjacent = test;
                    var up = world.BlockRepository.GetBlockProvider(world.GetBlockID(test + Coordinates3D.Up));
                    if (up.Opaque && !(up is WallSignBlock)) // Wall sign blocks are an exception
                        return false; // Obstructed
                    break;
                }
            }
            var upSelf = world.BlockRepository.GetBlockProvider(world.GetBlockID(self + Coordinates3D.Up));
            if (upSelf.Opaque && !(upSelf is WallSignBlock))
                return false; // Obstructed

            if (adjacent != -Coordinates3D.One)
            {
                // Ensure that chests are always opened in the same arrangement
                if (adjacent.X < self.X ||
                    adjacent.Z < self.Z)
                {
                    var _ = adjacent;
                    adjacent = self;
                    self = _; // Swap
                }
            }

            var window = new ChestWindow((InventoryWindow)user.Inventory, adjacent != -Coordinates3D.One);
            // Add items
            var entity = world.GetTileEntity(self);
            if (entity != null)
            {
                foreach (var item in (NbtList)entity["Items"])
                {
                    var slot = ItemStack.FromNbt((NbtCompound)item);
                    window.ChestInventory[slot.Index] = slot;
                }
            }
            // Add adjacent items
            if (adjacent != -Coordinates3D.One)
            {
                entity = world.GetTileEntity(adjacent);
                if (entity != null)
                {
                    foreach (var item in (NbtList)entity["Items"])
                    {
                        var slot = ItemStack.FromNbt((NbtCompound)item);
                        window.ChestInventory[slot.Index + ChestWindow.DoubleChestSecondaryIndex] = slot;
                    }
                }
            }
            window.WindowChange += (sender, e) =>
                {
                    var entitySelf = new NbtList("Items", NbtTagType.Compound);
                    var entityAdjacent = new NbtList("Items", NbtTagType.Compound);
                    for (int i = 0; i < window.ChestInventory.Items.Length; i++)
                    {
                        var item = window.ChestInventory.Items[i];
                        if (!item.Empty)
                        {
                            if (i < ChestWindow.DoubleChestSecondaryIndex)
                            {
                                item.Index = i;
                                entitySelf.Add(item.ToNbt());
                            }
                            else
                            {
                                item.Index = i - ChestWindow.DoubleChestSecondaryIndex;
                                entityAdjacent.Add(item.ToNbt());
                            }
                        }
                    }
                    var newEntity = world.GetTileEntity(self);
                    if (newEntity == null)
                        newEntity = new NbtCompound(new[] { entitySelf });
                    else
                        newEntity["Items"] = entitySelf;
                    world.SetTileEntity(self, newEntity);
                    if (adjacent != -Coordinates3D.One)
                    {
                        newEntity = world.GetTileEntity(adjacent);
                        if (newEntity == null)
                            newEntity = new NbtCompound(new[] { entityAdjacent });
                        else
                            newEntity["Items"] = entityAdjacent;
                        world.SetTileEntity(adjacent, newEntity);
                    }
                };
            user.OpenWindow(window);
            return false;
        }
开发者ID:ac682,项目名称:TrueCraft,代码行数:96,代码来源:ChestBlock.cs

示例3: SetState

 private void SetState(IWorld world, Coordinates3D coords, FurnaceState state)
 {
     world.SetTileEntity(coords, new NbtCompound(new NbtTag[]
     {
         new NbtShort("BurnTime", state.BurnTimeRemaining),
         new NbtShort("BurnTotal", state.BurnTimeTotal),
         new NbtShort("CookTime", state.CookTime),
         new NbtList("Items", new[]
         {
             state.Items[0].ToNbt(),
             state.Items[1].ToNbt(),
             state.Items[2].ToNbt()
         }, NbtTagType.Compound)
     }));
     UpdateWindows(coords, state);
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:16,代码来源:FurnaceBlock.cs

示例4: BlockMined

 public override void BlockMined(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     world.SetTileEntity(descriptor.Coordinates, null);
     base.BlockMined(descriptor, face, world, user);
 }
开发者ID:Gbear605,项目名称:TrueCraft,代码行数:5,代码来源:WallSignBlock.cs


注:本文中的IWorld.SetTileEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。