Exemplo n.º 1
0
Arquivo: Level.cs Projeto: wgaox/MiNET
        public void SetBlockEntity(BlockEntity blockEntity, bool broadcast = true)
        {
            ChunkColumn chunk = _worldProvider.GenerateChunkColumn(new ChunkCoordinates(blockEntity.Coordinates.X >> 4, blockEntity.Coordinates.Z >> 4));

            chunk.SetBlockEntity(blockEntity.Coordinates, blockEntity.GetCompound());

            if (blockEntity.UpdatesOnTick)
            {
                BlockEntities.Add(blockEntity);
            }

            if (!broadcast)
            {
                return;
            }

            Nbt nbt = new Nbt
            {
                NbtFile = new NbtFile
                {
                    BigEndian = false,
                    RootTag   = blockEntity.GetCompound()
                }
            };

            var entityData = new McpeTileEntityData
            {
                namedtag = nbt,
                x        = blockEntity.Coordinates.X,
                y        = (byte)blockEntity.Coordinates.Y,
                z        = blockEntity.Coordinates.Z
            };

            RelayBroadcast(entityData);
        }
Exemplo n.º 2
0
        private void LoadNbtBlockEntity(NbtTag nbtTag)
        {
            var blockEntityTag = (NbtCompound)nbtTag.Clone();
            int x = blockEntityTag["x"].IntValue;
            int y = blockEntityTag["y"].IntValue;
            int z = blockEntityTag["z"].IntValue;

            var coords = new BlockCoordinates(x, y, z);

            Debug.WriteLine($"Found TileEntity at {x},{y},{z}: {nbtTag["id"].StringValue}");

            BlockEntities.Add(coords, blockEntityTag);
        }